Shape shading
in
Programming Questions
•
1 year ago
Hi.
I'm trying to draw a rotating square with shaded colors (red one side with a gradient to yellow on the other side).
There are some artifacts in P2D as you can see in this snippet (I'm using Processing 1.5.1):
Any hint to remove them?
Here is an example of what I mean:
There is a number of (mostly) white points where single shaded rectangles are oriented left/north. Artifacts are always on side right/bottom and if the background is pitch dark they are more visible.
I also saw that this shading is not available in JAVA2D (it is rendered as a single color). Is this true or am I missing something?
OPENGL would work (instead of P2D) but here I found another issue I cannot solve.
I create a background OPENGL image (PGraphics) where I draw. This image is far bigger than the screen and I prefere to copy it to the smaller screen only when elaboration is complete.
Doing so I use
Any idea?
Thank you in advance for any help in solving the issue.
Alessandro
I'm trying to draw a rotating square with shaded colors (red one side with a gradient to yellow on the other side).
There are some artifacts in P2D as you can see in this snippet (I'm using Processing 1.5.1):
- void setup() {
- size(400,400,P2D);
- smooth();
- frameRate(30);
- }
- void draw() {
- background(0);
- translate(200,200);
- rotate(radians(frameCount));
- beginShape();
- fill(#ff0000, 50);
- vertex(-100,-100);
- vertex(+100,-100);
- fill(#ffff00, 50);
- vertex(+100,+100);
- vertex(-100,+100);
- endShape(CLOSE);
- }
Any hint to remove them?
Here is an example of what I mean:
There is a number of (mostly) white points where single shaded rectangles are oriented left/north. Artifacts are always on side right/bottom and if the background is pitch dark they are more visible.
I also saw that this shading is not available in JAVA2D (it is rendered as a single color). Is this true or am I missing something?
OPENGL would work (instead of P2D) but here I found another issue I cannot solve.
I create a background OPENGL image (PGraphics) where I draw. This image is far bigger than the screen and I prefere to copy it to the smaller screen only when elaboration is complete.
Doing so I use
- copy(img, 0,0,img.width,img.height, 0,0,width,height);
Exception in thread "Animation Thread" java.lang.IllegalArgumentException: Illegally formatted version identifier: "null"
Any idea?
Thank you in advance for any help in solving the issue.
Alessandro
1