Learn creative coding writing simple programs

49. Show part of a loaded image using copy()

Second episode that deals with loading images. We review how to use loadImage() and then use image() to show a full image in the screen. Then we learn about copy(), which allows us to show only one part of a loaded image, and at the same time stretch or resize that part. copy() takes 9 parameters, our record :) The first parameter is the variable that holds the loaded image. Then there are two series of 4 parameters which are similar to the ones used when drawing a rectangle: x, y, width and height. The first 4 parameters refer to the loaded image: which part of that image do you want to display? The second 4 parameters refer to the display: in which area do you want to show the image area selected by the first 4 parameters?
All parameteres can be animated. Just replace a fixed value by a variable, and change that variable over time.

Tags: copy, image, loadimage

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus