Processing, 類PImage中的set()用法介紹。
用法
pimg.set(x, y, c)pimg.set(x, y, img)
參數
pimg(PImage)任何 PImage 類型的對象x(int)像素的 x 坐標y(int)像素的 y 坐標c(int)顏色數據類型的任何值img(PImage)要複製到原始圖像中的圖像
返回
void
說明
更改任何像素的顏色或將圖像直接寫入顯示窗口。
x 和y 參數指定要更改的像素,color 參數指定顏色值。顏色參數受當前顏色模式的影響(默認為 0 到 255 的 RGB 值)。設置圖像時,x 和 y 參數定義圖像左上角的坐標,與當前的 imageMode() 無關。
使用 set(x, y) 設置單個像素的顏色很容易,但不如將數據直接放入 pixels[] 快。使用 pixels[] 的 set(x, y, #000000) 的等效語句是 pixels[y*width+x] = #000000 。有關詳細信息,請參閱pixels[] 的參考。
例子
PImage tower;
void setup() {
size(400, 400);
tower = loadImage("tower.jpg");
color black = color(0);
tower.set(240, 160, black);
tower.set(340, 160, black);
tower.set(340, 600, black);
tower.set(240, 600, black);
}
void draw() {
image(tower, 0, 0);
}
相關用法
- Processing PImage.save()用法及代碼示例
- Processing PImage.pixels[]用法及代碼示例
- Processing PImage.resize()用法及代碼示例
- Processing PImage.width用法及代碼示例
- Processing PImage.get()用法及代碼示例
- Processing PImage.loadPixels()用法及代碼示例
- Processing PImage.filter()用法及代碼示例
- Processing PImage.updatePixels()用法及代碼示例
- Processing PImage.mask()用法及代碼示例
- Processing PImage.blend()用法及代碼示例
- Processing PImage.copy()用法及代碼示例
- Processing PImage.height用法及代碼示例
- Processing PImage用法及代碼示例
- Processing PI用法及代碼示例
- Processing Pulse用法及代碼示例
- Processing PShader用法及代碼示例
- Processing PVector.set()用法及代碼示例
- Processing PShape.enableStyle()用法及代碼示例
- Processing PVector.mag()用法及代碼示例
- Processing PWM.set()用法及代碼示例
- Processing PVector.normalize()用法及代碼示例
- Processing PVector.limit()用法及代碼示例
- Processing PShape用法及代碼示例
- Processing PFont.list()用法及代碼示例
- Processing PVector.div()用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 PImage.set()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
