h
Basic Commands and Drawing Shapes
First thing is first when trying out the Instinct Graphics Package. Let’s learn what is needed to be set up prior to drawing anything.
Starting Code to Use
To begin coding a Instinct Graphics Package program, you must first have at least this starting code set up:
#include "instinct.h" int instinct_main() { return 0; }
The Instinct Project folder will have this already precoded. However if you are coding this from scratch you must type the code above.
The “instinct_main()“ function acts similar to the standard “int main()“ function that console programs use.
Shapes
There are different ways to draw shapes to the screen. The shapes we can draw are:
- Point
- Line
- Circle
- Rect
- Triangle
- Message

The constructors you can use for each are as follows:
- Point(double x, double y)
- Line(Point start, Point end)
- Circle(Point center, double radius)
- Rect(Point lower_left, double width, double height)
- Triangle(Point p1, Point p2, Point p3)
- Message(Point lower_left, string text)
Colors
The Colors that are available to use on the shapes are:

The default color for shapes is BLACK. Each object can use the “set_color(Color color)“ member function to change their color.
Example:
- pt.set_color(BLUE);
- line2.set_color(GREEN);
- circ.set_color(YELLOW);
- etc.
Or you can add an extra parameter to the end of any of the shape constructors to specify their starting color instead.
Example:
- Circle circ = Circle(Point(5, 5), 2, YELLOW);
- Line l2 = Line(Point(0, 0), Point(5, 5), ORANGE);
Filling in Objects with Color

All the objects except the Line can either be outlined or filled in with color. To set whether a object is filled in with color or not, you can use the “set_filled_in(bool is_filled)“member function.
Example:
- circ.set_filled_in(true);
- rect.set_filled_in(false);
- etc.
So the Circle circ will be filled in with it’s color while the Rect rect will only be outlined with it’s color.
Similarly to the colors, you can add that parameter to the end of a constructor if the constructor already has the color included.
Example:
- Circle circ = Circle(Point(5, 5), 2, YELLOW, true);
- Rect rect = Rect(Point(1, 2), 5, 5, BLUE, true);
So both the Circle circ and the Rect rect will be filled in with color since they added true after the color argument in their constructors.
The “win” Object
When it comes to manipulating the window or drawing shapes to the window, you must use the “win” object that is already created. We will use the “win” object to draw shapes, change the background color, get user input, play audio, etc.
Drawing and Outputting Shapes
To actually draw shapes to the window, first you have to add them to the window buffer. You do this by using the insertion operator on the “win” object.
Example:
- win << circ;
- win << rect;
This adds the Circle circ and then the Rect rect onto the windows drawing buffer. You can add more than one object to the buffer at a time.
Example:
- win << circ << rect << line2;
- win << pt << triangle;
Then once you are ready to draw everything in the buffer, use the “win.output_buffer()” command to output everything in the buffer to the screen.
Example:
- win << circ << rect;
win << line3 << pt2;
win.output_buffer();
The above example in lines 1 and 2 add Circle circ, Rect rect, Line line3, and Point pt2 onto the buffer to be drawn. Then the final line outputs all of the shapes that we just put in the buffer (as well as any other shapes that were previously in the buffer) onto the screen all at once.
Changing the Background Color
To change the background color of the window, you must use the “win.set_background_color(Color color);“ function.
Example:
- win.set_background_color(BLACK);
- win.set_background_color(RED);

So the first example above will change the background color of the window to BLACK. Be careful when changing the background that you do not draw any shapes the same color as the background. If you set the background to BLACK, any BLACK shapes won’t be seen on the background.
Changing the Title on the Program
The last little thing you can do to your program is change the title of your window. You do this by using the “win.set_title(string new_title)“ function.
Example:
- win.set_title(“My Cool Program”);
- win.set_title(“Space Wars!”);

So that’s all the basics for drawing shapes, colors, outputting, and changing the title.