Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17abf36

Browse files
committed
add CanvasFillRule enum
1 parent 4fd7dd6 commit 17abf36

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
@js.native
6+
sealed trait CanvasFillRule extends js.Any
7+
8+
object CanvasFillRule {
9+
10+
val nonzero: CanvasFillRule = "nonzero".asInstanceOf[CanvasFillRule]
11+
12+
val evenodd: CanvasFillRule = "evenodd".asInstanceOf[CanvasFillRule]
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
opaque type CanvasFillRule <: String = String
6+
7+
object CanvasFillRule {
8+
9+
val nonzero: CanvasFillRule = "nonzero"
10+
11+
val evenodd: CanvasFillRule = "evenodd"
12+
13+
}

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

+27-14
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,28 @@ class CanvasRenderingContext2D extends js.Object {
8686
*/
8787
def save(): Unit = js.native
8888

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).
89+
/** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle,
90+
* ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise).
9191
*/
9292
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double,
93-
anticlockwise: Boolean): Unit = js.native
93+
counterclockwise: Boolean): Unit = js.native
9494

95-
/** Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at
96-
* endAngle going in the given direction by anticlockwise (defaulting to clockwise).
95+
/** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle,
96+
* ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise).
9797
*/
9898
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native
9999

100100
/** Returns a TextMetrics object. */
101101
def measureText(text: String): TextMetrics = js.native
102102

103103
/** Reports whether or not the specified point is contained in the current path. */
104-
def isPointInPath(x: Double, y: Double, fillRule: String): Boolean = js.native
104+
def isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule = js.native): Boolean = js.native
105105

106106
/** Reports whether or not the specified point is contained in the current path. */
107-
def isPointInPath(x: Double, y: Double): Boolean = js.native
107+
def isPointInPath(path: Path2D, x: Double, y: Double): Boolean = js.native
108+
109+
/** Reports whether or not the specified point is contained in the current path. */
110+
def isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule): Boolean = js.native
108111

109112
/** Adds a quadratic Bézier curve to the current path. */
110113
def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native
@@ -140,13 +143,13 @@ class CanvasRenderingContext2D extends js.Object {
140143
def getLineDash(): js.Array[Double] = js.native
141144

142145
/** Fills the subpaths with the current fill style. */
143-
def fill(): Unit = js.native
146+
def fill(fillRule: CanvasFillRule = js.native): Unit = js.native
144147

148+
/** Fills the subpaths with the current fill style. */
145149
def fill(path: Path2D): Unit = js.native
146150

147-
def fill(fillRule: String): Unit = js.native
148-
149-
def fill(path: Path2D, fillRule: String): Unit = js.native
151+
/** Fills the subpaths with the current fill style. */
152+
def fill(path: Path2D, fillRule: CanvasFillRule): Unit = js.native
150153

151154
/** Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are
152155
* transparent black.
@@ -169,7 +172,17 @@ class CanvasRenderingContext2D extends js.Object {
169172
/** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the
170173
* clipping path only. For an example, see Clipping paths in the Canvas tutorial.
171174
*/
172-
def clip(fillRule: String = js.native): Unit = js.native
175+
def clip(fillRule: CanvasFillRule = js.native): Unit = js.native
176+
177+
/** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the
178+
* clipping path only. For an example, see Clipping paths in the Canvas tutorial.
179+
*/
180+
def clip(path: Path2D): Unit = js.native
181+
182+
/** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the
183+
* clipping path only. For an example, see Clipping paths in the Canvas tutorial.
184+
*/
185+
def clip(path: Path2D, fillRule: CanvasFillRule): Unit = js.native
173186

174187
/** Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black.
175188
*/
@@ -225,9 +238,9 @@ class CanvasRenderingContext2D extends js.Object {
225238
def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient = js.native
226239

227240
/** The ellipse() method creates an elliptical arc centered at (x, y) with the radii radiusX and radiusY. The path
228-
* starts at startAngle and ends at endAngle, and travels in the direction given by anticlockwise (defaulting to
241+
* starts at startAngle and ends at endAngle, and travels in the direction given by counterclockwise (defaulting to
229242
* clockwise).
230243
*/
231244
def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double,
232-
endAngle: Double, anticlockwise: Boolean = js.native): Unit = js.native
245+
endAngle: Double, counterclockwise: Boolean = js.native): Unit = js.native
233246
}

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

+13-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package org.scalajs.dom
33
import scala.scalajs.js
44
import scala.scalajs.js.annotation.JSGlobal
55

6+
/** The [[Path2D]] interface of the Canvas 2D API is used to declare a path that can then be used on a
7+
* [[CanvasRenderingContext2D]] object. The path methods of the [[CanvasRenderingContext2D]] interface are also present
8+
* on this interface, which gives you the convenience of being able to retain and replay your path whenever desired.
9+
*/
610
@js.native
711
@JSGlobal
812
class Path2D extends js.Object {
@@ -36,20 +40,23 @@ class Path2D extends js.Object {
3640
*/
3741
def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native
3842

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).
43+
/** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle,
44+
* ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise).
4145
*/
4246
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double,
43-
anticlockwise: Boolean): Unit = js.native
47+
counterclockwise: Boolean): Unit = js.native
4448

49+
/** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle,
50+
* ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise).
51+
*/
4552
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native
4653

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
54+
/** The ellipse() method creates an elliptical arc centered at (x, y) with the radii radiusX and radiusY. The path
55+
* starts at startAngle and ends at endAngle, and travels in the direction given by counterclockwise (defaulting to
4956
* clockwise).
5057
*/
5158
def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double,
52-
endAngle: Double, anticlockwise: Boolean = js.native): Unit = js.native
59+
endAngle: Double, counterclockwise: Boolean = js.native): Unit = js.native
5360

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

0 commit comments

Comments
 (0)