forked from jdf/processing-py-site
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPImage_get.xml
More file actions
75 lines (61 loc) · 2.39 KB
/
PImage_get.xml
File metadata and controls
75 lines (61 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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>get()</name>
<category>PImage</category>
<subcategory>Method</subcategory>
<type></type>
<example>
<image />
<code><![CDATA[
mountains = loadImage("rockies.jpg")
background(mountains)
noStroke()
c = mountains.get(60, 90)
fill(c)
rect(25, 25, 50, 50)
]]></code>
</example>
<example>
<image />
<code><![CDATA[
mountains = loadImage("rockies.jpg")
background(mountains)
newMountains = mountains.get(50, 0, 50, 100)
image(newMountains, 0, 0)
]]></code>
</example>
<description><![CDATA[
Reads the color of any pixel or grabs a section of an image. If no parameters are specified, the entire image is returned. Use the <b>x</b> and <b>y</b> parameters to get the value of one pixel. Get a section of the display window by specifying an additional <b>width</b> and <b>height</b> parameter. When getting an image, the <b>x</b> and <b>y</b> parameters define the coordinates for the upper-left corner of the image, regardless of the current <b>imageMode()</b>.<br />
<br />
If the pixel requested is outside of the image window, black is returned. The numbers returned are scaled according to the current color ranges, but only RGB values are returned by this function. For example, even though you may have drawn a shape with <b>colorMode(HSB)</b>, the numbers returned will be in RGB format.<br />
<br />
Getting the color of a single pixel with <b>get(x, y)</b> is easy, but not as fast as grabbing the data directly from <b>pixels</b>. The equivalent statement to <b>get(x, y)</b> using <b>pixels</b> is <b>pixels[y*width+x]</b>. See the reference for <b>pixels</b> for more information.
]]></description>
<syntax>
<c>pimg</c>.get(<c>x</c>, <c>y</c>)
<c>pimg</c>.get(<c>x</c>, <c>y</c>, <c>w</c>, <c>h</c>)
<c>pimg</c>.get()
</syntax>
<parameter>
<label>pimg</label>
<description><![CDATA[PImage: any object of type PImage]]></description>
</parameter>
<parameter>
<label>x</label>
<description><![CDATA[int: x-coordinate of the pixel]]></description>
</parameter>
<parameter>
<label>y</label>
<description><![CDATA[int: y-coordinate of the pixel]]></description>
</parameter>
<parameter>
<label>w</label>
<description><![CDATA[int: width of pixel rectangle to get]]></description>
</parameter>
<parameter>
<label>h</label>
<description><![CDATA[int: height of pixel rectangle to get]]></description>
</parameter>
<related>set</related>
<related>pixels</related>
</root>