forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPImage_set_.html
More file actions
80 lines (74 loc) · 2.39 KB
/
Copy pathPImage_set_.html
File metadata and controls
80 lines (74 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
layout: default
---
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
<tr>
<th scope="row">Class</th>
<td>PImage</td>
</tr>
<tr class="name-row">
<th scope="row">Name</th>
<td><h3>set()</h3></td>
</tr>
<tr class="">
<th scope="row">Examples</th>
<td><div class="example"><img src="/reference/PImage_set.jpg" alt="example pic" /><pre class="margin">// @pjs preload must be used to preload the image
/* @pjs preload="tower.jpg"; */
PImage img = loadImage("tower.jpg");
background(img);
noStroke();
color c = img.get(60, 90);
fill(c);
rect(25, 25, 50, 50);</pre></div></td>
</tr>
<tr class="">
<th scope="row">Description</th>
<td><p>Changes the color of any pixel or writes an image directly into the image. The x and y parameter specify the pixel or the upper-left corner of the image.
The color parameter specifies the color value.</p>
<p>Setting the color of a single pixel with <b>set(x, y)</b> is easy, but not as fast as putting the data directly into <b>pixels[]</b>.
The equivalent statement to "set(x, y, #000000)" using pixels[] is "pixels[y*width+x] = #000000". Processing requires calling <b>loadPixels()</b> to load the
display window data into the <b>pixels[]</b> array before getting the values and calling <b>updatePixels()</b> to update the window. </p>
<p>This function ignores <b>imageMode()</b>.</p></td>
</tr>
<tr class="">
<th scope="row">Syntax</th>
<td> <pre><kbd>img</kbd>.set(<kbd>x</kbd>,<kbd>y</kbd>,<kbd>color</kbd>)</pre><br /></td>
</tr>
<tr class="">
<th scope="row">Parameters</th>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row">img</th>
<td>PImage: any variable of type PImage</td>
</tr>
<tr class="">
<th scope="row">x</th>
<td>int: x-coordinate of the pixel</td>
</tr>
<tr class="">
<th scope="row">y</th>
<td>int: y-coordinate of the pixel</td>
</tr>
<tr class="">
<th scope="row">color</th>
<td>color: any value of the color datatype</td>
</tr>
</table>
</td>
</tr>
<tr class="">
<th scope="row">Returns</th>
<td>None</td>
</tr>
<tr class="">
<th scope="row">Usage</th>
<td>Web & Application</td>
</tr>
<tr class="">
<th scope="row">Related</th>
<td><a href="../reference/get_">get()</a><br />
<a href="../reference/pixels">pixels[]</a><br />
<a href="../reference/copy_">copy()</a></td>
</tr>
</table>