Assuming that the drawing object is a group, how to add a stroke to it using jsfl?
I have some confusion. When the object I select is a drawing object or shape, I can use the following code to add a stroke to it.
fl.getDocumentDOM().selection[0].x += 0;
fl.getDocumentDOM().setStrokeSize(10);This code cannot take effect on the selected group or symbol.
Using the history function I get code like this:
an.getDocumentDOM().setStroke('#000000', 10, 'solid');Repeated operations found that this code only takes effect on the drawing object union.
Back to my question:
If the selected object is a group or symbol, the following code cannot stroke it.
customStrokeWidth = 10;
if (customStrokeWidth) {
var doc = fl.getDocumentDOM();
var selection = doc.selection[0];
myStroke(selection, customStrokeWidth);
}
function myStroke(element, strokeWidth) {
if (element.elementType === "group") {
var elements = element.getElements();
for (var i = 0; i < elements.length; i++) {
var nestedElement = elements[i];
myStroke(nestedElement, strokeWidth);
}
} else {
doc.selection = [element];
doc.setStrokeSize(strokeWidth);
}
}Did I miss something?
