set()

Image / Pixels

Description

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

Syntax

void set(int x, int y, color c)

Parameters

NameTypeDescription
xintx-coordinate
yinty-coordinate
ccolorcolor value

Returns

void

Related

Under the Hood

From Processing.h:

PVector& set(float _x, float _y, float _z=0) { x=_x; y=_y; z=_z; return *this; } PVector& set(const PVector& v) { x=v.x; y=v.y; z=v.z; return *this; } PColor& set(float _r, float _g, float _b, float _a=255) { r=_r; g=_g; b=_b; a=_a; return *this; } PColor& set(float gray, float _a=255) { r=g=b=gray; a=_a; return *this; } void set(int x, int y, unsigned int c) { if (x<0||x>=width||y<0||y>=height) return; pixels[y*width+x] = c; dirty = true; } set(dx+ix, dy+iy, src.get(srcX, srcY)); void set(int i, int v) { data[i]=v; } void set(int i, float v) { data[i]=v; } void set(int i, const std::string& v){ data[i]=v; } void set(int i, const T& v) { data[i]=v; } void set(int i, T* v) { data[i]=v; } void set(const std::string& k, int v) { data[k]=v; } void set(const std::string& k, float v) { data[k]=v; } void set(const std::string& k, const std::string& v) { data[k]=v; } void set(const std::string& n, float v) { glUniform1f(glGetUniformLocation(program,n.c_str()),v); } void set(const std::string& n, int v) { glUniform1i(glGetUniformLocation(program,n.c_str()),v); } void set(const std::string& n, float x, float y) { glUniform2f(glGetUniformLocation(program,n.c_str()),x,y); } void set(const std::string& n, float x, float y, float z) { glUniform3f(glGetUniformLocation(program,n.c_str()),x,y,z); } void set(const std::string& n, float x, float y, float z, float w){ glUniform4f(glGetUniformLocation(program,n.c_str()),x,y,z,w); } void set(int x, int y, color c);

Under the Hood

From Processing.cpp:

void PApplet::set(int x, int y, color c) { unsigned int v = c.value; unsigned char p[] = { (unsigned char)((v >> 16) & 0xFF), // R (unsigned char)((v >> 8) & 0xFF), // G (unsigned char)( v & 0xFF), // B (unsigned char)((v >> 24) & 0xFF) // A }; glWindowPos2i(x, winHeight - 1 - y); glDrawPixels(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, p); }