felixSchl / photoshop.d.ts

Typescript declaration files and generator for the Photoshop javascript API
Other
78 stars 9 forks source link

Separate class declarations from interfaces #14

Closed perludum closed 6 years ago

perludum commented 6 years ago

Half of the PS objects/functions are DOM objects and perfectly declared as interfaces, while the other half actually are used like classes and can be instantiated.

DOM objects can be filtered on their "parent" property. Just "MeasurementLog" and "MeasurementScale" do not have this property for some reason. "Application" and "UnitValue" are special cases anyway. These exceptions are respected in the renderer (kind of hardcoded...). Let me know what you think about it.

The other part of functions will now be declared as classes. They do not have explicit parameters in their constructors (nor are they documented), but Extendscript wants them to be specified like this:

var myColor = new SolidColor()
myColor.rgb.blue = 50
myColor.rgb.green = 40
myColor.rgb.red = 90

There's a separate file in the assets now that documents what's a DOM object or a class for any possible future use.

Finally a minor fix in the assets about arrays of 2D point coordinates (should be number[][], documentation says just number[]). Example:

let A = [0, 0];
let B = [50, 0];
let C = [50, 50];
let D = [0, 50];
let square = [A, B, C, D];
app.activeDocument.selection.select(square);
felixSchl commented 6 years ago

I had a read over it, looks good to me. Are you happy to have this merged?

perludum commented 6 years ago

Thanks for reviewing! I'm happy with a merge 👍