Fixed issue with window hiding on linux
This commit is contained in:
parent
9377a90b6a
commit
6091444e65
@ -180,7 +180,7 @@ function Client () {
|
|||||||
if (file.type === 'image/jpeg' || file.type === 'image/png') {
|
if (file.type === 'image/jpeg' || file.type === 'image/png') {
|
||||||
const img = new Image()
|
const img = new Image()
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
this.cache.set(file.name, img.src)
|
this.cache.set(file.name, img)
|
||||||
this.commander.injectPath(file.name)
|
this.commander.injectPath(file.name)
|
||||||
this.log('Loaded ' + file.name)
|
this.log('Loaded ' + file.name)
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,10 @@
|
|||||||
function Library (client) {
|
function Library (client) {
|
||||||
// IO
|
// IO
|
||||||
this.import = async (name, shape, alpha = 1) => { // Imports a graphic file with format.
|
this.import = async (name, shape, alpha = 1) => { // Imports a graphic file with format.
|
||||||
const src = client.cache.get(name)
|
const img = client.cache.get(name)
|
||||||
if (!src) { client.log('No data for ' + name); return }
|
if (!img) { client.log('No data for ' + name); return }
|
||||||
const img = new Image()
|
client.surface.draw(img, shape, alpha)
|
||||||
img.src = src
|
return shape || this.rect(0, 0, img.width, img.height)
|
||||||
return client.surface.draw(img, shape, alpha)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.export = async (name = 'export', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
|
this.export = async (name = 'export', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
|
||||||
|
@ -173,22 +173,8 @@ function Surface (client) {
|
|||||||
|
|
||||||
// IO
|
// IO
|
||||||
|
|
||||||
this.open = (path, ratio = 1) => {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
const img = new Image()
|
|
||||||
img.src = path
|
|
||||||
img.onload = () => {
|
|
||||||
const rect = { x: 0, y: 0, w: img.width * ratio, h: img.height * ratio }
|
|
||||||
this.resize(rect, true)
|
|
||||||
this.context.drawImage(img, rect.x, rect.y, rect.w, rect.h)
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.draw = function (img, shape = this.getFrame(), alpha = 1) {
|
this.draw = function (img, shape = this.getFrame(), alpha = 1) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
img.onload = () => {
|
|
||||||
this.context.globalAlpha = alpha
|
this.context.globalAlpha = alpha
|
||||||
if (isLine(shape)) {
|
if (isLine(shape)) {
|
||||||
this.context.drawImage(img, shape.a.x, shape.a.y, shape.b.x - shape.a.x, shape.b.y - shape.a.y)
|
this.context.drawImage(img, shape.a.x, shape.a.y, shape.b.x - shape.a.x, shape.b.y - shape.a.y)
|
||||||
@ -205,11 +191,11 @@ function Surface (client) {
|
|||||||
}
|
}
|
||||||
this.context.globalAlpha = 1
|
this.context.globalAlpha = 1
|
||||||
resolve()
|
resolve()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.crop = function (rect) {
|
this.crop = function (rect) {
|
||||||
|
if (!isRect(rect)) { return }
|
||||||
client.log(`Crop ${rect.w}x${rect.h} from ${rect.x}x${rect.y}`)
|
client.log(`Crop ${rect.w}x${rect.h} from ${rect.x}x${rect.y}`)
|
||||||
const crop = this.copy(rect)
|
const crop = this.copy(rect)
|
||||||
this.resize(rect, true)
|
this.resize(rect, true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user