Skip to content

Commit 4fd7dd6

Browse files
committed
more scaladocs
1 parent 38b238b commit 4fd7dd6

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

dom/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,18 @@ class CanvasRenderingContext2D extends js.Object {
7777
/** Restores the drawing style state to the last element on the 'state stack' saved by save(). */
7878
def restore(): Unit = js.native
7979

80+
/** Resets the current transform to the identity matrix, and then invokes the transform() method with the same
81+
* arguments.
82+
*/
8083
def setTransform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit = js.native
8184

8285
/** Saves the current drawing style state using a stack so you can revert any change you make to it using restore().
8386
*/
8487
def save(): Unit = js.native
8588

89+
/** Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at
90+
* endAngle going in the given direction by anticlockwise (defaulting to clockwise).
91+
*/
8692
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double,
8793
anticlockwise: Boolean): Unit = js.native
8894

@@ -91,27 +97,39 @@ class CanvasRenderingContext2D extends js.Object {
9197
*/
9298
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native
9399

100+
/** Returns a TextMetrics object. */
94101
def measureText(text: String): TextMetrics = js.native
95102

103+
/** Reports whether or not the specified point is contained in the current path. */
96104
def isPointInPath(x: Double, y: Double, fillRule: String): Boolean = js.native
97105

98106
/** Reports whether or not the specified point is contained in the current path. */
99107
def isPointInPath(x: Double, y: Double): Boolean = js.native
100108

109+
/** Adds a quadratic Bézier curve to the current path. */
101110
def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native
102111

112+
/** Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels
113+
* from that rectangle are painted.
114+
*/
103115
def putImageData(imagedata: ImageData, dx: Double, dy: Double, dirtyX: Double = js.native, dirtyY: Double = js.native,
104116
dirtyWidth: Double = js.native, dirtyHeight: Double = js.native): Unit = js.native
105117

118+
/** Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is
119+
* expressed in radians.
120+
*/
106121
def rotate(angle: Double): Unit = js.native
107122

123+
/** Draws (fills) a given text at the given (x, y) position. */
108124
def fillText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit = js.native
109125

110126
/** Moves the origin point of the context to (x, y). */
111127
def translate(x: Double, y: Double): Unit = js.native
112128

129+
/** Adds a scaling transformation to the canvas units by x horizontally and by y vertically. */
113130
def scale(x: Double, y: Double): Unit = js.native
114131

132+
/** Creates a radial gradient given by the coordinates of the two circles represented by the parameters. */
115133
def createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double,
116134
r1: Double): CanvasGradient = js.native
117135

@@ -135,13 +153,17 @@ class CanvasRenderingContext2D extends js.Object {
135153
*/
136154
def createImageData(imageDataOrSw: js.Any, sh: Double = js.native): ImageData = js.native
137155

156+
/** Creates a pattern using the specified image. It repeats the source in the directions specified by the repetition
157+
* argument. This method returns a CanvasPattern.
158+
*/
138159
def createPattern(image: HTMLElement, repetition: String): CanvasPattern = js.native
139160

140161
/** Tries to draw a straight line from the current point to the start. If the shape has already been closed or has
141162
* only one point, this function does nothing.
142163
*/
143164
def closePath(): Unit = js.native
144165

166+
/** Creates a path for a rectangle at position (x, y) with a size that is determined by width and height. */
145167
def rect(x: Double, y: Double, w: Double, h: Double): Unit = js.native
146168

147169
/** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the
@@ -164,6 +186,7 @@ class CanvasRenderingContext2D extends js.Object {
164186
/** Draws a filled rectangle at (x, y) position whose size is determined by width and height. */
165187
def fillRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native
166188

189+
/** Adds a cubic Bézier curve to the current path. */
167190
def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit = js.native
168191

169192
/** Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in
@@ -173,6 +196,7 @@ class CanvasRenderingContext2D extends js.Object {
173196
height: Double = js.native, canvasOffsetX: Double = js.native, canvasOffsetY: Double = js.native,
174197
canvasImageWidth: Double = js.native, canvasImageHeight: Double = js.native): Unit = js.native
175198

199+
/** Multiplies the current transformation matrix with the matrix described by its arguments. */
176200
def transform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit = js.native
177201

178202
/** Strokes the subpaths with the current stroke style. */
@@ -185,8 +209,10 @@ class CanvasRenderingContext2D extends js.Object {
185209
*/
186210
def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native
187211

212+
/** Sets the current line dash pattern. */
188213
def setLineDash(segments: js.Array[Double]): Unit = js.native
189214

215+
/** Draws (strokes) a given text at the given (x, y) position. */
190216
def strokeText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit = js.native
191217

192218
/** Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path. */
@@ -195,6 +221,7 @@ class CanvasRenderingContext2D extends js.Object {
195221
/** Adds an arc with the given control points and radius, connected to the previous point by a straight line. */
196222
def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native
197223

224+
/** Creates a linear gradient along the line given by the coordinates represented by the parameters. */
198225
def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient = js.native
199226

200227
/** The ellipse() method creates an elliptical arc centered at (x, y) with the radii radiusX and radiusY. The path

dom/src/main/scala/org/scalajs/dom/Path2D.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,51 @@ import scala.scalajs.js.annotation.JSGlobal
77
@JSGlobal
88
class Path2D extends js.Object {
99

10+
/** Adds a path to the current path. */
1011
def addPath(path: Path2D): Unit = js.native
1112

13+
/** Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line
14+
* from the current point to the start. If the shape has already been closed or has only one point, this function
15+
* does nothing.
16+
*/
1217
def closePath(): Unit = js.native
1318

19+
/** Moves the starting point of a new sub-path to the (x, y) coordinates. */
1420
def moveTo(x: Double, y: Double): Unit = js.native
1521

22+
/** Connects the last point in the subpath to the (x, y) coordinates with a straight line. */
1623
def lineTo(x: Double, y: Double): Unit = js.native
1724

25+
/** Adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the
26+
* third one is the end point. The starting point is the last point in the current path, which can be changed using
27+
* moveTo() before creating the Bézier curve.
28+
*/
1829
def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit = js.native
1930

31+
/** Adds a quadratic Bézier curve to the current path. */
2032
def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native
2133

34+
/** Adds a circular arc to the path with the given control points and radius, connected to the previous point by a
35+
* straight line.
36+
*/
2237
def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native
2338

39+
/** Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at
40+
* endAngle going in the given direction by counterclockwise (defaulting to clockwise).
41+
*/
2442
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double,
2543
anticlockwise: Boolean): Unit = js.native
2644

2745
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native
2846

47+
/** Adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
48+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to
49+
* clockwise).
50+
*/
2951
def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double,
3052
endAngle: Double, anticlockwise: Boolean = js.native): Unit = js.native
3153

54+
/** Creates a path for a rectangle at position (x, y) with a size that is determined by width and height. */
3255
def rect(x: Double, y: Double, w: Double, h: Double): Unit = js.native
3356

3457
}

0 commit comments

Comments
 (0)