绘制后如何更改形状的轮廓颜色(描边)?

How do I change the outline color (stroke) of my shape after drawing it?

我是第一次在 Processing 中编码(之前熟悉 Java),我正在尝试制作一个三角形网格,当我单击其中一个时,它会将填充和描边更改为不同的颜色。填充正在改变,但描边仍然是默认颜色。这是我的代码:

void setup() {
  size(800, 600); // size of canvas
  triangles = new ArrayList<TriangleClass>();  // Create an empty ArrayList

  int L = 50; // length of triangle side
  double halfStep = L * Math.sqrt(3);

  // all the code about making the grid
} 

void draw() {
  background(0);
  TriangleClass myCurrentTriangle;

  for (int i = 0; i < triangles.size(); i++) {
    // get object from ArrayList
    myCurrentTriangle = triangles.get(i);
    myCurrentTriangle.display();
  } 
} 

void mouseClicked () {
  TriangleClass myCurrentTriangle ;
  for (int i=0; i < triangles.size(); i++) {
    // get object from ArrayList
    myCurrentTriangle = triangles.get(i);
    myCurrentTriangle.mouseOver();
  }
}

class TriangleClass {
  double x1, y1, x2, y2, x3, y3;    // points
  color fill; // fill color
  color stroke; // stroke color
  float mouseSensorX, mouseSensorY;// check point for dist to mouse

  // constructor
  TriangleClass(
    //  ...
    stroke = color(174, 208, 234);
    fill = color(249, 249, 249);
    mouseSensorX = (float) (x1+x2+x3 )/ 3;
    mouseSensorY = (float) (y1+y2+y3 )/ 3;
  }  

  void mouseOver() {
    if (dist(mouseX, mouseY, mouseSensorX, mouseSensorY) < 17) {
      if (fill == color(249, 249, 249)) {
        stroke = color(251, 84, 84);
        fill = color(251,84,84);
      // ... repeated for other colors
    }
  } 

  void display() {
    // show triangle
    stroke(stroke);
    fill(fill);
    triangle((float) x1, (float) y1, (float) x2, (float) y2, (float) x3, (float) y3);
  } 
} 
// =====================================================================

我认为问题出在笔划粗细上。您需要做的就是在设置函数的末尾有这行代码:

strokeWeight(3);

数字越大,轮廓越大。