diff --git a/README.txt b/README.txt index 2046710..f44e097 100644 --- a/README.txt +++ b/README.txt @@ -61,7 +61,7 @@ Library - (open name ~scale) Imports a graphic file with format. - (import name ~shape) Imports a graphic file with format. -- (export ~name ~format ~quality) Exports a graphic file with format. +- (export ~format ~quality) Exports a graphic file with format. - (print string) Exports string to file. - (pos ~x ~y) Returns a position shape. - (line ax ay bx by) Returns a line shape. diff --git a/index.html b/index.html index 3a43380..ade82e3 100644 --- a/index.html +++ b/index.html @@ -896,9 +896,9 @@ function Library (client) { client.surface.draw(img, shape, alpha) return shape || this.rect(0, 0, img.width, img.height) } - this.export = (name = 'ronin', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format. - const ext = type === 'image/png' ? name + '.png' : name + '.jpg' - client.source.write(name, ext, client.surface.el.toDataURL(type, quality), type) + this.export = (format = 'jpg', quality = 0.9) => { // Exports a graphic file with format. + const type = `image/${format === 'jpeg' || format === 'jpg' ? 'jpeg' : 'png'}` + client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type) } this.pos = (x = 0, y = 0) => { // Returns a position shape. return { x, y } diff --git a/scripts/library.js b/scripts/library.js index ffd2eac..8c8c997 100644 --- a/scripts/library.js +++ b/scripts/library.js @@ -20,9 +20,9 @@ function Library (client) { return shape || this.rect(0, 0, img.width, img.height) } - this.export = (name = 'ronin', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format. - const ext = type === 'image/png' ? name + '.png' : name + '.jpg' - client.source.write(name, ext, client.surface.el.toDataURL(type, quality), type) + this.export = (format = 'jpg', quality = 0.9) => { // Exports a graphic file with format. + const type = `image/${format === 'jpeg' || format === 'jpg' ? 'jpeg' : 'png'}` + client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type) } // Shapes