Paul,
could you please confirm that ScriptUIPath cannot be stored in variables?
That is, I can add / stroke / fill different paths, but I can't refer to anything (nor change/update) but the current Path, am I right?
Apparently, the ScriptUIPath object has no properties or methods (JS Tools Guide, p.162).
Anyway, I'm now operative with the project I was working on, thanks again!
Davide
Drawing in a ScriptUI window
Drawing in a ScriptUI window
I haven't found a way to amend/add to a previous path, it seems that only the current path can be added to or the stroke amended.
Drawing in a ScriptUI window
Paul,
I'm afraid I'll take advantage once more of your ScriptUI drawing skills
I've been able to basically do what I wanted, which is more or less as follows:
Apparently, I couldn't find a way to refresh the drawing.
The onDraw() is:
Code: Select allcurveGraphic = win.curvePanel.canvas.graphics;
win.curvePanel.canvas.onDraw = function() {
var blackPen, blueBrush, i;
// White background
curveGraphic.newPath();
curveGraphic.rectPath(0, 0, 255, 255);
curveGraphic.fillPath(curveGraphic.newBrush(curveGraphic.BrushType.SOLID_COLOR, [1, 1, 1, 1], 1));
// Blue function
curveGraphic.newPath();
curveGraphic.moveTo(0, 255);
i = 0;
while (i < 256) {
curveGraphic.lineTo(i, 255 - curveFunction(i));
i++;
}
curveGraphic.lineTo(255, 255);
curveGraphic.lineTo(0, 255);
blueBrush = curveGraphic.newBrush(curveGraphic.BrushType.SOLID_COLOR, [0.7, 0.8, 0.9, 1]);
curveGraphic.fillPath(blueBrush);
// Black square
blackPen = curveGraphic.newPen(curveGraphic.PenType.SOLID_COLOR, [0, 0, 0, 1], 1);
curveGraphic.newPath();
curveGraphic.rectPath(0, 0, 255, 255);
curveGraphic.strokePath(blackPen);
};
Which is ok, since as I call the Window code, the graphic is correctly displayed.
I've linked a:
Code: Select allwin.curvePanel.canvas.onDraw.call();
to the DropDownList.onChange() handler, that you use to recall formulas to update the graph. It calls the re-drawing, but then the onDraw() fails when it comes to fill the Path ("cannot execute") - and if I comment it, it stops to the next fill. I don't know whether it is because I can't (or at least I don't know how to) first cancel the drawing - there's no delete method - or because I can't call onDraw() but once.
The weird part is that the rectPath() goes fine.
I'm stuck here - which is kind of sad since I can draw beautiful graphics but I can't update them!
One thing that came to my mind (which I could try maybe tomorrow) is to procedurally add and remove the curvePanel altogether - a bit rude...
Any suggestion is really appreciated!
Thanks again
Davide
I'm afraid I'll take advantage once more of your ScriptUI drawing skills
I've been able to basically do what I wanted, which is more or less as follows:
Apparently, I couldn't find a way to refresh the drawing.
The onDraw() is:
Code: Select allcurveGraphic = win.curvePanel.canvas.graphics;
win.curvePanel.canvas.onDraw = function() {
var blackPen, blueBrush, i;
// White background
curveGraphic.newPath();
curveGraphic.rectPath(0, 0, 255, 255);
curveGraphic.fillPath(curveGraphic.newBrush(curveGraphic.BrushType.SOLID_COLOR, [1, 1, 1, 1], 1));
// Blue function
curveGraphic.newPath();
curveGraphic.moveTo(0, 255);
i = 0;
while (i < 256) {
curveGraphic.lineTo(i, 255 - curveFunction(i));
i++;
}
curveGraphic.lineTo(255, 255);
curveGraphic.lineTo(0, 255);
blueBrush = curveGraphic.newBrush(curveGraphic.BrushType.SOLID_COLOR, [0.7, 0.8, 0.9, 1]);
curveGraphic.fillPath(blueBrush);
// Black square
blackPen = curveGraphic.newPen(curveGraphic.PenType.SOLID_COLOR, [0, 0, 0, 1], 1);
curveGraphic.newPath();
curveGraphic.rectPath(0, 0, 255, 255);
curveGraphic.strokePath(blackPen);
};
Which is ok, since as I call the Window code, the graphic is correctly displayed.
I've linked a:
Code: Select allwin.curvePanel.canvas.onDraw.call();
to the DropDownList.onChange() handler, that you use to recall formulas to update the graph. It calls the re-drawing, but then the onDraw() fails when it comes to fill the Path ("cannot execute") - and if I comment it, it stops to the next fill. I don't know whether it is because I can't (or at least I don't know how to) first cancel the drawing - there's no delete method - or because I can't call onDraw() but once.
The weird part is that the rectPath() goes fine.
I'm stuck here - which is kind of sad since I can draw beautiful graphics but I can't update them!
One thing that came to my mind (which I could try maybe tomorrow) is to procedurally add and remove the curvePanel altogether - a bit rude...
Any suggestion is really appreciated!
Thanks again
Davide
Drawing in a ScriptUI window
That graph is very impressive Davide!
The tests I've done even crash ESTK and still no way to update, what I haven't tried yet is to use stacked panels and swop them when required?
The tests I've done even crash ESTK and still no way to update, what I haven't tried yet is to use stacked panels and swop them when required?
Drawing in a ScriptUI window
Paul MR wrote:That graph is very impressive Davide!
Thanks Paul!
My goal is to make a panel that loads preset formulas and leaves the opportunity to write your own (in the text area, as JS).
These curves will become actual Curves adjustment layers mathematically drawn - it's a little project I'm building in my spare time, still have to find a place for it besides the fun gradients I've linked before.
Yet, if I'm not able to re-draw the graphics, it's quite pointless - stacking could be an option for the presets (which are known), but the user can add his/her own ones so it's got to be dynamically generated. I'll try to delete and rebuild the Panel which is the canvas base (actually I don't even know if you can delete a Panel instance, I'll go through the Guide once more )
Possibly I'll post to the Adobe forum too, maybe it's worth trying (to tell the truth, I'm always dubious when I've questions to ask - naturally I tend to post here on ps-scripts because that's what I'm used to and the community seems to be... more focused. Then I ask to myself why not Adobe? But to crosspost looks weird - and my impression is that Adobe forum is a bit more desultory (it this is the right english word). Given the attention they're giving to users these times, it's rarer and rarer that an Adobe engineer could answer you. Enough rants
Thanks for your help so far, your suggestions have been precious!
Davide
-----
UPDATE
I'm having some results with Custom objects, I'll keep you updated
Thanks Paul!
My goal is to make a panel that loads preset formulas and leaves the opportunity to write your own (in the text area, as JS).
These curves will become actual Curves adjustment layers mathematically drawn - it's a little project I'm building in my spare time, still have to find a place for it besides the fun gradients I've linked before.
Yet, if I'm not able to re-draw the graphics, it's quite pointless - stacking could be an option for the presets (which are known), but the user can add his/her own ones so it's got to be dynamically generated. I'll try to delete and rebuild the Panel which is the canvas base (actually I don't even know if you can delete a Panel instance, I'll go through the Guide once more )
Possibly I'll post to the Adobe forum too, maybe it's worth trying (to tell the truth, I'm always dubious when I've questions to ask - naturally I tend to post here on ps-scripts because that's what I'm used to and the community seems to be... more focused. Then I ask to myself why not Adobe? But to crosspost looks weird - and my impression is that Adobe forum is a bit more desultory (it this is the right english word). Given the attention they're giving to users these times, it's rarer and rarer that an Adobe engineer could answer you. Enough rants
Thanks for your help so far, your suggestions have been precious!
Davide
-----
UPDATE
I'm having some results with Custom objects, I'll keep you updated
Drawing in a ScriptUI window
It might be best to post in the Adobe InDesign scripting forum as there are some extremely clever/knowledgeable people with ScriptUI