@@ -33,7 +33,6 @@ const canvasState = require("./canvasState");
3333
3434/**
3535 * Creates a new canvas with the specified dimensions given in pixels.
36- * @public
3736 */
3837function CanvasContext ( canvas ) {
3938 this . canvas = canvas ;
@@ -48,39 +47,41 @@ function CanvasContext(canvas) {
4847
4948/**
5049 * Specifies the fill color that is used when the fill method is called. Allowed values are:
51- * - 32 bit integers on the format 0xRRGGBBAA
52- * - strings on the format #RGB
53- * - strings on the format #RGBA
54- * - strings on the format #RRGGBB
55- * - strings on the format #RRGGBBAA
56- * - strings on the format rgb(255, 255, 255)
57- * - strings on the format rgb(255, 255, 255, 0.5)
58- * - strings on the format rgb(255, 255, 255, 50%)
59- * - strings on the format rgba(255, 255, 255, 0.5)
60- * - strings on the format rgba(255, 255, 255, 50%)
61- * - strings on the format hsl(134, 50%, 50%)
62- * - strings on the format hsl(134, 50%, 50%, 0.5)
63- * - strings on the format hsl(134, 50%, 50%, 50%)
64- * - strings on the format hsla(134, 50%, 50%, 0.5)
65- * - strings on the format hsla(134, 50%, 50%, 50%)
66- * - strings on the format hwb(134, 50%, 50%)
67- * - strings on the format hwb(134, 50%, 50%, 0.5)
68- * - strings on the format hwb(134, 50%, 50%, 50%)
69- * @public
50+ * - 32 bit integers on the format ` 0xRRGGBBAA`
51+ * - strings on the format `" #RGB"`
52+ * - strings on the format `" #RGBA"`
53+ * - strings on the format `" #RRGGBB"`
54+ * - strings on the format `" #RRGGBBAA"`
55+ * - strings on the format `" rgb(255, 255, 255)"`
56+ * - strings on the format `" rgb(255, 255, 255, 0.5)"`
57+ * - strings on the format `" rgb(255, 255, 255, 50%)"`
58+ * - strings on the format `" rgba(255, 255, 255, 0.5)"`
59+ * - strings on the format `" rgba(255, 255, 255, 50%)"`
60+ * - strings on the format `" hsl(134, 50%, 50%)"`
61+ * - strings on the format `" hsl(134, 50%, 50%, 0.5)"`
62+ * - strings on the format `" hsl(134, 50%, 50%, 50%)"`
63+ * - strings on the format `" hsla(134, 50%, 50%, 0.5)"`
64+ * - strings on the format `" hsla(134, 50%, 50%, 50%)"`
65+ * - strings on the format `" hwb(134, 50%, 50%)"`
66+ * - strings on the format `" hwb(134, 50%, 50%, 0.5)"`
67+ * - strings on the format `" hwb(134, 50%, 50%, 50%)"`
68+ * @type { string|number }
7069 */
7170CanvasContext . prototype . fillStyle = 0x000000ff ;
7271
7372/**
74- * Saves the current state to the state stack.
75- * @public
73+ * Saves the current drawing state to a stack. The state can later be restored by calling `CanvasContext.restore()`.
74+ *
75+ * The following state is included when being saved to the stack:
76+ * - Current transformation matrix
77+ * - Current fill style
7678 */
7779CanvasContext . prototype . save = function CanvasContext_save ( ) {
7880 this . _savedStates . push ( canvasState . capture ( this ) ) ;
7981} ;
8082
8183/**
82- * Restores the last saved state of the CanvasContext.
83- * @public
84+ * Restores the last drawing state that was saved with `CanvasContext.save()`, and then removes it from the state stack.
8485 */
8586CanvasContext . prototype . restore = function CanvasContext_restore ( ) {
8687 if ( this . _savedStates . length ) {
@@ -89,16 +90,14 @@ CanvasContext.prototype.restore = function CanvasContext_restore() {
8990} ;
9091
9192/**
92- * Resets the internal path buffer and begins a new path.
93- * @public
93+ * Restores the current transformation to the identity matrix.
9494 */
9595CanvasContext . prototype . resetTransform = function CanvasContext_resetTransform ( ) {
9696 this . _transform = new Matrix ( 1 , 0 , 0 , 1 , 0 , 0 ) ;
9797} ;
9898
9999/**
100100 * Multiplies the current transformation matrix with the specified values.
101- * @public
102101 */
103102CanvasContext . prototype . transform = function CanvasContext_transform ( a , b , c , d , e , f ) {
104103 if ( ! Number . isFinite ( a ) ||
@@ -115,7 +114,6 @@ CanvasContext.prototype.transform = function CanvasContext_transform(a, b, c, d,
115114
116115/**
117116 * Sets the transformation matrix to the specified matrix.
118- * @public
119117 */
120118CanvasContext . prototype . setTransform = function CanvasContext_transform ( a , b , c , d , e , f ) {
121119 if ( ! Number . isFinite ( a ) ||
@@ -131,10 +129,9 @@ CanvasContext.prototype.setTransform = function CanvasContext_transform(a, b, c,
131129} ;
132130
133131/**
134- * Applies a translation transformation to the CanvasContext .
132+ * Applies a translation transformation on top of the current transform .
135133 * @param {number } x Distance to move in the horizontal direction in pixels.
136134 * @param {number } y Distance to move in the vertical direction in pixels.
137- * @public
138135 */
139136CanvasContext . prototype . translate = function CanvasContext_translate ( x , y ) {
140137 if ( ! Number . isFinite ( x ) || ! Number . isFinite ( y ) ) {
@@ -145,10 +142,9 @@ CanvasContext.prototype.translate = function CanvasContext_translate(x, y) {
145142} ;
146143
147144/**
148- * Applies a scale transformation to the CanvasContext.
149- * @param {number } x Scale in the horizontal direction. 1 means no scale.
150- * @param {number } y Scale in the vertical direction. 1 means no scale.
151- * @public
145+ * Applies a scale transformation on top of the current transform.
146+ * @param {number } x Scale in the horizontal direction. `1` means no horizontal scaling.
147+ * @param {number } y Scale in the vertical direction. `1` means no vertical scaling.
152148 */
153149CanvasContext . prototype . scale = function CanvasContext_scale ( x , y ) {
154150 if ( ! Number . isFinite ( x ) || ! Number . isFinite ( y ) ) {
@@ -159,9 +155,8 @@ CanvasContext.prototype.scale = function CanvasContext_scale(x, y) {
159155} ;
160156
161157/**
162- * Applies a rotation transformation to the canvas around its current origo.
158+ * Applies a rotation transformation on top of the current transform around the current canvas origo.
163159 * @param {number } angle Angle in radians measured clockwise from the positive x axis.
164- * @public
165160 */
166161CanvasContext . prototype . rotate = function CanvasContext_rotate ( angle ) {
167162 if ( ! Number . isFinite ( angle ) ) {
@@ -173,15 +168,13 @@ CanvasContext.prototype.rotate = function CanvasContext_rotate(angle) {
173168
174169/**
175170 * Removes all existing subpaths and begins a new path.
176- * @public
177171 */
178172CanvasContext . prototype . beginPath = function CanvasContext_beginPath ( ) {
179173 this . _paths = [ ] ;
180174} ;
181175
182176/**
183177 * Starts a new subpath that begins in the same point as the start and end point of the previous one.
184- * @public
185178 */
186179CanvasContext . prototype . closePath = function CanvasContext_closePath ( ) {
187180 if ( this . _paths . length ) {
@@ -204,7 +197,6 @@ CanvasContext.prototype.closePath = function CanvasContext_closePath() {
204197 * Begins a new subpath by moving the cursor to the specified position.
205198 * @param {number } x X coordinate.
206199 * @param {number } y Y coordinate.
207- * @public
208200 */
209201CanvasContext . prototype . moveTo = function CanvasContext_moveTo ( x , y ) {
210202 if ( ! Number . isFinite ( x ) || ! Number . isFinite ( y ) ) {
@@ -219,7 +211,6 @@ CanvasContext.prototype.moveTo = function CanvasContext_moveTo(x, y) {
219211 * Inserts an edge between the last and specified position.
220212 * @param {number } x Target X coordinate.
221213 * @param {number } y Target Y coordinate.
222- * @public
223214 */
224215CanvasContext . prototype . lineTo = function CanvasContext_lineTo ( x , y ) {
225216 if ( ! Number . isFinite ( x ) || ! Number . isFinite ( y ) ) {
@@ -243,7 +234,7 @@ CanvasContext.prototype.lineTo = function CanvasContext_lineTo(x, y) {
243234 * @param {number } radius Radius of the arc.
244235 * @param {number } startAngle The angle in radians at which the arc starts, measured clockwise from the positive x axis.
245236 * @param {number } endAngle The angle in radians at which the arc end, measured clockwise from the positive x axis.
246- * @param {Boolean } anticlockwise Specifies whether the arc will be drawn counter clockwise. Default is clockwise.
237+ * @param {boolean } [ anticlockwise] Specifies whether the arc will be drawn counter clockwise. Default is clockwise.
247238 */
248239CanvasContext . prototype . arc = function CanvasContext_arc ( x , y , radius , startAngle , endAngle , anticlockwise ) {
249240 if ( ! Number . isFinite ( x ) || ! Number . isFinite ( y ) ||
@@ -304,12 +295,11 @@ CanvasContext.prototype.arc = function CanvasContext_arc(x, y, radius, startAngl
304295} ;
305296
306297/**
307- * Fills the specified rectangle with fully transparent black without affecting the current paths.
298+ * Fills a specified rectangle with fully transparent black without blending with the background or affecting the current paths.
308299 * @param {number } x X coordinate of the left side of the rectangle.
309300 * @param {number } y Y coordinate of the top of the rectangle.
310301 * @param {number } width Width of the rectangle.
311302 * @param {number } height Height of the rectangle.
312- * @public
313303 */
314304CanvasContext . prototype . clearRect = function CanvasContext_clearRect ( x , y , width , height ) {
315305 var fullCanvas = false ;
@@ -336,12 +326,11 @@ CanvasContext.prototype.clearRect = function CanvasContext_clearRect(x, y, width
336326} ;
337327
338328/**
339- * Fills the specified rectangle without affecting the current paths.
329+ * Fills a specified rectangle without affecting the current paths.
340330 * @param {number } x X coordinate of the left side of the rectangle.
341331 * @param {number } y Y coordinate of the top of the rectangle.
342332 * @param {number } width Width of the rectangle.
343333 * @param {number } height Height of the rectangle.
344- * @public
345334 */
346335CanvasContext . prototype . fillRect = function CanvasContext_fillRect ( x , y , width , height ) {
347336 var fillColor = colorUtils . parse ( this . fillStyle ) ;
@@ -379,9 +368,8 @@ CanvasContext.prototype._fillRect = function CanvasContext__fillRect(fillColor,
379368/**
380369 * Fills the defined paths.
381370 * @param {string } [windingRule] The winding rule to be used for determining
382- * which areas are covered by the current path. Valid values are "evenodd" and
383- * "nonzero". Default is "nonzero".
384- * @public
371+ * which areas are covered by the current path. Valid values are "evenodd" and
372+ * "nonzero". Default is `"nonzero"`.
385373 */
386374CanvasContext . prototype . fill = function CanvasContext_fill ( windingRule ) {
387375 var id = this . _edges . nextId ++ ;
0 commit comments