Lab 1 Shape Drawer
Functions | Variables
lab1.cpp File Reference
#include <iostream>
#include <fstream>
Include dependency graph for lab1.cpp:

Functions

void start ()
 
void go (int x, int y)
 
void setColor (string color)
 
void drawRectangle (int width, int height)
 
void drawCircle (int radius)
 
void end ()
 
 

Function Documentation

◆ drawCircle()

void drawCircle ( int  r)

Draws a circle where the pen currently is with radius r filled with whatever color is currently set.

Example: drawCircle(10); will draw a circle with radius 10 with an origin wherever the pen is.

Parameters
rThe radius of the circle to draw.

◆ drawRectangle()

void drawRectangle ( int  width,
int  height 
)

Draws a rectangle with the upper left corner where the pen currently is with the given height and width and filled with whatever color is currently set.

Example: drawRectangle(2, 5); will draw a rectangle with width 2 and height 5.

Parameters
widthThe width of the rectangle to draw.
heightThe height of the rectangle to draw.

◆ end()

void end ( )

Indicates the end of your drawing. Call it like this: end();

◆ go()

void go ( int  x,
int  y 
)

Moves the pen's position to the given coordinate.

Example: go(10, 5); will cause the pen's position to change to the (x,y) coordinate (10,5). Note that (0,0) is the upper left of the screen (so y increases the further down the screen you move).

Parameters
xThe x coordinate to move to.
yThe y coordinate to move to.

◆ setColor()

void setColor ( string  color)

Sets the fill color. Call this before drawing a shape to fill it with this color.

Example: setColor("#555555"); will set the color to #555555 (dark gray).

Parameters
colorThe hexadecimal color code to set.

◆ start()

void start ( )

Indicates the start of your drawing. Call it like this: start();