toyGraphics / com.anysolo.toyGraphics / Graphics

Graphics

class Graphics : Closeable

Use this class to draw on a window.

Constructors

<init>

Graphics(window: Window)

Use this class to draw on a window.

Properties

backgroundColor

var backgroundColor: Color

Background color.

color

var color: Color

Color of the pen.

window

val window: Window

Functions

clear

fun clear(): Unit

Fills the window with background color

close

fun close(): Unit

Finish drawing.

drawDot

fun drawDot(x: Int, y: Int): Unit

Draws a dot.

drawImage

fun drawImage(x: Int, y: Int, image: Image): Unit

Draws an image.

fun drawImage(x: Int, y: Int, image: Image, angle: Double, anchorx: Int = 0, anchory: Int = 0): Unit

Draws rotated image.

drawLine

fun drawLine(x1: Int, y1: Int, x2: Int, y2: Int): Unit

Draws line from x1,y1 to x2,y2.

drawOval

fun drawOval(x: Int, y: Int, width: Int, height: Int, fill: Boolean = false): Unit

Draws oval inside invisible rect.

drawRect

fun drawRect(x: Int, y: Int, width: Int, height: Int, fill: Boolean = false): Unit

Draws a rect.

drawText

fun drawText(x: Int, y: Int, string: String): Unit

Draws the text.

setFontSize

fun setFontSize(size: Int): Unit

Change size of the current font

setStrokeWidth

fun setStrokeWidth(width: Int): Unit

Change current width of lines and size of dots

Extension Functions

drawAnimation

fun Graphics.drawAnimation(x: Int, y: Int, animation: Animation): Unit

Draws current frame from animation.

fun Graphics.drawAnimation(x: Int, y: Int, animation: Animation, angle: Double, anchorx: Int = 0, anchory: Int = 0): Unit

Draws rotated animation.