幾天以來我一直遇到一個問題。我開始自我介紹,我是Quentin,法國學生,我也在onepoint工作。我的問題是我正在做一個個人項目,稍后學習處理和WebGL,我想在我的三角形中使用淡入淡出,具有兩種特定顏色的動態(tài)淡入淡出(第一個是起始顏色,第二個是結(jié)束顏色)。我使用 lerpColor 但我的代碼不起作用,我希望獲得一些幫助!:)(抱歉,當我說話時我的英語更好)這是我的整個代碼:let x = 50;let x1 = 100;let y = 150;let speed = 5;let startColor;let endColor;let amt;function setup() { createCanvas(windowWidth, 800); }function draw() { colorMode(RGB); background(252, 238, 10); shape(); // Appel de la function shape bounce();// appel de la fonction bounce}function bounce() { x = x + speed; x1 = x1 + speed; y = y + speed; if (y > windowWidth || x < 0) { speed = speed * -1; }}function shape() { colorMode(HSB, 360, 100 , 100); triangle(x, 200, x1, 100, y, 200); noStroke(); let startColor = color(288 , 71 , 60 ); let endColor = color( 352 , 90 , 16); amt += 0.01; let colorTransition = (lerpColor(startColor,endColor,amt)); if (amt >= 1){ amt = 0.0; }}
關(guān)于填充 p5.js 中的褪色問題
HUX布斯
2023-08-24 21:10:00