Skip to content

Commit 38b238b

Browse files
committed
add Path2D and related methods
1 parent 0accb64 commit 38b238b

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

api-reports/2_12.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,9 @@ CanvasRenderingContext2D[JC] def createRadialGradient(x0: Double, y0: Double, r0
10891089
CanvasRenderingContext2D[JC] def drawImage(image: HTMLElement, offsetX: Double, offsetY: Double, width: Double?, height: Double?, canvasOffsetX: Double?, canvasOffsetY: Double?, canvasImageWidth: Double?, canvasImageHeight: Double?): Unit
10901090
CanvasRenderingContext2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean?): Unit
10911091
CanvasRenderingContext2D[JC] def fill(): Unit
1092+
CanvasRenderingContext2D[JC] def fill(fillRule: String): Unit
1093+
CanvasRenderingContext2D[JC] def fill(path: Path2D): Unit
1094+
CanvasRenderingContext2D[JC] def fill(path: Path2D, fillRule: String): Unit
10921095
CanvasRenderingContext2D[JC] def fillRect(x: Double, y: Double, w: Double, h: Double): Unit
10931096
CanvasRenderingContext2D[JC] var fillStyle: js.Any
10941097
CanvasRenderingContext2D[JC] def fillText(text: String, x: Double, y: Double, maxWidth: Double?): Unit
@@ -1122,6 +1125,7 @@ CanvasRenderingContext2D[JC] var shadowColor: String
11221125
CanvasRenderingContext2D[JC] var shadowOffsetX: Double
11231126
CanvasRenderingContext2D[JC] var shadowOffsetY: Double
11241127
CanvasRenderingContext2D[JC] def stroke(): Unit
1128+
CanvasRenderingContext2D[JC] def stroke(path: Path2D): Unit
11251129
CanvasRenderingContext2D[JC] def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit
11261130
CanvasRenderingContext2D[JC] var strokeStyle: js.Any
11271131
CanvasRenderingContext2D[JC] def strokeText(text: String, x: Double, y: Double, maxWidth: Double?): Unit
@@ -16627,6 +16631,17 @@ ParentNode[JT] def children: HTMLCollection[Element]
1662716631
ParentNode[JT] def firstElementChild: Element
1662816632
ParentNode[JT] def lastElementChild: Element
1662916633
ParentNode[JT] def replaceChildren(nodes: Node | String*): Unit
16634+
Path2D[JC] def addPath(path: Path2D): Unit
16635+
Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit
16636+
Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean): Unit
16637+
Path2D[JC] def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit
16638+
Path2D[JC] def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit
16639+
Path2D[JC] def closePath(): Unit
16640+
Path2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean?): Unit
16641+
Path2D[JC] def lineTo(x: Double, y: Double): Unit
16642+
Path2D[JC] def moveTo(x: Double, y: Double): Unit
16643+
Path2D[JC] def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit
16644+
Path2D[JC] def rect(x: Double, y: Double, w: Double, h: Double): Unit
1663016645
Pbkdf2Params[JT] val hash: HashAlgorithmIdentifier
1663116646
Pbkdf2Params[JT] val iterations: Double
1663216647
Pbkdf2Params[JT] val name: String

