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

Re : Creating PDF when using copy() and multiple images

$
0
0
A practical example:
  1. import processing.pdf.*;
  2.  
  3. PImage myImage;
  4. PImage myImage2;
  5.  
  6. void setup() {
  7.   size (800, 800);
  8.   smooth();
  9.   myImage = loadImage ("H:/Temp/Tree.jpg"); // I just use absolute paths because I don't save these small test sketches... So no data folder for me!
  10.   myImage2 = loadImage ("H:/Temp/Test.jpg");
  11.  
  12.   beginRecord (PDF, "H:/Temp/filename.pdf");
  13. }
  14.  
  15. void draw() {
  16.   PGraphics result = createGraphics(width, height, JAVA2D);
  17.   result.beginDraw();
  18.  
  19.   result.image (myImage2, 0, 0);
  20.   int w = int(random(width));
  21.   for (int i = 0; i < 300; i++) {
  22.     int x = int(random(50, 100));
  23.     int y = int(random(height));
  24.  
  25.     result.copy (myImage, w, y, x, x, int(random(-200, 1200)), y, x, x);
  26. //    endRecord(); // Should be after the loop, if you use this style
  27.   }
  28.   result.endDraw();
  29.   image(result, 0, 0);
  30.  
  31.   endRecord();
  32.   println("Done");
  33.   noLoop();
  34.   exit();
  35. }


Viewing all articles
Browse latest Browse all 1768

Trending Articles