Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

PDF export: shapes misaligned

$
0
0
Something is up with my attempt at rendering this sketch as a PDF. In the PDF render the ellipses are misaligned.  The drawing outputs perfectly to the screen.  Any help would be appreciated (trying to output for printing).

On screen render:


PDF render:



  1. import processing.pdf.*;

  2. boolean record = true;
  3. PGraphics pdf;

  4. int d = 300;
  5. int r = 300;
  6. float z = random(1, 5);
  7. float rand;
  8. int stepX = 15;
  9. int stepY = 15;



  10. color[] palette = {
  11.   #556270, #4ECDC4, #C7F464, #FF6B6B, #C44D58
  12. };

  13. void setup(){
  14. //background (palette[(int)random(1, 5)]);
  15. size(960, 645);
  16. ellipseMode(CORNER);
  17. smooth();
  18. pdf = (PGraphics) createGraphics((width), (height), PDF, "frame.pdf");
  19. noLoop();
  20. }

  21. void draw(){
  22. if(record){
  23.  beginRecord(pdf);
  24.       println("Recording started.");
  25.       record = true;
  26.   }

  27. float n = noise(d)*d;
  28. noiseSeed(0);
  29. noStroke();
  30.  
  31. background (#556270);

  32. for (int y = stepY; y < height +d; y += d + stepY){
  33. for (int x = stepX; x < width; x += d + stepX){
  34. drawCircle(x, y, d);
  35. }

  36. }

  37. if(record){
  38.  endRecord();
  39.       println("Recording stopped.");
  40.       record = false;
  41. }
  42. }



  43. void drawCircle(float x, float y, float d){
  44. //noFill();
  45. noStroke();
  46. fill(palette[(int)random(0, 5)]);
  47. ellipse(x, y, d, d);

  48. if(d > 2){
  49. drawCircle(x, y, d/1.5);
  50. }
  51. }




Viewing all articles
Browse latest Browse all 1768

Trending Articles