hi,
I am simply trying to place and image on the screen and beside it a shape. But when displaying the shape, the background of the shape is in the right place but the shape itself is not and is actually overlapping the image because it has not moved over by the x amount. Is this a Processing bug or am I doing something wrong. I have done a lot of programming but am very new to Processing. Thanks for any information. Had trouble creating an id on this forum and got no email support from Zoho. It may be that creating an id needs Internet Explorer.
PImage img, pimg; // master image which will be imitated by program created image. PGraphics pg; // program created graphics. When rendered will be put into pimg.
void setup() { // size(200, 200); // The file "x.png" must be in the data folder // of the current sketch to load successfully img = loadImage("single_triangle.png"); // Load the image into the program size(img.width*2, img.height); pg = createGraphics(img.width, img.height, JAVA2D); // P2D chosen for speed. (JAVA2D for accuracy) noLoop(); // Makes draw() only run once }
void draw() { // Displays the image at its actual size at point (0,0) image(img, 0, 0); // create then display new graphics createImage(pg); pimg = pg.get(0, 0, img.width, img.height); // Displays the created image at its actual size beside original image(pimg, pimg.width, 0, pimg.width, pimg.height); } /** * Draws into an off-screen buffer. */ void createImage(PGraphics buffer) { color c1 = color(204, 153, 0); color red = color(255, 0, 0); buffer.beginDraw(); buffer.background(red); buffer.smooth(); buffer.noStroke(); fill(c1); // triangle(x1, y1, x2, y2, x3, y3); triangle(0, 15, 15, 0, 40, 40); buffer.endDraw(); }