api-reports/2_13.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,9 @@ CanvasRenderingContext2D[JC] def createRadialGradient(x0: Double, y0: Double, r0
10891089
CanvasRenderingContext2D[JC] def drawImage(image: HTMLElement, offsetX: Double, offsetY: Double, width: Double?, height: Double?, canvasOffsetX: Double?, canvasOffsetY: Double?, canvasImageWidth: Double?, canvasImageHeight: Double?): Unit
10901090
CanvasRenderingContext2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean?): Unit
10911091
CanvasRenderingContext2D[JC] def fill(): Unit
1092+
CanvasRenderingContext2D[JC] def fill(fillRule: String): Unit
1093+
CanvasRenderingContext2D[JC] def fill(path: Path2D): Unit
1094+
CanvasRenderingContext2D[JC] def fill(path: Path2D, fillRule: String): Unit
10921095
CanvasRenderingContext2D[JC] def fillRect(x: Double, y: Double, w: Double, h: Double): Unit
10931096
CanvasRenderingContext2D[JC] var fillStyle: js.Any
10941097
CanvasRenderingContext2D[JC] def fillText(text: String, x: Double, y: Double, maxWidth: Double?): Unit
@@ -1122,6 +1125,7 @@ CanvasRenderingContext2D[JC] var shadowColor: String
11221125
CanvasRenderingContext2D[JC] var shadowOffsetX: Double
11231126
CanvasRenderingContext2D[JC] var shadowOffsetY: Double
11241127
CanvasRenderingContext2D[JC] def stroke(): Unit
1128+
CanvasRenderingContext2D[JC] def stroke(path: Path2D): Unit
11251129
CanvasRenderingContext2D[JC] def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit
11261130
CanvasRenderingContext2D[JC] var strokeStyle: js.Any
11271131
CanvasRenderingContext2D[JC] def strokeText(text: String, x: Double, y: Double, maxWidth: Double?): Unit
@@ -16627,6 +16631,17 @@ ParentNode[JT] def children: HTMLCollection[Element]
1662716631
ParentNode[JT] def firstElementChild: Element
1662816632
ParentNode[JT] def lastElementChild: Element
1662916633
ParentNode[JT] def replaceChildren(nodes: Node | String*): Unit
16634+
Path2D[JC] def addPath(path: Path2D): Unit
16635+
Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit
16636+
Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean): Unit
16637+
Path2D[JC] def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit
16638+
Path2D[JC] def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit
16639+
Path2D[JC] def closePath(): Unit
16640+
Path2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean?): Unit
16641+
Path2D[JC] def lineTo(x: Double, y: Double): Unit
16642+
Path2D[JC] def moveTo(x: Double, y: Double): Unit
16643+
Path2D[JC] def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit
16644+
Path2D[JC] def rect(x: Double, y: Double, w: Double, h: Double): Unit
1663016645
Pbkdf2Params[JT] val hash: HashAlgorithmIdentifier
1663116646
Pbkdf2Params[JT] val iterations: Double
1663216647
Pbkdf2Params[JT] val name: String

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ class CanvasRenderingContext2D extends js.Object {
124124
/** Fills the subpaths with the current fill style. */
125125
def fill(): Unit = js.native
126126

127+
def fill(path: Path2D): Unit = js.native
128+
129+
def fill(fillRule: String): Unit = js.native
130+
131+
def fill(path: Path2D, fillRule: String): Unit = js.native
132+
127133
/** Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are
128134
* transparent black.
129135
*/
@@ -172,6 +178,8 @@ class CanvasRenderingContext2D extends js.Object {
172178
/** Strokes the subpaths with the current stroke style. */
173179
def stroke(): Unit = js.native
174180

181+
def stroke(path: Path2D): Unit = js.native
182+
175183
/** Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using
176184
* the current stroke style.
177185
*/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.JSGlobal
5+
6+
@js.native
7+
@JSGlobal
8+
class Path2D extends js.Object {
9+
10+
def addPath(path: Path2D): Unit = js.native
11+
12+
def closePath(): Unit = js.native
13+
14+
def moveTo(x: Double, y: Double): Unit = js.native
15+
16+
def lineTo(x: Double, y: Double): Unit = js.native
17+
18+
def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit = js.native
19+
20+
def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native
21+
22+
def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native
23+
24+
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double,
25+
anticlockwise: Boolean): Unit = js.native
26+
27+
def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native
28+
29+
def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double,
30+
endAngle: Double, anticlockwise: Boolean = js.native): Unit = js.native
31+
32+
def rect(x: Double, y: Double, w: Double, h: Double): Unit = js.native
33+
34+
}

0 commit comments

Comments
 (0)