Sayed's Blog

drawlang > docs > users > library > canvas

Canvas

If you're used to HTML5 or Java Canvas, this is slightly different. There is no separate context class, everything is called on canvas.

  • arc(centerX, centerY, radiusX, radiusY, startAngle, length) - Creates arc from current path that uses Euclidean degrees.

  • arcTo(x1, y1, x2, y2, radius) - Creats arc from current path.

  • beginPath() - Resets current path to empty.

  • bezierCurveTo(xControl, yControl, xControl2, yControl2, xEnd, yEnd) - Creates cubic bezier curve from path postion to given end position using specified control positions.

  • clear() - Makes canvas transparent.

  • closePath() - Closes the path.

  • drawArc(x, y, width, height, startAngle, arcExtent, artType) - Draws an arc using current color. All of the parameters are numerical with the exception of the last one, which is a string that can only take the following values: ROUND, CHORD, OPEN.

  • drawCircle(x, y, radius) - Draws a circle with given position and radius using current color.

  • drawImage(image, x, y) - Draws image instance onto canvas at specified position.

  • drawLine(x, y, endX, endY) - Draws a line between given points using current color.

  • drawPath() - Outlines path with current color.

  • drawPolygon(xArray, yArray) - Draws a polygon with the given points using current color.

  • drawPolyline(xArray, yArray) - Draws a polyline with given points using current color.

  • drawRect(x, y, width, height) - Draws a rectangle with current color.

  • fillArc(x, y, width, height, startAngle, arcExtent, artType) - Fills an arc using current color. All of the parameters are numerical with the exception of the last one, which is a string that can only take the following values: ROUND, CHORD, OPEN.

  • fillCircle(x, y, radius) - Fills a circle with given position and radius using current color.

  • fillPath() - Fills path with current color.

  • fillPolygon(xArray, yArray) - Fills a polygon with the given points using current color.

  • fillRect(x, y, width, height) - Fills a rectangle with current color.

  • fillText(string, x, y) - Fills given text at given position using current color.

  • lineTo(x, y) - Creates line from current path to given position.

  • moveTo(x, y) - Moves path to given coordinates.

  • quadraticCurveTo(xControl, yControl, xEnd, yEnd) - Creates quadratic bezier curve from path position to given end position using specified control position.

  • setColor(color) - Sets current color.

  • setLineWidth(num) - Sets the current line width.

  • setPixel(x, y, color) - Sets color of specified point.

  • toImage() - Returns image representation of canvas.

    © 2023