[28914] | 1 | <!DOCTYPE html>
|
---|
| 2 | <html>
|
---|
| 3 | <head>
|
---|
| 4 | <meta charset="UTF-8">
|
---|
| 5 | <title>Symbol</title>
|
---|
| 6 | <base target="class-frame">
|
---|
| 7 | <link href="../assets/css/docs.css" rel="stylesheet" type="text/css">
|
---|
| 8 | <script src="../assets/js/paper.js"></script>
|
---|
| 9 | <script src="../assets/js/jquery.js"></script>
|
---|
| 10 | <script src="../assets/js/codemirror.js"></script>
|
---|
| 11 | <script src="../assets/js/docs.js"></script>
|
---|
| 12 | </head>
|
---|
| 13 | <body class="reference">
|
---|
| 14 | <div class="reference-class">
|
---|
| 15 | <h1>Symbol</h1>
|
---|
| 16 |
|
---|
| 17 | <p>Symbols allow you to place multiple instances of an item in your
|
---|
| 18 | project. This can save memory, since all instances of a symbol simply refer
|
---|
| 19 | to the original item and it can speed up moving around complex objects, since
|
---|
| 20 | internal properties such as segment lists and gradient positions don't need
|
---|
| 21 | to be updated with every transformation.</p>
|
---|
| 22 |
|
---|
| 23 | </div>
|
---|
| 24 |
|
---|
| 25 | <!-- ============================== constructors ========================= -->
|
---|
| 26 | <div class="reference-members"><h2>Constructors</h2>
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | <div id="symbol-item" class="member">
|
---|
| 30 | <div class="member-link">
|
---|
| 31 | <a name="symbol-item" href="#symbol-item"><tt><b>Symbol</b>(item[, dontCenter])</tt></a>
|
---|
| 32 | </div>
|
---|
| 33 | <div class="member-description hidden">
|
---|
| 34 | <div class="member-text">
|
---|
| 35 | <p>Creates a Symbol item.</p>
|
---|
| 36 |
|
---|
| 37 | <ul><b>Parameters:</b>
|
---|
| 38 |
|
---|
| 39 | <li>
|
---|
| 40 | <tt>item:</tt>
|
---|
| 41 | <a href="../classes/Item.html"><tt>Item</tt></a>
|
---|
| 42 | — the source item which is copied as the definition of
|
---|
| 43 | the symbol
|
---|
| 44 |
|
---|
| 45 | </li>
|
---|
| 46 |
|
---|
| 47 | <li>
|
---|
| 48 | <tt>dontCenter:</tt>
|
---|
| 49 | <tt>Boolean</tt>
|
---|
| 50 |
|
---|
| 51 | — optional, default: <tt>false</tt>
|
---|
| 52 | </li>
|
---|
| 53 |
|
---|
| 54 | </ul>
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | <p>
|
---|
| 58 | <b>Example</b> — Placing 100 instances of a symbol:
|
---|
| 59 | </p>
|
---|
| 60 |
|
---|
| 61 | <div class="paperscript split">
|
---|
| 62 |
|
---|
| 63 | <div class="buttons">
|
---|
| 64 | <div class="button run">Run</div>
|
---|
| 65 | </div>
|
---|
| 66 |
|
---|
| 67 | <script type="text/paperscript" canvas="canvas-0">
|
---|
| 68 | var path = new Path.Star(new Point(0, 0), 6, 5, 13);
|
---|
| 69 | path.style = {
|
---|
| 70 | fillColor: 'white',
|
---|
| 71 | strokeColor: 'black'
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 | // Create a symbol from the path:
|
---|
| 75 | var symbol = new Symbol(path);
|
---|
| 76 |
|
---|
| 77 | // Remove the path:
|
---|
| 78 | path.remove();
|
---|
| 79 |
|
---|
| 80 | // Place 100 instances of the symbol:
|
---|
| 81 | for (var i = 0; i < 100; i++) {
|
---|
| 82 | // Place an instance of the symbol in the project:
|
---|
| 83 | var instance = symbol.place();
|
---|
| 84 |
|
---|
| 85 | // Move the instance to a random position within the view:
|
---|
| 86 | instance.position = Point.random() * view.size;
|
---|
| 87 |
|
---|
| 88 | // Rotate the instance by a random amount between
|
---|
| 89 | // 0 and 360 degrees:
|
---|
| 90 | instance.rotate(Math.random() * 360);
|
---|
| 91 |
|
---|
| 92 | // Scale the instance between 0.25 and 1:
|
---|
| 93 | instance.scale(0.25 + Math.random() * 0.75);
|
---|
| 94 | }
|
---|
| 95 | </script>
|
---|
| 96 | <div class="canvas"><canvas width="516" height="240" id="canvas-0"></canvas></div>
|
---|
| 97 | </div>
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | </div>
|
---|
| 102 | </div>
|
---|
| 103 | </div>
|
---|
| 104 |
|
---|
| 105 | </div>
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | <div class="reference-members"><h2>Properties</h2>
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | <div id="project" class="member">
|
---|
| 115 | <div class="member-link">
|
---|
| 116 | <a name="project" href="#project"><tt><b>project</b></tt></a>
|
---|
| 117 | </div>
|
---|
| 118 | <div class="member-description hidden">
|
---|
| 119 |
|
---|
| 120 | <div class="member-text">
|
---|
| 121 | <p>The project that this symbol belongs to.</p>
|
---|
| 122 |
|
---|
| 123 | <p>Read only.</p>
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | <ul><b>Type:</b>
|
---|
| 127 | <li>
|
---|
| 128 | <a href="../classes/Project.html"><tt>Project</tt></a>
|
---|
| 129 | </li>
|
---|
| 130 | </ul>
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | </div>
|
---|
| 134 |
|
---|
| 135 | </div>
|
---|
| 136 | </div>
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | <div id="definition" class="member">
|
---|
| 140 | <div class="member-link">
|
---|
| 141 | <a name="definition" href="#definition"><tt><b>definition</b></tt></a>
|
---|
| 142 | </div>
|
---|
| 143 | <div class="member-description hidden">
|
---|
| 144 |
|
---|
| 145 | <div class="member-text">
|
---|
| 146 | <p>The symbol definition.</p>
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | <ul><b>Type:</b>
|
---|
| 150 | <li>
|
---|
| 151 | <a href="../classes/Item.html"><tt>Item</tt></a>
|
---|
| 152 | </li>
|
---|
| 153 | </ul>
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 | </div>
|
---|
| 157 |
|
---|
| 158 | </div>
|
---|
| 159 | </div>
|
---|
| 160 |
|
---|
| 161 | </div>
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | <!-- ============================== methods ================================ -->
|
---|
| 166 | <div class="reference-members"><h2>Methods</h2>
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | <div id="place" class="member">
|
---|
| 170 | <div class="member-link">
|
---|
| 171 | <a name="place" href="#place"><tt><b>place</b>([position])</tt></a>
|
---|
| 172 | </div>
|
---|
| 173 | <div class="member-description hidden">
|
---|
| 174 | <div class="member-text">
|
---|
| 175 | <p>Places in instance of the symbol in the project.</p>
|
---|
| 176 |
|
---|
| 177 | <ul><b>Parameters:</b>
|
---|
| 178 |
|
---|
| 179 | <li>
|
---|
| 180 | <tt>position:</tt>
|
---|
| 181 |
|
---|
| 182 | — The position of the placed symbol.
|
---|
| 183 | — optional
|
---|
| 184 | </li>
|
---|
| 185 |
|
---|
| 186 | </ul>
|
---|
| 187 |
|
---|
| 188 |
|
---|
| 189 | <ul><b>Returns:</b>
|
---|
| 190 |
|
---|
| 191 | <li>
|
---|
| 192 | <tt><a href="../classes/PlacedSymbol.html"><tt>PlacedSymbol</tt></a></tt>
|
---|
| 193 | </li>
|
---|
| 194 |
|
---|
| 195 | </ul>
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 | </div>
|
---|
| 200 | </div>
|
---|
| 201 | </div>
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | <div id="clone" class="member">
|
---|
| 205 | <div class="member-link">
|
---|
| 206 | <a name="clone" href="#clone"><tt><b>clone</b>()</tt></a>
|
---|
| 207 | </div>
|
---|
| 208 | <div class="member-description hidden">
|
---|
| 209 | <div class="member-text">
|
---|
| 210 | <p>Returns a copy of the symbol.</p>
|
---|
| 211 |
|
---|
| 212 |
|
---|
| 213 | <ul><b>Returns:</b>
|
---|
| 214 |
|
---|
| 215 | <li>
|
---|
| 216 | <tt><a href="../classes/Symbol.html"><tt>Symbol</tt></a></tt>
|
---|
| 217 | </li>
|
---|
| 218 |
|
---|
| 219 | </ul>
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 |
|
---|
| 223 | </div>
|
---|
| 224 | </div>
|
---|
| 225 | </div>
|
---|
| 226 |
|
---|
| 227 | </div>
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 |
|
---|
| 232 | <!-- =========================== copyright notice ========================= -->
|
---|
| 233 | <p class="footer">Copyright © 2011 <a href="http://www.lehni.org" target="_blank">Jürg Lehni</a> & <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
|
---|
| 234 | <div class="content-end"></div>
|
---|
| 235 |
|
---|
| 236 | </body> |
---|