toyGraphics / com.anysolo.toyGraphics / Window


open class Window

The graphic window of your program.

The window you draw on. You must create exactly one window in you program.

By default all you drawing immediately appears on the window. If you writing a game it will be a lot of flickering. The better way is to pass parameter buffered=true. In this case you draw on a memory buffer. When you done drawing you call method close() from your Graphics object and all your drawing pushed to the screen.

Actually in buffered mode Window may use 2 or 3 buffers. Image you created pushes through all the buffers until it reaches the screen. It means you may see the result on the screen with 2 or frames delay.



Window(width: Int, height: Int, background: Color = Pal16.white, buffered: Boolean = false, autoSync: Boolean = !buffered)

The graphic window of your program.



val autoSync: Boolean

Call sync() automatically after any drawing operation.


val buffered: Boolean

Buffered mode. Set it to true if you need to draw fast and without flickering.


val height: Int

Height in pixels.


val width: Int

Width in pixels.



fun close(): Unit

Closes the window.


fun sync(): Unit

It means program does not draw anything else until the current drawing operation is visible on the screen.