diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index b909d6f20..ab04fbca0 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -1070,25 +1070,32 @@ CacheStorage[JT] def has(cacheName: String): js.Promise[Boolean] CacheStorage[JT] def keys(): js.Promise[js.Array[String]] CacheStorage[JT] def `match`(request: RequestInfo, options: CacheQueryOptions?): js.Promise[js.Any] CacheStorage[JT] def open(cacheName: String): js.Promise[Cache] +CanvasFillRule[JT] +CanvasFillRule[SO] val evenodd: CanvasFillRule +CanvasFillRule[SO] val nonzero: CanvasFillRule CanvasGradient[JC] def addColorStop(offset: Double, color: String): Unit CanvasPattern[JC] CanvasProxy[JT] def setContext(context: RenderingContext): Unit CanvasRenderingContext2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit -CanvasRenderingContext2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean): Unit +CanvasRenderingContext2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean): Unit CanvasRenderingContext2D[JC] def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit CanvasRenderingContext2D[JC] def beginPath(): Unit CanvasRenderingContext2D[JC] def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit CanvasRenderingContext2D[JC] var canvas: HTMLCanvasElement CanvasRenderingContext2D[JC] def clearRect(x: Double, y: Double, w: Double, h: Double): Unit -CanvasRenderingContext2D[JC] def clip(fillRule: String?): Unit +CanvasRenderingContext2D[JC] def clip(fillRule: CanvasFillRule?): Unit +CanvasRenderingContext2D[JC] def clip(path: Path2D): Unit +CanvasRenderingContext2D[JC] def clip(path: Path2D, fillRule: CanvasFillRule): Unit CanvasRenderingContext2D[JC] def closePath(): Unit CanvasRenderingContext2D[JC] def createImageData(imageDataOrSw: js.Any, sh: Double?): ImageData CanvasRenderingContext2D[JC] def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient CanvasRenderingContext2D[JC] def createPattern(image: HTMLElement, repetition: String): CanvasPattern CanvasRenderingContext2D[JC] def createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double, r1: Double): CanvasGradient CanvasRenderingContext2D[JC] def drawImage(image: HTMLElement, offsetX: Double, offsetY: Double, width: Double?, height: Double?, canvasOffsetX: Double?, canvasOffsetY: Double?, canvasImageWidth: Double?, canvasImageHeight: Double?): Unit -CanvasRenderingContext2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean?): Unit -CanvasRenderingContext2D[JC] def fill(): Unit +CanvasRenderingContext2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean?): Unit +CanvasRenderingContext2D[JC] def fill(fillRule: CanvasFillRule?): Unit +CanvasRenderingContext2D[JC] def fill(path: Path2D): Unit +CanvasRenderingContext2D[JC] def fill(path: Path2D, fillRule: CanvasFillRule): Unit CanvasRenderingContext2D[JC] def fillRect(x: Double, y: Double, w: Double, h: Double): Unit CanvasRenderingContext2D[JC] var fillStyle: js.Any CanvasRenderingContext2D[JC] def fillText(text: String, x: Double, y: Double, maxWidth: Double?): Unit @@ -1098,8 +1105,9 @@ CanvasRenderingContext2D[JC] def getLineDash(): js.Array[Double] CanvasRenderingContext2D[JC] var globalAlpha: Double CanvasRenderingContext2D[JC] var globalCompositeOperation: String CanvasRenderingContext2D[JC] var imageSmoothingEnabled: Boolean -CanvasRenderingContext2D[JC] def isPointInPath(x: Double, y: Double): Boolean -CanvasRenderingContext2D[JC] def isPointInPath(x: Double, y: Double, fillRule: String): Boolean +CanvasRenderingContext2D[JC] def isPointInPath(path: Path2D, x: Double, y: Double): Boolean +CanvasRenderingContext2D[JC] def isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule): Boolean +CanvasRenderingContext2D[JC] def isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule?): Boolean CanvasRenderingContext2D[JC] var lineCap: String CanvasRenderingContext2D[JC] var lineDashOffset: Double CanvasRenderingContext2D[JC] var lineJoin: String @@ -1122,6 +1130,7 @@ CanvasRenderingContext2D[JC] var shadowColor: String CanvasRenderingContext2D[JC] var shadowOffsetX: Double CanvasRenderingContext2D[JC] var shadowOffsetY: Double CanvasRenderingContext2D[JC] def stroke(): Unit +CanvasRenderingContext2D[JC] def stroke(path: Path2D): Unit CanvasRenderingContext2D[JC] def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit CanvasRenderingContext2D[JC] var strokeStyle: js.Any CanvasRenderingContext2D[JC] def strokeText(text: String, x: Double, y: Double, maxWidth: Double?): Unit @@ -16627,6 +16636,17 @@ ParentNode[JT] def children: HTMLCollection[Element] ParentNode[JT] def firstElementChild: Element ParentNode[JT] def lastElementChild: Element ParentNode[JT] def replaceChildren(nodes: Node | String*): Unit +Path2D[JC] def addPath(path: Path2D): Unit +Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit +Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean): Unit +Path2D[JC] def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit +Path2D[JC] def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit +Path2D[JC] def closePath(): Unit +Path2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean?): Unit +Path2D[JC] def lineTo(x: Double, y: Double): Unit +Path2D[JC] def moveTo(x: Double, y: Double): Unit +Path2D[JC] def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit +Path2D[JC] def rect(x: Double, y: Double, w: Double, h: Double): Unit Pbkdf2Params[JT] val hash: HashAlgorithmIdentifier Pbkdf2Params[JT] val iterations: Double Pbkdf2Params[JT] val name: String diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index b909d6f20..ab04fbca0 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -1070,25 +1070,32 @@ CacheStorage[JT] def has(cacheName: String): js.Promise[Boolean] CacheStorage[JT] def keys(): js.Promise[js.Array[String]] CacheStorage[JT] def `match`(request: RequestInfo, options: CacheQueryOptions?): js.Promise[js.Any] CacheStorage[JT] def open(cacheName: String): js.Promise[Cache] +CanvasFillRule[JT] +CanvasFillRule[SO] val evenodd: CanvasFillRule +CanvasFillRule[SO] val nonzero: CanvasFillRule CanvasGradient[JC] def addColorStop(offset: Double, color: String): Unit CanvasPattern[JC] CanvasProxy[JT] def setContext(context: RenderingContext): Unit CanvasRenderingContext2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit -CanvasRenderingContext2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean): Unit +CanvasRenderingContext2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean): Unit CanvasRenderingContext2D[JC] def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit CanvasRenderingContext2D[JC] def beginPath(): Unit CanvasRenderingContext2D[JC] def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit CanvasRenderingContext2D[JC] var canvas: HTMLCanvasElement CanvasRenderingContext2D[JC] def clearRect(x: Double, y: Double, w: Double, h: Double): Unit -CanvasRenderingContext2D[JC] def clip(fillRule: String?): Unit +CanvasRenderingContext2D[JC] def clip(fillRule: CanvasFillRule?): Unit +CanvasRenderingContext2D[JC] def clip(path: Path2D): Unit +CanvasRenderingContext2D[JC] def clip(path: Path2D, fillRule: CanvasFillRule): Unit CanvasRenderingContext2D[JC] def closePath(): Unit CanvasRenderingContext2D[JC] def createImageData(imageDataOrSw: js.Any, sh: Double?): ImageData CanvasRenderingContext2D[JC] def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient CanvasRenderingContext2D[JC] def createPattern(image: HTMLElement, repetition: String): CanvasPattern CanvasRenderingContext2D[JC] def createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double, r1: Double): CanvasGradient CanvasRenderingContext2D[JC] def drawImage(image: HTMLElement, offsetX: Double, offsetY: Double, width: Double?, height: Double?, canvasOffsetX: Double?, canvasOffsetY: Double?, canvasImageWidth: Double?, canvasImageHeight: Double?): Unit -CanvasRenderingContext2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, anticlockwise: Boolean?): Unit -CanvasRenderingContext2D[JC] def fill(): Unit +CanvasRenderingContext2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean?): Unit +CanvasRenderingContext2D[JC] def fill(fillRule: CanvasFillRule?): Unit +CanvasRenderingContext2D[JC] def fill(path: Path2D): Unit +CanvasRenderingContext2D[JC] def fill(path: Path2D, fillRule: CanvasFillRule): Unit CanvasRenderingContext2D[JC] def fillRect(x: Double, y: Double, w: Double, h: Double): Unit CanvasRenderingContext2D[JC] var fillStyle: js.Any CanvasRenderingContext2D[JC] def fillText(text: String, x: Double, y: Double, maxWidth: Double?): Unit @@ -1098,8 +1105,9 @@ CanvasRenderingContext2D[JC] def getLineDash(): js.Array[Double] CanvasRenderingContext2D[JC] var globalAlpha: Double CanvasRenderingContext2D[JC] var globalCompositeOperation: String CanvasRenderingContext2D[JC] var imageSmoothingEnabled: Boolean -CanvasRenderingContext2D[JC] def isPointInPath(x: Double, y: Double): Boolean -CanvasRenderingContext2D[JC] def isPointInPath(x: Double, y: Double, fillRule: String): Boolean +CanvasRenderingContext2D[JC] def isPointInPath(path: Path2D, x: Double, y: Double): Boolean +CanvasRenderingContext2D[JC] def isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule): Boolean +CanvasRenderingContext2D[JC] def isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule?): Boolean CanvasRenderingContext2D[JC] var lineCap: String CanvasRenderingContext2D[JC] var lineDashOffset: Double CanvasRenderingContext2D[JC] var lineJoin: String @@ -1122,6 +1130,7 @@ CanvasRenderingContext2D[JC] var shadowColor: String CanvasRenderingContext2D[JC] var shadowOffsetX: Double CanvasRenderingContext2D[JC] var shadowOffsetY: Double CanvasRenderingContext2D[JC] def stroke(): Unit +CanvasRenderingContext2D[JC] def stroke(path: Path2D): Unit CanvasRenderingContext2D[JC] def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit CanvasRenderingContext2D[JC] var strokeStyle: js.Any CanvasRenderingContext2D[JC] def strokeText(text: String, x: Double, y: Double, maxWidth: Double?): Unit @@ -16627,6 +16636,17 @@ ParentNode[JT] def children: HTMLCollection[Element] ParentNode[JT] def firstElementChild: Element ParentNode[JT] def lastElementChild: Element ParentNode[JT] def replaceChildren(nodes: Node | String*): Unit +Path2D[JC] def addPath(path: Path2D): Unit +Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit +Path2D[JC] def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean): Unit +Path2D[JC] def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit +Path2D[JC] def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit +Path2D[JC] def closePath(): Unit +Path2D[JC] def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean?): Unit +Path2D[JC] def lineTo(x: Double, y: Double): Unit +Path2D[JC] def moveTo(x: Double, y: Double): Unit +Path2D[JC] def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit +Path2D[JC] def rect(x: Double, y: Double, w: Double, h: Double): Unit Pbkdf2Params[JT] val hash: HashAlgorithmIdentifier Pbkdf2Params[JT] val iterations: Double Pbkdf2Params[JT] val name: String diff --git a/dom/src/main/scala-2/org/scalajs/dom/CanvasFillRule.scala b/dom/src/main/scala-2/org/scalajs/dom/CanvasFillRule.scala new file mode 100644 index 000000000..bc3f98c58 --- /dev/null +++ b/dom/src/main/scala-2/org/scalajs/dom/CanvasFillRule.scala @@ -0,0 +1,14 @@ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +sealed trait CanvasFillRule extends js.Any + +object CanvasFillRule { + + val nonzero: CanvasFillRule = "nonzero".asInstanceOf[CanvasFillRule] + + val evenodd: CanvasFillRule = "evenodd".asInstanceOf[CanvasFillRule] + +} diff --git a/dom/src/main/scala-3/org/scalajs/dom/CanvasFillRule.scala b/dom/src/main/scala-3/org/scalajs/dom/CanvasFillRule.scala new file mode 100644 index 000000000..f72f2d9e9 --- /dev/null +++ b/dom/src/main/scala-3/org/scalajs/dom/CanvasFillRule.scala @@ -0,0 +1,13 @@ +package org.scalajs.dom + +import scala.scalajs.js + +opaque type CanvasFillRule <: String = String + +object CanvasFillRule { + + val nonzero: CanvasFillRule = "nonzero" + + val evenodd: CanvasFillRule = "evenodd" + +} diff --git a/dom/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala b/dom/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala index db0207e84..6c379819e 100644 --- a/dom/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala +++ b/dom/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala @@ -77,41 +77,62 @@ class CanvasRenderingContext2D extends js.Object { /** Restores the drawing style state to the last element on the 'state stack' saved by save(). */ def restore(): Unit = js.native + /** Resets the current transform to the identity matrix, and then invokes the transform() method with the same + * arguments. + */ def setTransform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit = js.native /** Saves the current drawing style state using a stack so you can revert any change you make to it using restore(). */ def save(): Unit = js.native + /** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle, + * ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise). + */ def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, - anticlockwise: Boolean): Unit = js.native + counterclockwise: Boolean): Unit = js.native - /** Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at - * endAngle going in the given direction by anticlockwise (defaulting to clockwise). + /** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle, + * ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise). */ def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native + /** Returns a TextMetrics object. */ def measureText(text: String): TextMetrics = js.native - def isPointInPath(x: Double, y: Double, fillRule: String): Boolean = js.native + /** Reports whether or not the specified point is contained in the current path. */ + def isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule = js.native): Boolean = js.native + + /** Reports whether or not the specified point is contained in the current path. */ + def isPointInPath(path: Path2D, x: Double, y: Double): Boolean = js.native /** Reports whether or not the specified point is contained in the current path. */ - def isPointInPath(x: Double, y: Double): Boolean = js.native + def isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule): Boolean = js.native + /** Adds a quadratic Bézier curve to the current path. */ def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native + /** Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels + * from that rectangle are painted. + */ def putImageData(imagedata: ImageData, dx: Double, dy: Double, dirtyX: Double = js.native, dirtyY: Double = js.native, dirtyWidth: Double = js.native, dirtyHeight: Double = js.native): Unit = js.native + /** Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is + * expressed in radians. + */ def rotate(angle: Double): Unit = js.native + /** Draws (fills) a given text at the given (x, y) position. */ def fillText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit = js.native /** Moves the origin point of the context to (x, y). */ def translate(x: Double, y: Double): Unit = js.native + /** Adds a scaling transformation to the canvas units by x horizontally and by y vertically. */ def scale(x: Double, y: Double): Unit = js.native + /** Creates a radial gradient given by the coordinates of the two circles represented by the parameters. */ def createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double, r1: Double): CanvasGradient = js.native @@ -122,13 +143,22 @@ class CanvasRenderingContext2D extends js.Object { def getLineDash(): js.Array[Double] = js.native /** Fills the subpaths with the current fill style. */ - def fill(): Unit = js.native + def fill(fillRule: CanvasFillRule = js.native): Unit = js.native + + /** Fills the subpaths with the current fill style. */ + def fill(path: Path2D): Unit = js.native + + /** Fills the subpaths with the current fill style. */ + def fill(path: Path2D, fillRule: CanvasFillRule): Unit = js.native /** Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are * transparent black. */ def createImageData(imageDataOrSw: js.Any, sh: Double = js.native): ImageData = js.native + /** Creates a pattern using the specified image. It repeats the source in the directions specified by the repetition + * argument. This method returns a CanvasPattern. + */ def createPattern(image: HTMLElement, repetition: String): CanvasPattern = js.native /** Tries to draw a straight line from the current point to the start. If the shape has already been closed or has @@ -136,12 +166,23 @@ class CanvasRenderingContext2D extends js.Object { */ def closePath(): Unit = js.native + /** Creates a path for a rectangle at position (x, y) with a size that is determined by width and height. */ def rect(x: Double, y: Double, w: Double, h: Double): Unit = js.native /** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the * clipping path only. For an example, see Clipping paths in the Canvas tutorial. */ - def clip(fillRule: String = js.native): Unit = js.native + def clip(fillRule: CanvasFillRule = js.native): Unit = js.native + + /** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the + * clipping path only. For an example, see Clipping paths in the Canvas tutorial. + */ + def clip(path: Path2D): Unit = js.native + + /** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the + * clipping path only. For an example, see Clipping paths in the Canvas tutorial. + */ + def clip(path: Path2D, fillRule: CanvasFillRule): Unit = js.native /** Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black. */ @@ -158,6 +199,7 @@ class CanvasRenderingContext2D extends js.Object { /** Draws a filled rectangle at (x, y) position whose size is determined by width and height. */ def fillRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + /** Adds a cubic Bézier curve to the current path. */ def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit = js.native /** Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in @@ -167,18 +209,23 @@ class CanvasRenderingContext2D extends js.Object { height: Double = js.native, canvasOffsetX: Double = js.native, canvasOffsetY: Double = js.native, canvasImageWidth: Double = js.native, canvasImageHeight: Double = js.native): Unit = js.native + /** Multiplies the current transformation matrix with the matrix described by its arguments. */ def transform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit = js.native /** Strokes the subpaths with the current stroke style. */ def stroke(): Unit = js.native + def stroke(path: Path2D): Unit = js.native + /** Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using * the current stroke style. */ def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + /** Sets the current line dash pattern. */ def setLineDash(segments: js.Array[Double]): Unit = js.native + /** Draws (strokes) a given text at the given (x, y) position. */ def strokeText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit = js.native /** Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path. */ @@ -187,12 +234,13 @@ class CanvasRenderingContext2D extends js.Object { /** Adds an arc with the given control points and radius, connected to the previous point by a straight line. */ def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native + /** Creates a linear gradient along the line given by the coordinates represented by the parameters. */ def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient = js.native /** The ellipse() method creates an elliptical arc centered at (x, y) with the radii radiusX and radiusY. The path - * starts at startAngle and ends at endAngle, and travels in the direction given by anticlockwise (defaulting to + * starts at startAngle and ends at endAngle, and travels in the direction given by counterclockwise (defaulting to * clockwise). */ def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, - endAngle: Double, anticlockwise: Boolean = js.native): Unit = js.native + endAngle: Double, counterclockwise: Boolean = js.native): Unit = js.native } diff --git a/dom/src/main/scala/org/scalajs/dom/Path2D.scala b/dom/src/main/scala/org/scalajs/dom/Path2D.scala new file mode 100644 index 000000000..7038efdb2 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/Path2D.scala @@ -0,0 +1,64 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation.JSGlobal + +/** The [[Path2D]] interface of the Canvas 2D API is used to declare a path that can then be used on a + * [[CanvasRenderingContext2D]] object. The path methods of the [[CanvasRenderingContext2D]] interface are also present + * on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. + */ +@js.native +@JSGlobal +class Path2D extends js.Object { + + /** Adds a path to the current path. */ + def addPath(path: Path2D): Unit = js.native + + /** Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line + * from the current point to the start. If the shape has already been closed or has only one point, this function + * does nothing. + */ + def closePath(): Unit = js.native + + /** Moves the starting point of a new sub-path to the (x, y) coordinates. */ + def moveTo(x: Double, y: Double): Unit = js.native + + /** Connects the last point in the subpath to the (x, y) coordinates with a straight line. */ + def lineTo(x: Double, y: Double): Unit = js.native + + /** Adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the + * third one is the end point. The starting point is the last point in the current path, which can be changed using + * moveTo() before creating the Bézier curve. + */ + def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit = js.native + + /** Adds a quadratic Bézier curve to the current path. */ + def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native + + /** Adds a circular arc to the path with the given control points and radius, connected to the previous point by a + * straight line. + */ + def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native + + /** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle, + * ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise). + */ + def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, + counterclockwise: Boolean): Unit = js.native + + /** The arc() method creates a circular arc centered at (x, y) with a radius of radius. The path starts at startAngle, + * ends at endAngle, and travels in the direction given by counterclockwise (defaulting to clockwise). + */ + def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native + + /** The ellipse() method creates an elliptical arc centered at (x, y) with the radii radiusX and radiusY. The path + * starts at startAngle and ends at endAngle, and travels in the direction given by counterclockwise (defaulting to + * clockwise). + */ + def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, + endAngle: Double, counterclockwise: Boolean = js.native): Unit = js.native + + /** Creates a path for a rectangle at position (x, y) with a size that is determined by width and height. */ + def rect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + +}