We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, i'm experimenting with gradient fills in polygons and am aware that this only works when P2D, P3D & OpenGL renders have been defined. Trouble here is the poor rendering quality. Using JAVA2D or PGraphicsRetina2D means that i lose the option of having gradient fills. How can I get high quality rendering yet still have the option of gradient fills? Check out the simple sketch below. Run it with the different renders to see the difference. Any help with this would be appreciated :)
void setup(){
//size(400, 400, P2D);
size(400, 400, "processing.core.PGraphicsRetina2D");
background(255);
PVector start = new PVector(30,30);
PVector stop = new PVector(width-30, height-30);
int edgeWidth = 5;
// Draw Directed Edges
renderTLine(start, stop, edgeWidth);
// Draw Nodes
strokeWeight(10);
stroke(255,0,0);
point(start.x, start.y);
point(stop.x, stop.y);
strokeWeight(1);
}
void draw(){}
void renderTLine(PVector startLoc, PVector endLoc, float arrowsize) {
PVector d = PVector.sub(endLoc,startLoc);
float len = d.mag();
float arr = arrowsize / 2;
noStroke();
pushMatrix();
translate(startLoc.x,startLoc.y);
rotate(d.heading2D());
beginShape(TRIANGLES);
fill(0, 0, 0, 0);
vertex(len,0);
fill(0, 0, 0, 180);
vertex(0,arr);
vertex(0,-arr);
endShape(CLOSE);
popMatrix();
}
Answers
You can define a smooth() setting for the OpenGL renderers. Depending on your graphics card how high. The console will print the maximum number for your graphics card, if 32 is too high. Tweaking your example, I found that apparantly this smooth() setting in OpenGL only works after setup(), so I've moved the drawing to the draw() loop. Note that from smooth value 8 upwards this sketch looks ok.
Adapted Code