Cocos Creator
Fill
The fill()
method is used to fill the current image (path). The color used is fillColor
.
Note: if the path is not closed, the
fill()
method adds a line from the end of the path to the start point to close the path and then fills the path.
Example
ts
const ctx = node.getComponent(Graphics);
ctx.rect(20,20,150,100);
ctx.fillColor = Color.GREEN;
ctx.fill();

Return to the Graphics Component Reference documentation.