- PImage tree = loadImage(“tree.jpg”):讀取一張JPG圖片存於PImage
- get():取得整個畫面的pixel,存於PImage
- get(x,y):取得(x,y)座標的pixel,存於color
- get(x,y,width,height):取得以(x,y)為起點,(width,height)大小的區域pixel,存於PImage
- image(PImage,x,y,width,height):繪製PImage以(x,y)為起點,(width,height)為大小
- set(x,y,color):設定(x,y)座標處的pixel value
- set(x,y,image):設定以(x,y)座標為起點,貼上image
- PImage.set(x,y,color):設定圖片x,y處的pixel value
- constrain(mouseX,0,50):將變數滑鼠座標X值限制在0到50之間
Exercises
- Load a image use get() to create a collage by overlaying difference sections of the same image.
- Load a image and use mouseX and mouseY to read value of the pixel beneath the cursor.Use this value to change some aspect of the image.
- Draw a shape in the display window. Copy a section of the window to another by using get() and set() within for structure.
Reference
- Casey Reas & Ben Fry : Page348
沒有留言:
張貼留言