forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPShape_scale_.html
More file actions
91 lines (81 loc) · 2.38 KB
/
Copy pathPShape_scale_.html
File metadata and controls
91 lines (81 loc) · 2.38 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
81
82
83
84
85
86
87
88
89
90
91
---
layout: default
---
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
<tr>
<th scope="row">Class</th>
<td>PShape</td>
</tr>
<tr class="name-row">
<th scope="row">Name</th>
<td><h3>scale()</h3></td>
</tr>
<tr class="">
<th scope="row">Examples</th>
<td><div class="example"><pre>
PShape s;
void setup() {
s = loadShape("bot.svg");
smooth();
}
void draw() {
background(204);
shape(s);
}
void mousePressed() {
// Shrink the shape 90% each time the mouse is pressed
s.scale(0.9);
}</pre></div></td>
</tr>
<tr class="">
<th scope="row">Description</th>
<td><p>Increases or decreases the size of a shape by expanding and contracting vertices.
Shapes always scale from the relative origin of their bounding box. Scale values are specified as decimal percentages.
For example, the method call <b>scale(2.0)</b> increases the dimension of a shape by 200%. Subsequent calls to the method multiply the effect.
For example, calling <b>scale(2.0)</b> and then <b>scale(1.5)</b> is the same as <b>scale(3.0)</b>. This transformation is applied directly to the shape,
it's not refreshed each time <b>draw()</b> is run.
</p>
<p>Using this fuction with the <b>z</b> parameter requires passing P3D or OPENGL into the size() parameter.</p></td>
</tr>
<tr class="">
<th scope="row">Syntax</th>
<td><pre><kbd>sh</kbd>.scale(<kbd>size</kbd>)</pre><br />
<pre><kbd>sh</kbd>.scale(<kbd>x</kbd>,<kbd>y</kbd>)</pre><br />
<pre><kbd>sh</kbd>.scale(<kbd>x</kbd>,<kbd>y</kbd>,<kbd>z</kbd>)</pre></td>
</tr>
<tr class="">
<th scope="row">Parameters</th>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row">sh</th>
<td>PShape: any variable of type PShape</td>
</tr>
<tr class="">
<th scope="row">size</th>
<td>float: percentage to scale the object</td>
</tr>
<tr class="">
<th scope="row">x</th>
<td>float: percentage to scale the object in the x-axis</td>
</tr>
<tr class="">
<th scope="row">y</th>
<td>float: percentage to scale the object in the y-axis</td>
</tr>
<tr class="">
<th scope="row">z</th>
<td>float: percentage to scale the object in the z-axis</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>
</table>