spade-0.1.0.9: docs/functions/graphics.md
### Graphics Functions
##### graphics
Starts the graphics mode. The argument here is an optional boolean. A true value indicates the graphics will use acceleration.
In accelerated graphics mode, screen is only updated on #link: render#
```
graphics(true)
```
#### graphicswindow
Starts the graphics windowed mode. The first two arguments decides the width and height of the window. The third argument decides if the display is accelerated.
Example:
```
graphicswindow(400, 200, true)
```
#### render
Draws everything to the screen at once.
#### point
Turns the pixel at given cordinates on, with the current drawing color.
use #link: setcolor# to set drawing color.
#### points
Turns the pixels at the given coordinates on, with current drawing color. The arguments is a single list where each element is inturn a list with only two values representing x and y co-ordinates.
use #link: setcolor# to set drawing color.
Example:
```
points([[100, 100], [200, 200]])
```
#### line
Draws a line from the specified co-ordinates. First and second arguments represents x and y co-ordinates of the starting point, and the third and fourth arguments represents co-ordinates of the end point.
Example:
```
line(100, 100, 200, 200)
```
#### lines
Draws a sequence of lines from a list of points. Each point is represented by a list of two numbers, first one representing the x coordinate and the second one representing the y-coordinate.
use #link: setcolor# to set drawing color.
Example:
```
lines([[100, 100], [200, 200]])
```
#### box
Draws a rectangle in current color. As with the #link: line# function the arguments represents the co-ordinates of the top left and bottom right corners.
use #link: setcolor# to set drawing color.
Example:
```
box(100, 100, 20, 30)
```
#### circle
Draws a circle that can be optionally filled.
use #link: setcolor# to set drawing color.
Example:
```
circle(100, 100, 20)
```
#### smoothcircle
Similar to #link: circle# function, but draws an smooth (antialiased)
circle.
#### ellipse
Draws an ellipse which can be optionally filled.
#### smoothellipse
Draws a smooth (antialiased) ellipse.
#### arc
Similar to #link: circle#, but draws an arc.
#### pie
Similar to #link: arc#, but draws a pie shape.
#### polygon
Draws a polygon taking a list of points as input. The last point is joined with the first one, closing the polygon. The second optional argument specifies wether the polygon should be filled.
Sample:
```
polygon([[100, 100], [150, 50], [200, 100]])
```
#### smoothpolygon
Same as #link: polygon#, but draws an anti-aliased polygon, and does not have the option to draw filled polygon.
#### setbgcolor
Sets the current background color using red, green and blue component values. The function #link: clearscreen# will use this color to clear the screen.
#### setcolor
Sets the current drawing color using red, green and blue component values.
#### setcolora
Sets the current drawing color using red, green, blue and transparency component values.
#### clearscreen
Fills the graphics screen with current background color.
Example:
```
setbgcolor(255, 0, 0)
clearscreen() -- paints the entire screen red.
```
#### getwindowsize
Gets the dimensions of the graphics window.
Example:
```
graphics()
let windowsize = getwindowsize()
println(windowsize.width)
println(windowsize.height)
```
#### setlogicalsize
Sets the logical size of the display, so that things being drawn on screen are scaled to fit the entire dimensions of actual display. Check #link: Graphics and Animation# to read more about using this function.
#### gwaitforkey
Suspends the program till a key is pressed when the graphics window has focus. Use #link: waitforkey#
to wait for key press when running in a terminal window.
##### loadtexture
Loads a bitmap file into a texture.
##### setfont
Sets the default font and font-size that will be used by text rendering
functions.
##### loadfont
Load a font and return it. First argument is the point size of the target font. The second optional argument is the path to the font file (.ttf or .otf) file. If it is not provided, a default font will be used.
##### texttotexture
Creates a texture from text
##### destroytexture
Destroys a loaded texture.
##### drawtextat
Draw text at the provided location using the currently active font (set using #link: setfont#)
and active color.
##### drawtextrotatedat
Draw rotated text at the provided location and angle using the currently active font (set using #link: setfont#)
and active color.
##### copytexture
Copy a texture to default renderer at the the specified position.
##### copytexturepart
Copy a texture partially to default renderer at the the specified position.
##### copytexturerotated
Copy a texture after rotating/flipping to default renderer at the the specified position.
##### textureinfo
Get dimensions of the texture.