This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let currentDocument = app.activeDocument; | |
/* | |
load in the image as an array buffer - will open in new document | |
*/ | |
app.activeDocument.activeLayer.copy(true); | |
app.activeDocument.close(); | |
app.activeDocument = currentDocument; | |
let newLayer = currentDocument.layers.add(); | |
currentDocument.paste(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Make Firefox number inputs show/hide spinner arrows like in Chrome */ | |
input[type=number] { | |
-moz-appearance: textfield; | |
} | |
input[type=number]:hover { | |
-moz-appearance: revert!important; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses Photopea.js | |
var addImageAndWait = async function(contentWindow, imgURI) { | |
return new Promise(async function(resolve) { | |
var layerCountOld = "done"; | |
while (layerCountOld == "done") layerCountOld = (await Photopea.runScript(contentWindow, `app.echoToOE(app.activeDocument.layers.length)`))[0]; | |
var layerCountNew = layerCountOld; | |
await Photopea.runScript(contentWindow, `app.open("${imgURI}", null, true);`); | |
var layerCheckInterval = async function () { | |
layerCountNew = (await Photopea.runScript(contentWindow, `app.echoToOE(app.activeDocument.layers.length)`))[0]; | |
if (layerCountNew == layerCountOld + 1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.integrate = function(fn, a, b, deltaX = 0.0001) { | |
var out = 0; | |
for (var x = a; x < b; x += deltaX) out += deltaX * fn(x); | |
return out; | |
}; |