首页 > 文档 > set()设置像素颜色
2017
08-09

set()设置像素颜色

Name

set()设置像素颜色

   

Examples

set()设置像素颜色 - 第1张  | Processing编程艺术set()设置像素颜色 - 第2张  | Processing编程艺术set()设置像素颜色 - 第3张  | Processing编程艺术

color black = color(0);

set(30, 20, black);

set(85, 20, black);

set(85, 75, black);

set(30, 75, black);

set()设置像素颜色 - 第4张  | Processing编程艺术set()设置像素颜色 - 第5张  | Processing编程艺术set()设置像素颜色 - 第6张  | Processing编程艺术

for (int i = 30; i < width-15; i++) {

for (int j = 20; j < height-25; j++) {

color c = color(204-j, 153-i, 0);

set(i, j, c);

}

}

set()设置像素颜色 - 第7张  | Processing编程艺术set()设置像素颜色 - 第8张  | Processing编程艺术set()设置像素颜色 - 第9张  | Processing编程艺术

size(100, 100);

PImage myImage = loadImage(“apples.jpg”);

set(0, 0, myImage);

line(0, 0, width, height);

line(0, height, width, 0);

Description

Changes the color of any pixel, or writes an image directly to the display window.

The x and y parameters specify the pixel to change and the c parameter specifies the color value. The c parameter is interpreted according to the current color mode. (The default color mode is RGB values from 0 to 255.) When setting an image, the x and y parameters define the coordinates for the upper-left corner of the image, regardless of the current imageMode()

Setting the color of a single pixel with set(x, y) is easy, but not as fast as putting the data directly into pixels[]. The equivalent statement to set(x, y, #000000) using pixels[] is pixels[y*width+x] = #000000. See the reference for pixels[] for more information.

更改任何像素的颜色, 或直接将图像写入显示窗口。

 

x y 参数指定要更改的像素, c 参数指定颜色值。根据当前颜色模式解释 c 参数。(默认颜色模式是从0255 RGB 值。设置图像时, x y 参数定义图像左上角的坐标, 而不考虑当前的 imageMode ()

 

设置单个像素的颜色 (xy) 很简单, 但不能像将数据直接放入像素 [] 那样快。使用像素 [] 设置的等价语句 (xy# 000000) 是像素 [y * + x] = # 000000。有关详细信息, 请参阅像素 [] 的参考。

Syntax

set(x, y, c)

set(x, y, img)

Parameters

x

int: x-coordinate of the pixel

 像素的 x 坐标

y

int: y-coordinate of the pixel

 像素的 y 坐标

c

int: any value of the color datatype

颜色数据类型的任何值

img

PImage: image to copy into the original image

图像复制到原始图像

Returns

void

Related

get()
pixels[]
copy()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。