text LLL Square line to corner.pde

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text LLL Square line to corner.pde相关的知识,希望对你有一定的参考价值。

float pointNo = 100;
float stage = 0.0;

PVector point1;
PVector point2;
PVector point3;
PVector point4;
PVector point5, point6, point7, point8;
PVector l1mp, l2mp, l3mp, l4mp;
PVector l5mp, l6mp, l7mp, l8mp;

int colourValue = 0;


void setup() {
  size(1000, 1000);
  noLoop();
  translate(1000, 1000);
  strokeWeight(2);
  background(50,48,49);

  point1 = new PVector(100, 100);
  point2 = new PVector(900, 100);
  point3 = new PVector(900, 900);
  point4 = new PVector(100, 900);
  
  point5 = new PVector(900, 100);
  point6 = new PVector(900, 100);
  point7 = new PVector(900, 900);
  point8 = new PVector(900, 900); 
}

void draw() {

  stage = 0;
  
    for (int i = 0; i < pointNo+1; i++) {

          if (colourValue == 0){
    stroke(23,126,137);
    } else if (colourValue == 1){
    stroke(8,76,97);
    } else if (colourValue == 2){
    stroke(219,58,52);
    } else if (colourValue == 3){
    stroke(255,200,87);
    }
     
/*
    l1mp = PVector.lerp(point1, point2, stage);
    l2mp = PVector.lerp(point2, point3, stage);
    l3mp = PVector.lerp(point3, point4, stage);
    l4mp = PVector.lerp(point4, point1, stage);


    line(l1mp.x, l1mp.y, l2mp.x, l2mp.y);
    line(l2mp.x, l2mp.y, l3mp.x, l3mp.y);
    line(l3mp.x, l3mp.y, l4mp.x, l4mp.y);
    line(l4mp.x, l4mp.y, l1mp.x, l1mp.y);

    l5mp = PVector.lerp(point5, point6, stage);
    l6mp = PVector.lerp(point6, point7, stage);
    l7mp = PVector.lerp(point7, point8, stage);
    l8mp = PVector.lerp(point8, point5, stage);

    line(l5mp.x, l5mp.y, l6mp.x, l6mp.y);
    line(l6mp.x, l6mp.y, l7mp.x, l7mp.y);
    line(l7mp.x, l7mp.y, l8mp.x, l8mp.y);
    line(l8mp.x, l8mp.y, l5mp.x, l5mp.y);
*/

l1mp = PVector.lerp(point1, point2, 0);
l3mp = PVector.lerp(point3, point4, stage);
line(l1mp.x, l1mp.y, l3mp.x, l3mp.y);

l4mp = PVector.lerp(point3, point3, 0);
l1mp = PVector.lerp(point1, point2, stage);
line(l4mp.x, l4mp.y, l1mp.x, l1mp.y);


    stage += (1/pointNo);
    
    colourValue++;
    
    if (colourValue == 2){
    colourValue = 0;
    }
    
  }

save("LLL.png");
}

以上是关于text LLL Square line to corner.pde的主要内容,如果未能解决你的问题,请参考以下文章

类继承,定义了一个点类point,然后线条类line继承了point类,正方形类square继承line类

Zapier Formatter > Utilities > line item to text 中的额外逗号

3 Ways to Write Text to a File in Python

473. Matchsticks to Square

473. Matchsticks to Square

LeetCode 473 - Matchsticks to Square - Medium (Python)