Skip to content

🎨 Draw module

A module for drawing UI elements, such as rects.

đŸ”ĸ Types

[4]int{R, G, B, A} // for colors

ℹī¸ Usage

Note

For this you will need a renderer initialized.

For now this module is pretty basic. You can draw a rectangle using the DrawRect() function, passing X position, Y position, width & height, and an RGBA color (int array as described above).

myRect := renderer.DrawRect(0, 0, 0.8, 0.8, [4]int{255, 255, 255, 255}) // draws a white square

You can also use DrawLine() to draw line that goes from x1, y1 to x2, y2, and again, with a color.

myLine := renderer.DrawLine(0.5, 0.5, -0.5, -0.5, [4]int{255, 255, 255, 255})

You can also create them and render them later, using "New" instead of "Draw", with the same arguments.

myRect := renderer.NewRect(-0.4, -0.3, 0.4, 0.4, [4]int{67, 239, 189, 255})
myLine := renderer.NewLine(0.5, 0.5, -0.5, -0.5, [4]int{255, 255, 255, 255})

// then, when you feel like it, draw them
myRect.Draw();
myLine.Draw();

If you want to "clear" the window, you can use ClearColor(), passing a color that'll be used as the background of the window.

renderer.ClearColor([4]int{255, 255, 255, 255}) // flashbang!