Changed export def

This commit is contained in:
neauoire 2020-04-07 11:01:07 +09:00
parent 965c071aed
commit 0fc8103e7a
3 changed files with 7 additions and 7 deletions

View File

@ -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.

View File

@ -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 }

View File

@ -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