当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Processing PShape.setFill()用法及代码示例


Processing, 类PShape中的setFill()用法介绍。

用法

  • sh.setFill(fill)

参数

  • sh (PShape) 任何 PShape 类型的变量

返回

  • void

说明

setFill() 方法定义了 PShape 的填充颜色。此方法在创建形状后或显式定义形状时使用(例如 createShape(RECT, 20, 20, 80, 80) ),如上例所示。当使用 beginShape()endShape() 创建形状时,可以在 beginShape()endShape() 中使用 fill()stroke() 更改其属性。但是,在创建形状后,只有 setFill() 方法可以为 PShape 定义新的填充值。

例子

PShape circle;

void setup() {  
  size(640, 360, P2D);
  circle = createShape(ELLIPSE, 0, 0, 200, 200);
  circle.setStroke(color(255));  
}

void draw() {
  background(51);
  circle.setFill(color(random(255)));
  translate(mouseX, mouseY);
  shape(circle);
}

相关用法


注:本文由纯净天空筛选整理自processing.org大神的英文原创作品 PShape.setFill()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。