Packages

c

org.scalajs.dom

CanvasRenderingContext2D

class CanvasRenderingContext2D extends Object

The 2D rendering context for the drawing surface of a <canvas> element. To get this object, call getContext() on a <canvas>, supplying "2d" as the argument:

Annotations
@JSType() @native() @JSGlobal()
Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CanvasRenderingContext2D
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new CanvasRenderingContext2D()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit

    The arc() method creates a circular arc centered at (x, y) with a radius of radius.

    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).

  5. def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean): Unit

    The arc() method creates a circular arc centered at (x, y) with a radius of radius.

    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).

  6. def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit

    Adds an arc with the given control points and radius, connected to the previous point by a straight line.

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def beginPath(): Unit

    Starts a new path by resetting the list of sub-paths.

    Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path.

  9. def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit

    Adds a cubic Bézier curve to the current path.

  10. var canvas: HTMLCanvasElement

    Back-reference to the canvas element for which this context was created.

    Back-reference to the canvas element for which this context was created. Read only.

  11. def clearRect(x: Double, y: Double, w: Double, h: Double): Unit

    Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black.

  12. def clip(path: Path2D, fillRule: CanvasFillRule): Unit

    Creates a clipping path from the current sub-paths.

    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.

  13. def clip(path: Path2D): Unit

    Creates a clipping path from the current sub-paths.

    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.

  14. def clip(fillRule: CanvasFillRule = js.native): Unit

    Creates a clipping path from the current sub-paths.

    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.

  15. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  16. def closePath(): Unit

    Tries to draw a straight line from the current point to the start.

    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.

  17. def createImageData(imageDataOrSw: Any, sh: Double = js.native): ImageData

    Creates a new, blank ImageData object with the specified dimensions.

    Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are transparent black.

  18. def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient

    Creates a linear gradient along the line given by the coordinates represented by the parameters.

  19. def createPattern(image: HTMLElement, repetition: String): CanvasPattern

    Creates a pattern using the specified image.

    Creates a pattern using the specified image. It repeats the source in the directions specified by the repetition argument. This method returns a CanvasPattern.

  20. def createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double, r1: Double): CanvasGradient

    Creates a radial gradient given by the coordinates of the two circles represented by the parameters.

  21. def drawImage(image: HTMLElement, offsetX: Double, offsetY: Double, width: Double = js.native, height: Double = js.native, canvasOffsetX: Double = js.native, canvasOffsetY: Double = js.native, canvasImageWidth: Double = js.native, canvasImageHeight: Double = js.native): Unit

    Draws the specified image.

    Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.

  22. def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, endAngle: Double, counterclockwise: Boolean = js.native): Unit

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

    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).

  23. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  25. def fill(path: Path2D, fillRule: CanvasFillRule): Unit

    Fills the subpaths with the current fill style.

  26. def fill(path: Path2D): Unit

    Fills the subpaths with the current fill style.

  27. def fill(fillRule: CanvasFillRule = js.native): Unit

    Fills the subpaths with the current fill style.

  28. def fillRect(x: Double, y: Double, w: Double, h: Double): Unit

    Draws a filled rectangle at (x, y) position whose size is determined by width and height.

  29. var fillStyle: Any

    A CSS color, a CanvasGradient or CanvasPattern, to use as a fill.

  30. def fillText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit

    Draws (fills) a given text at the given (x, y) position.

  31. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  32. var font: String

    Default value 10px sans-serif

  33. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  34. def getImageData(sx: Double, sy: Double, sw: Double, sh: Double): ImageData

    Returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by the rectangle which starts at (sx, sy) and has an sw width and sh height.

  35. def getLineDash(): Array[Double]

    Returns a dash list array containing an even number of non-negative numbers.

  36. var globalAlpha: Double

    Alpha value that is applied to shapes and images before they are composited onto the canvas.

    Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque).

  37. var globalCompositeOperation: String

    With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap.

    With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap. Possible values: source-atop source-in source-out source-over (default) destination-atop destination-in destination-out destination-over lighter darker copy xor

  38. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  39. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  40. var imageSmoothingEnabled: Boolean

    A boolean value indicating whether to smooth scaled images or not.

    A boolean value indicating whether to smooth scaled images or not. The default value is true.

  41. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  42. def isPointInPath(path: Path2D, x: Double, y: Double, fillRule: CanvasFillRule): Boolean

    Reports whether or not the specified point is contained in the current path.

  43. def isPointInPath(path: Path2D, x: Double, y: Double): Boolean

    Reports whether or not the specified point is contained in the current path.

  44. def isPointInPath(x: Double, y: Double, fillRule: CanvasFillRule = js.native): Boolean

    Reports whether or not the specified point is contained in the current path.

  45. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  46. var lineCap: String

    Type of endings on the end of lines.

    Type of endings on the end of lines. Possible values: butt (default), round, square

  47. var lineDashOffset: Double

    Specifies where to start a dasharray on a line.

  48. var lineJoin: String

    Defines the type of corners where two lines meet.

    Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default)

  49. def lineTo(x: Double, y: Double): Unit

    Connects the last point in the subpath to the x, y coordinates with a straight line.

  50. var lineWidth: Double

    Width of lines.

    Width of lines. Default 1.0

  51. def measureText(text: String): TextMetrics

    Returns a TextMetrics object.

  52. var miterLimit: Double

    Default 10

  53. def moveTo(x: Double, y: Double): Unit

    Moves the starting point of a new subpath to the (x, y) coordinates.

  54. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  55. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  56. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  57. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  58. 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

    Paints data from the given ImageData object onto the bitmap.

    Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted.

  59. def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit

    Adds a quadratic Bézier curve to the current path.

  60. def rect(x: Double, y: Double, w: Double, h: Double): Unit

    Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.

  61. def restore(): Unit

    Restores the drawing style state to the last element on the 'state stack' saved by save().

  62. def rotate(angle: Double): Unit

    Adds a rotation to the transformation matrix.

    Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is expressed in radians.

  63. def save(): Unit

    Saves the current drawing style state using a stack so you can revert any change you make to it using restore().

  64. def scale(x: Double, y: Double): Unit

    Adds a scaling transformation to the canvas units by x horizontally and by y vertically.

  65. def setLineDash(segments: Array[Double]): Unit

    Sets the current line dash pattern.

  66. def setTransform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit

    Resets the current transform to the identity matrix, and then invokes the transform() method with the same arguments.

  67. var shadowBlur: Double

    Specifies the blurring effect.

    Specifies the blurring effect. Default 0

  68. var shadowColor: String

    Color of the shadow.

    Color of the shadow. Default fully-transparent black.

  69. var shadowOffsetX: Double

    Horizontal distance the shadow will be offset.

    Horizontal distance the shadow will be offset. Default 0.

  70. var shadowOffsetY: Double

    Vertical distance the shadow will be offset.

    Vertical distance the shadow will be offset. Default 0.

  71. def stroke(path: Path2D): Unit
  72. def stroke(): Unit

    Strokes the subpaths with the current stroke style.

  73. def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit

    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.

  74. var strokeStyle: Any

    A CSS color, a CanvasGradient or CanvasPattern, to use as a line around shapes.

  75. def strokeText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit

    Draws (strokes) a given text at the given (x, y) position.

  76. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  77. var textAlign: String

    Possible values: start (default), end, left, right or center.

  78. var textBaseline: String

    Possible values: top, hanging, middle, alphabetic (default), ideographic, bottom

  79. def toLocaleString(): String
    Definition Classes
    Object
  80. def toString(): String
    Definition Classes
    AnyRef → Any
  81. def transform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit

    Multiplies the current transformation matrix with the matrix described by its arguments.

  82. def translate(x: Double, y: Double): Unit

    Moves the origin point of the context to (x, y).

  83. def valueOf(): Any
    Definition Classes
    Object
  84. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  85. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  86. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped