The Basics
Draws a point at (x,y) with the provided color.
// with integers
Draw(5, 5, olc::WHITE);
// with the olc::vi2d
Draw(olc::vi2d{5, 5}, olc::WHITE);
Color: Color has a default value of olc::WHITE
Draws a line from the point (x1,y1) to (x2,y2) with the provided color.
// with integers
DrawLine(10, 10, 20, 20, olc::WHITE);
// with olc::vi2d
DrawLine(olc::vi2d{10, 10}, olc::vi2d{20, 20}, olc::WHITE);
Color: Color has a default value of olc::WHITE
Draws a circle at the point (x,y) with provided radius and color.
// with integers
DrawCircle(10, 10, 20, olc::WHITE);
FillCircle(10, 10, 20, olc::WHITE);
// with olc::vi2d
DrawCircle(olc::vi2d{10, 10}, 20, olc::WHITE);
FillCircle(olc::vi2d{10, 10}, 20, olc::WHITE);
Color: Color has a default value of olc::WHITE
Draws or fills a rectangle at the point (x,y) with the provide width, height, and color.
// with integers
DrawRect(10, 10, 20, 20, olc::WHITE);
FillRect(10, 10, 20, 20, olc::WHITE);
// with old::vi2d
DrawRect(olc::vi2d{10, 10}, olc::vi2d{20, 20}, olc::WHITE);
FillRect(olc::vi2d{10, 10}, olc::vi2d{20, 20}, olc::WHITE);
Color: Color has a default value of olc::WHITE
Draws or fills a triangle between points (x1,y1), (x2,y2) and (x3,y3)
// with integers
DrawTriangle(10, 30, 30, 10, 50, 30, olc::WHITE);
FillTriangle(10, 30, 30, 10, 50, 30, olc::WHITE);
// with olc::vi2d
DrawTriangle(olc::vi2d{10, 30}, olc::vi2d{30, 10}, olc::vi2d{50, 30}, olc::WHITE);
FillTriangle(olc::vi2d{10, 30}, olc::vi2d{30, 10}, olc::vi2d{50, 30}, olc::WHITE);
Color: Color has a default value of olc::WHITE
Draws a single line of text - traditional monospaced
// with integers
DrawString(10, 10, "Hello, World", olc::WHITE, 1);
// with olc::vi2d
DrawString(olc::vi2d{10, 10}, "Hello, World", olc::WHITE, 1);
Color: Color has a default value of olc::WHITE
Scale: Scale has a default value of 1
For convenience, there’s also function to calculate the pixel size of a given string. This is the traditional monospaced version.
olc::vi2d textSize = GetTextSize("Hello, World");
The textSize.x
property will contain the width.
The textSize.y
property will contain the height.
Note: this function does not account for scaling.
Draws a single line of text - non-monospaced
// with integers
DrawStringProp(10, 10, "Hello, World", olc::WHITE);
// with olc::vi2d
DrawStringProp(olc::vi2d{10, 10}, "Hello, World", olc::WHITE);
For convenience, there’s also function to calculate the pixel size of a given string. This is the non-monospaced version.
olc::vi2d textSize = GetTextSizeProp("Hello, World");
The textSize.x
property will contain the width.
The textSize.y
property will contain the height.
Note: this function does not account for scaling.