packages feed

spade-0.1.0.7: 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.

Example:

```
render()
```

#### point

Turns the pixel at given cordinates on, with the current drawing color.

use #link: setcolor# to set drawing color.

Example:

```
point(100, 100)
```

#### points

Turns the pixels at the given coordinates on, with current drawing color.

use #link: setcolor# to set drawing color.

Example:

```
points([[100, 100], [200, 200]])
```

#### line


Draws a line from co-ordinates (100, 100) to (200, 200) using the current color
use #link: setcolor# to set drawing color.

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, with top left corner at co-ordinates (100,
100) and having 20 pixels wide and 30 pixel tall.

use #link: setcolor# to set drawing color.

Example:

```
box(100, 100, 20, 30)
```

#### circle

Draws a rectangle in current color, with center at co-ordinates (100,
100) and having a radius of 20 pixels.

use #link: setcolor# to set drawing color.

Example:

```
circle(100, 100, 20)
```

#### arc

```
arc(center_x, center_y, radius, start_angle, end_angle, fill)
```

Similar to #link: circle#, but draws an arc.

#### polygon

```
polygon(points, fill)
```

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]])
```


#### setcolor

Sets the current drawing color using red, green and blue component values.

Example:

```
setcolor(100, 10, 200)
```

#### clearscreen

Fills the graphics screen with current draw color.

Example:

```
setcolor(0, 0, 0)
clearscreen() -- paints the entire screen black.
```

#### getwindowsize

Gets the dimensions of the graphics window.

```
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.

#### waitforkey

Waits for the user to press a key when the graphics window is in focus.

Example:

```
waitforkey()
```

##### loadtexture

Loads a bitmap file into a texture.

##### destroytexture

Destroys a loaded texture.

##### 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.