Style.html 14 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Class: Style</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Class: Style</h1>
  17. <section>
  18. <header>
  19. <h2><span class="attribs"><span class="type-signature"></span></span>Style<span class="signature">()</span><span class="type-signature"></span></h2>
  20. </header>
  21. <article>
  22. <div class="container-overview">
  23. <h4 class="name" id="Style"><span class="type-signature"></span>new Style<span class="signature">()</span><span class="type-signature"></span></h4>
  24. <div class="description">
  25. Style represents in a generic way a style applied to canvas drawing.
  26. Some styles (e.g. gradients, patterns) required a context to be generated this provides a generic way to share styles between objects.
  27. </div>
  28. <dl class="details">
  29. <dt class="tag-source">Source:</dt>
  30. <dd class="tag-source"><ul class="dummy"><li>
  31. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line8">line 8</a>
  32. </li></ul></dd>
  33. </dl>
  34. </div>
  35. <h3 class="subsection-title">Members</h3>
  36. <h4 class="name" id=".types"><span class="type-signature">(static) </span>types<span class="type-signature"> :Map.&lt;string, function()></span></h4>
  37. <div class="description">
  38. List of available style types known by the application. Stores the object constructor by object type.
  39. </div>
  40. <h5>Type:</h5>
  41. <ul>
  42. <li>
  43. <span class="param-type">Map.&lt;string, function()></span>
  44. </li>
  45. </ul>
  46. <dl class="details">
  47. <dt class="tag-source">Source:</dt>
  48. <dd class="tag-source"><ul class="dummy"><li>
  49. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line57">line 57</a>
  50. </li></ul></dd>
  51. </dl>
  52. <h4 class="name" id="cache"><span class="type-signature"></span>cache<span class="type-signature"> :string|CanvasGradient|CanvasPattern</span></h4>
  53. <div class="description">
  54. Cached style object pre-generated from previous calls. To avoid regenerating the same style object every cycle.
  55. Inherited classes should write their own get method that returns the style object and stores it in this property.
  56. </div>
  57. <h5>Type:</h5>
  58. <ul>
  59. <li>
  60. <span class="param-type">string</span>
  61. |
  62. <span class="param-type">CanvasGradient</span>
  63. |
  64. <span class="param-type">CanvasPattern</span>
  65. </li>
  66. </ul>
  67. <dl class="details">
  68. <dt class="tag-source">Source:</dt>
  69. <dd class="tag-source"><ul class="dummy"><li>
  70. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line17">line 17</a>
  71. </li></ul></dd>
  72. </dl>
  73. <h4 class="name" id="needsUpdate"><span class="type-signature"></span>needsUpdate<span class="type-signature"> :boolean</span></h4>
  74. <div class="description">
  75. Indicates if the style object needs to be updated, should be used after applying changed to the style in order to generate a new object.
  76. Inherited classes should implement this functionality.
  77. </div>
  78. <h5>Type:</h5>
  79. <ul>
  80. <li>
  81. <span class="param-type">boolean</span>
  82. </li>
  83. </ul>
  84. <dl class="details">
  85. <dt class="tag-source">Source:</dt>
  86. <dd class="tag-source"><ul class="dummy"><li>
  87. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line26">line 26</a>
  88. </li></ul></dd>
  89. </dl>
  90. <h3 class="subsection-title">Methods</h3>
  91. <h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<span class="signature">(data)</span><span class="type-signature"> &rarr; {<a href="Style.html">Style</a>}</span></h4>
  92. <div class="description">
  93. Parse style from JSON serialized data, created a style of the correct data type automatically and parses its data.
  94. </div>
  95. <h5>Parameters:</h5>
  96. <table class="params">
  97. <thead>
  98. <tr>
  99. <th>Name</th>
  100. <th>Type</th>
  101. <th class="last">Description</th>
  102. </tr>
  103. </thead>
  104. <tbody>
  105. <tr>
  106. <td class="name"><code>data</code></td>
  107. <td class="type">
  108. </td>
  109. <td class="description last">JSON serialized data.</td>
  110. </tr>
  111. </tbody>
  112. </table>
  113. <dl class="details">
  114. <dt class="tag-source">Source:</dt>
  115. <dd class="tag-source"><ul class="dummy"><li>
  116. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line76">line 76</a>
  117. </li></ul></dd>
  118. </dl>
  119. <h5>Returns:</h5>
  120. <div class="param-desc">
  121. Parsed style from the provided data.
  122. </div>
  123. <dl>
  124. <dt>
  125. Type
  126. </dt>
  127. <dd>
  128. <span class="param-type"><a href="Style.html">Style</a></span>
  129. </dd>
  130. </dl>
  131. <h4 class="name" id=".register"><span class="type-signature">(static) </span>register<span class="signature">(constructor, type)</span><span class="type-signature"></span></h4>
  132. <div class="description">
  133. Register a style type to be serializable. Associates the type string to the object constructor.
  134. </div>
  135. <h5>Parameters:</h5>
  136. <table class="params">
  137. <thead>
  138. <tr>
  139. <th>Name</th>
  140. <th>Type</th>
  141. <th class="last">Description</th>
  142. </tr>
  143. </thead>
  144. <tbody>
  145. <tr>
  146. <td class="name"><code>constructor</code></td>
  147. <td class="type">
  148. <span class="param-type">function</span>
  149. </td>
  150. <td class="description last">Style constructor.</td>
  151. </tr>
  152. <tr>
  153. <td class="name"><code>type</code></td>
  154. <td class="type">
  155. <span class="param-type">string</span>
  156. </td>
  157. <td class="description last">Style type name.</td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. <dl class="details">
  162. <dt class="tag-source">Source:</dt>
  163. <dd class="tag-source"><ul class="dummy"><li>
  164. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line65">line 65</a>
  165. </li></ul></dd>
  166. </dl>
  167. <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(context)</span><span class="type-signature"> &rarr; {string|CanvasGradient|CanvasPattern}</span></h4>
  168. <div class="description">
  169. Get generated style object from style data and the drawing context.
  170. </div>
  171. <h5>Parameters:</h5>
  172. <table class="params">
  173. <thead>
  174. <tr>
  175. <th>Name</th>
  176. <th>Type</th>
  177. <th class="last">Description</th>
  178. </tr>
  179. </thead>
  180. <tbody>
  181. <tr>
  182. <td class="name"><code>context</code></td>
  183. <td class="type">
  184. <span class="param-type">CanvasRenderingContext2D</span>
  185. </td>
  186. <td class="description last">Context being used to draw the object.</td>
  187. </tr>
  188. </tbody>
  189. </table>
  190. <dl class="details">
  191. <dt class="tag-source">Source:</dt>
  192. <dd class="tag-source"><ul class="dummy"><li>
  193. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line35">line 35</a>
  194. </li></ul></dd>
  195. </dl>
  196. <h5>Returns:</h5>
  197. <div class="param-desc">
  198. Return the canvas style object generated.
  199. </div>
  200. <dl>
  201. <dt>
  202. Type
  203. </dt>
  204. <dd>
  205. <span class="param-type">string</span>
  206. |
  207. <span class="param-type">CanvasGradient</span>
  208. |
  209. <span class="param-type">CanvasPattern</span>
  210. </dd>
  211. </dl>
  212. <h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">(data)</span><span class="type-signature"></span></h4>
  213. <div class="description">
  214. Parse the style attributes from JSON object data created with the serialize() method.
  215. </div>
  216. <h5>Parameters:</h5>
  217. <table class="params">
  218. <thead>
  219. <tr>
  220. <th>Name</th>
  221. <th>Type</th>
  222. <th class="last">Description</th>
  223. </tr>
  224. </thead>
  225. <tbody>
  226. <tr>
  227. <td class="name"><code>data</code></td>
  228. <td class="type">
  229. <span class="param-type">Object</span>
  230. </td>
  231. <td class="description last">Serialized style data.</td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. <dl class="details">
  236. <dt class="tag-source">Source:</dt>
  237. <dd class="tag-source"><ul class="dummy"><li>
  238. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line49">line 49</a>
  239. </li></ul></dd>
  240. </dl>
  241. <h4 class="name" id="serialize"><span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
  242. <div class="description">
  243. Serialize the style to JSON object, called by the objects using these styles.
  244. </div>
  245. <dl class="details">
  246. <dt class="tag-source">Source:</dt>
  247. <dd class="tag-source"><ul class="dummy"><li>
  248. <a href="objects_style_Style.js.html">objects/style/Style.js</a>, <a href="objects_style_Style.js.html#line42">line 42</a>
  249. </li></ul></dd>
  250. </dl>
  251. <h5>Returns:</h5>
  252. <div class="param-desc">
  253. Serialized style data.
  254. </div>
  255. <dl>
  256. <dt>
  257. Type
  258. </dt>
  259. <dd>
  260. <span class="param-type">Object</span>
  261. </dd>
  262. </dl>
  263. </article>
  264. </section>
  265. </div>
  266. <nav>
  267. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnimationTimer.html">AnimationTimer</a></li><li><a href="BarGraph.html">BarGraph</a></li><li><a href="BezierCurve.html">BezierCurve</a></li><li><a href="Box.html">Box</a></li><li><a href="Box2.html">Box2</a></li><li><a href="BoxMask.html">BoxMask</a></li><li><a href="Circle.html">Circle</a></li><li><a href="ColorStyle.html">ColorStyle</a></li><li><a href="DOM.html">DOM</a></li><li><a href="EventManager.html">EventManager</a></li><li><a href="FileUtils.html">FileUtils</a></li><li><a href="Gauge.html">Gauge</a></li><li><a href="GradientColorStop.html">GradientColorStop</a></li><li><a href="GradientStyle.html">GradientStyle</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Helpers.html">Helpers</a></li><li><a href="Image.html">Image</a></li><li><a href="Key.html">Key</a></li><li><a href="Line.html">Line</a></li><li><a href="LinearGradientStyle.html">LinearGradientStyle</a></li><li><a href="Mask.html">Mask</a></li><li><a href="Matrix.html">Matrix</a></li><li><a href="MultiLineText.html">MultiLineText</a></li><li><a href="Node.html">Node</a></li><li><a href="NodeConnector.html">NodeConnector</a></li><li><a href="NodeGraph.html">NodeGraph</a></li><li><a href="NodeSocket.html">NodeSocket</a></li><li><a href="Object2D.html">Object2D</a></li><li><a href="Path.html">Path</a></li><li><a href="Pattern.html">Pattern</a></li><li><a href="PatternStyle.html">PatternStyle</a></li><li><a href="PieChart.html">PieChart</a></li><li><a href="Pointer.html">Pointer</a></li><li><a href="QuadraticCurve.html">QuadraticCurve</a></li><li><a href="RadialGradientStyle.html">RadialGradientStyle</a></li><li><a href="Renderer.html">Renderer</a></li><li><a href="RoundedBox.html">RoundedBox</a></li><li><a href="ScatterGraph.html">ScatterGraph</a></li><li><a href="Style.html">Style</a></li><li><a href="Text.html">Text</a></li><li><a href="UUID.html">UUID</a></li><li><a href="Vector2.html">Vector2</a></li><li><a href="Viewport.html">Viewport</a></li><li><a href="ViewportControls.html">ViewportControls</a></li></ul><h3>Global</h3><ul><li><a href="global.html#writeFile">writeFile</a></li></ul>
  268. </nav>
  269. <br class="clear">
  270. <footer>
  271. Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Sat Sep 17 2022 14:24:36 GMT+0100 (Hora de verão da Europa Ocidental)
  272. </footer>
  273. <script> prettyPrint(); </script>
  274. <script src="scripts/linenumber.js"> </script>
  275. </body>
  276. </html>