render in java <> javascript
in
Processing with Other Languages
•
5 months ago
Hi!
When rendering this variation of the rgbcube example, using strokes in place of fills, I get what I want in java mode but the colors get changed in javascript mode. Apparently, colors are handled differently in stroke and fill methods, and it looks like a little bug is hiding there...
When rendering this variation of the rgbcube example, using strokes in place of fills, I get what I want in java mode but the colors get changed in javascript mode. Apparently, colors are handled differently in stroke and fill methods, and it looks like a little bug is hiding there...
Copy code
- float xmag, ymag = 0;
float newXmag, newYmag = 0;
void setup() {
size(640, 360, P3D);
colorMode(RGB, 1,1,1,1);
}
void draw() {
background(0.6);
pushMatrix();
translate(width/2, height/2, -30);
newXmag = mouseX/float(width) * TWO_PI;
newYmag = mouseY/float(height) * TWO_PI;
float diff = xmag-newXmag;
if (abs(diff) > 0.01) {xmag -= diff/4.0; }
diff = ymag-newYmag;
if (abs(diff) > 0.01) {ymag -= diff/4.0; }
rotateX(-ymag);
rotateY(-xmag);
strokeWeight(5);
noFill();
scale(100);
beginShape(QUADS);
stroke(0,1,1,1); vertex(-1,1,1);
stroke(1,1,1,1); vertex(1,1,1);
stroke(1,0,1,1); vertex(1,-1,1);
stroke(0,0,1,1); vertex(-1,-1,1);
stroke(1,1,1,1); vertex(1,1,1);
stroke(1,1,0,1); vertex(1,1,-1);
stroke(1,0,0,1); vertex(1,-1,-1);
stroke(1,0,1,1); vertex(1,-1,1);
stroke(1,1,0,1); vertex(1,1,-1);
stroke(0,1,0,1); vertex(-1,1,-1);
stroke(0,0,0,1); vertex(-1,-1,-1);
stroke(1,0,0,1); vertex(1,-1,-1);
stroke(0,1,0,1); vertex(-1,1,-1);
stroke(0,1,1,1); vertex(-1,1,1);
stroke(0,0,1,1); vertex(-1,-1,1);
stroke(0,0,0,1); vertex(-1,-1,-1);
stroke(0,1,0,1); vertex(-1,1,-1);
stroke(1,1,0,1); vertex(1,1,-1);
stroke(1,1,1,1); vertex(1,1,1);
stroke(0,1,1,1); vertex(-1,1,1);
stroke(0,0,0,1); vertex(-1,-1,-1);
stroke(1,0,0,1); vertex(1,-1,-1);
stroke(1,0,1,1); vertex(1,-1,1);
stroke(0,0,1,1); vertex(-1,-1,1);
endShape();
popMatrix();
}
1