objects_style_GradientStyle.js.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: objects/style/GradientStyle.js</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">Source: objects/style/GradientStyle.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>import {Style} from "./Style";
  20. import {GradientColorStop} from "./GradientColorStop";
  21. /**
  22. * Gradient style is used to represent any type of gradient based style.
  23. *
  24. * It handles any gradient based operations and should be used as base for other gradient styles.
  25. *
  26. * @class
  27. * @extends {Style}
  28. */
  29. function GradientStyle()
  30. {
  31. Style.call(this);
  32. /**
  33. * List of colors that compose this gradient ordered.
  34. *
  35. * You need to add at least one color stop to have a visible gradient.
  36. *
  37. * @type {GradientColorStop[]}
  38. */
  39. this.colors = [];
  40. }
  41. GradientStyle.prototype = Object.create(Style.prototype);
  42. /**
  43. * Add a new color stop defined by an offset and a color to the gradient.
  44. *
  45. * If the offset is not between 0 and 1 inclusive, or if color can't be parsed as a CSS color, an error is raised.
  46. *
  47. * @param {number} offset Offset of the color stop between 0 and 1 inclusive.
  48. * @param {string} color CSS color value.
  49. */
  50. GradientStyle.prototype.addColorStop = function(offset, color)
  51. {
  52. this.colors.push(new GradientColorStop(offset, color));
  53. };
  54. GradientStyle.prototype.serialize = function()
  55. {
  56. return {
  57. colors: this.colors
  58. };
  59. };
  60. GradientStyle.prototype.parse = function(data)
  61. {
  62. var colors = [];
  63. for(var i = 0; i &lt; data.colors.length; i++)
  64. {
  65. colors.push(new GradientColorStop(data.colors[i].offset, data.colors[i].color));
  66. }
  67. this.colors = colors;
  68. };
  69. export {GradientStyle};
  70. </code></pre>
  71. </article>
  72. </section>
  73. </div>
  74. <nav>
  75. <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>
  76. </nav>
  77. <br class="clear">
  78. <footer>
  79. 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)
  80. </footer>
  81. <script> prettyPrint(); </script>
  82. <script src="scripts/linenumber.js"> </script>
  83. </body>
  84. </html>