tentone 5 роки тому
батько
коміт
8742f512e6

+ 1 - 1
source/objects/style/ColorStyle.js

@@ -19,7 +19,7 @@ function ColorStyle(color)
 
 ColorStyle.prototype = Object.create(Style);
 
-ColorStyle.prototype.generate = function(context)
+ColorStyle.prototype.get = function(context)
 {
     return this.color;
 };

+ 3 - 3
source/objects/style/GradientStyle.js

@@ -3,7 +3,7 @@ import {Style} from "./Style";
 /**
  * Gradient style describes a gradient by its colors, directions origin, type (linear or radial, etc.
  *
- * The object returns a CanvasGradient https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient when generated.
+ * The get method returns a CanvasGradient https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient when generated.
  *
  * @class
  * @extends {Style}
@@ -12,7 +12,7 @@ function GradientStyle()
 {
     /**
      * Type of gradient can be LINEAR or RADIAL.
-     * 
+     *
      * @type {number}
      */
     this.type = GradientStyle.LINEAR;
@@ -51,7 +51,7 @@ GradientStyle.prototype.addColorStop = function(offset, color)
 
 };
 
-GradientStyle.prototype.generate = function(context)
+GradientStyle.prototype.get = function(context)
 {
     // context.createLinearGradient()
     // context.createRadialGradient()

+ 33 - 0
source/objects/style/PatternStyle.js

@@ -0,0 +1,33 @@
+import {Style} from "./Style";
+
+/**
+ * Pattern style represents an opaque object describing a pattern, based on an image, a canvas, or a video.
+ *
+ * The get method returns a CanvasPattern object https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern created by the context.createPattern() method.
+ *
+ * @class
+ * @extends {Style}
+ */
+function PatternStyle()
+{
+
+}
+
+/**
+ * Applies an 2x3 transformation matrix representing a linear transform to the pattern.
+ *
+ * The transformation allows to move, rotate and scale the pattern freely
+ *
+ * @param {number[]} transform 2x3 Transformation matrix.
+ */
+PatternStyle.prototype.setTransform = function(transform)
+{
+    // TODO <ADD CODE HERE>
+};
+
+PatternStyle.prototype.toJSON = function ()
+{
+
+};
+
+export {PatternStyle};

+ 2 - 2
source/objects/style/Style.js

@@ -10,12 +10,12 @@ import {ColorStyle} from "./ColorStyle";
 function Style() {}
 
 /**
- * Generate style object from style data and the drawing context.
+ * Get generated style object from style data and the drawing context.
  *
  * @param {CanvasRenderingContext2D} context Context being used to draw the object.
  * @return {string | CanvasGradient | CanvasPattern} Return the canvas style object generated.
  */
-Style.prototype.generate = function(context) {};
+Style.prototype.get = function(context) {};
 
 Style.prototype.toJSON = function() {};