Loading...
Logo
Processing Forum
Hey, anyone knows why the lines (vertex) dont connect (seems so), when i use PGraphics?

please look at the code, guess this makes it clear what i mean...

Copy code
  1. PGraphics m1 = createGraphics(40,40,P2D);
  2. PGraphics m2 = createGraphics(40,40,P2D);
  3. background(255);
  4. smooth();
  5. m1.beginDraw();
  6. m1.noStroke();
  7. m1.fill(0,255,255);
  8. m1.rect(0,0,40,40);
  9. m1.endDraw();
  10. m2.beginDraw();
  11. m2.stroke(255,0,255);
  12. m2.strokeWeight(6);
  13. m2.strokeCap(ROUND);
  14. m2.beginShape();
  15. m2.vertex(5,15);
  16. m2.vertex(15,5);
  17. m2.vertex(25,15);
  18. m2.vertex(35,5);
  19. m2.endShape();
  20. m2.endDraw();
  21. image(m1,10,10);
  22. for(int i = 0; i < 40; i+=15)
  23. blend(m2,  0,0,40,40,   20,10+i, 40,40, MULTIPLY);
  24. noFill();
  25. strokeWeight(6);
  26. strokeCap(CORNER);
  27. translate(20,60);
  28. beginShape();
  29. vertex(5,15);
  30. vertex(15,5);
  31. vertex(25,15);
  32. vertex(35,5);
  33. endShape();

thanks!

Replies(2)

Try:
Copy code
  1. PGraphics m1 = createGraphics(40, 40, JAVA2D);
  2. PGraphics m2 = createGraphics(40, 40, JAVA2D);
No idea why it doesn't work with P2D
For some reason you have to use m1.loadPixels() at the beginning  and  m1.updatePixels() at the end with P2D.