【问题标题】:Using fill(); with line(); in processing使用填充();与线();进行中
【发布时间】:2015-09-26 20:36:16
【问题描述】:

想知道我是否可以用颜色填充封闭路径,可以这样做吗?

这是我遇到问题的一个基本示例。

void setup() {
size(640, 360);

    fill(122,161,158);
    strokeWeight(1);
    stroke(0,0,0);
    line(548,144,516,220);
    line(516,220,599,257);
    line(599,257,548,144);
}

填充似乎不起作用。填充是否仅适用于 rect() 等预定义形状?如果是这样,有没有办法填写封闭线。 我正在使用处理 2.2.1

【问题讨论】:

    标签: line processing fill


    【解决方案1】:

    请查看beginShape():

    void setup() {
    size(640, 360);
    
        fill(122,161,158);
        strokeWeight(1);
        stroke(0,0,0);
        beginShape();
        vertex(548,144);vertex(516,220);
        vertex(516,220);vertex(599,257);
        vertex(599,257);vertex(548,144);
        endShape();
    }
    

    另外查看createShape()

    【讨论】:

      【解决方案2】:

      line() 函数就是这样做的:它画一条线。处理没有使用此函数定义的区域的概念。

      相反,您想使用shape functions。以下是您可以做到的一种方式:

      void setup() {
         size(640, 360);
      
         fill(122,161,158);
         strokeWeight(1);
         stroke(0,0,0);
      
         beginShape();
         vertex(548,144);
         vertex(516,220);
         vertex(599);
         vertex(30, 75);
         endShape(CLOSE);
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-08
        • 1970-01-01
        • 1970-01-01
        • 2022-08-19
        • 2017-09-15
        • 2020-12-22
        • 2018-04-30
        • 2021-10-11
        相关资源
        最近更新 更多