DrawingContext dc; // assuming dc is already initialized Surface image("image.png"); // create a surface object from an image file dc.draw_surface(image, 0, 0, image.get_width(), image.get_height()); // draw the image at (0, 0) with its original dimensions
DrawingContext dc; // assuming dc is already initialized Surface image("image.png"); // create a surface object from an image file dc.save(); // save the current state of the drawing context dc.translate(100, 100); // move the canvas origin to (100, 100) dc.rotate(45); // rotate the canvas by 45 degrees counter-clockwise dc.scale(0.5, 0.5); // scale the canvas dimensions by 0.5 in both x and y directions dc.draw_surface(image, 0, 0, image.get_width(), image.get_height()); // draw the image at (0, 0) with its original dimensions dc.restore(); // restore the saved state of the drawing contextThis example code would draw an image on a canvas using the DrawingContext draw_surface function, but with some additional transformations applied to the canvas. The canvas is first moved to (100, 100), rotated by 45 degrees counter-clockwise, and scaled by 0.5 in both x and y directions. The image is then drawn at its original size at the modified canvas location. Package/Library: SFML (Simple and Fast Multimedia Library)