问题描述
例如 //绘制矩形
doc.addNewLine ({x:0,y:0},{x:2000,y:0});
doc.addNewLine({x:2000,y:0},{x:2000,y:500});
doc.addNewLine({x:2000,y:500},{x:0,y:500});
doc.addNewLine({x:0,y:500},{x:0,y:0});
//如何填充它,因为这种方式不起作用
doc.setFillColor('#0000ff');
舞台。这个结合了你的矩形形状和#0000FF的颜色:
pre $创建带填充的矩形Andrew Doll
var dom = fl.getDocumentDOM();
if(dom == null)
{
alert('请打开一个文件');
}
else
{
//声明变量。
var tl = dom.getTimeline();
var curLayer = tl.currentLayer;
var curFrame = tl.currentFrame;
var lockStatus = tl.layers [curLayer] .locked;
var myElements = tl.layers [curLayer] .frames [0] .elements;
if(lockStatus)
{
alert('Unlock the layer。');
}
else
{
//绘制矩形。
dom.addNewLine({x:0,y:0},{x:2000,y:0});
dom.addNewLine({x:2000,y:0},{x:2000,y:500});
dom.addNewLine({x:2000,y:500},{x:0,y:500});
dom.addNewLine({x:0,y:500},{x:0,y:0});
//将当前图层设置为选中状态。
tl.setSelectedLayers(curLayer);
tl.setSelectedFrames(0,0,true);
//检查是否有选定的作品。
var mySelectedFrames = tl.getSelectedFrames();
//选择当前帧。
tl.setSelectedFrames(curFrame,curFrame,true);
//设置对象内部的填充颜色。
var insideContour = dom.selection [0] .contours [0];
var insideFill = insideContour.fill;
insideFill.color ='#0000ff';
dom.setFillColor('#0000ff');
dom.selectNone();
}
}
I draw figure in Flsh ID with JSFL methods, for example
// draw rectangle
doc.addNewLine({x:0, y:0}, {x:2000, y:0});
doc.addNewLine({x:2000, y:0}, {x:2000, y:500});
doc.addNewLine({x:2000, y:500}, {x:0, y:500});
doc.addNewLine({x:0, y:500}, {x:0, y:0});
// how can I fill it, because this way doesn't work
doc.setFillColor('#0000ff');
Another method that I have found useful for filling shapes on the stage. This incorporates your rectangle shape and the "#0000FF" color:
// Create Rectangle With Fill - Andrew Doll
var dom = fl.getDocumentDOM();
if (dom == null)
{
alert('Please open a file.');
}
else
{
// Declare variables.
var tl = dom.getTimeline();
var curLayer = tl.currentLayer;
var curFrame = tl.currentFrame;
var lockStatus = tl.layers[curLayer].locked;
var myElements = tl.layers[curLayer].frames[0].elements;
if (lockStatus)
{
alert('Unlock the layer.');
}
else
{
// Draw rectangle.
dom.addNewLine({x:0, y:0}, {x:2000, y:0});
dom.addNewLine({x:2000, y:0}, {x:2000, y:500});
dom.addNewLine({x:2000, y:500}, {x:0, y:500});
dom.addNewLine({x:0, y:500}, {x:0, y:0});
// Sets the current layer as selected.
tl.setSelectedLayers(curLayer);
tl.setSelectedFrames(0, 0, true);
// Checks to see if there is artwork selected.
var mySelectedFrames = tl.getSelectedFrames();
// Selects current frame.
tl.setSelectedFrames(curFrame, curFrame, true);
// Sets the fill color for the inside of the object.
var insideContour = dom.selection[0].contours[0];
var insideFill = insideContour.fill;
insideFill.color = '#0000ff';
dom.setFillColor('#0000ff');
dom.selectNone();
}
}
这篇关于用JSFL填充图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!