Anima

A microframework for drawing.


(load "anima.carp")
(use Anima)

(defn setup [rend]
  (framerate 0)) ; shortcut for a static sketch

(defn draw [rend]
  (do
    (color rend 255)
    (line rend 0 0 800 800)))

(defsketch "One line to rule them all" 800 800
  setup
  draw)

Function Reference

background

external

(Fn [Int] ())

Set the current background color to color. The color can have 1 component (greyscale, from 0 to 255), three components (RGB value, from 0 to 255), or 4 components (RGBA value, from 0 to 255).

Warning: This will also clear the screen with that color.

color

external

(Fn [Int] ())

Set the current drawing color to color. The color can have 1 component (greyscale, from 0 to 255), three components (RGB value, from 0 to 255), or 4 components (RGBA value, from 0 to 255).

defsketch

external

(Fn [&String Int Int (Fn [SDL_Renderer] ())] ())

Create a sketch with a name, width, height, and setup function. Optionally takes a draw and state function as well.

framerate

defn

(λ [Int] ())

Set the framerate to n per second.

hsb-to-rgb

defn

(λ [Int, Int, Int] (Array Int))

Convert a three-component HSB color to an RGB color array.

line

defn

(λ [(Ptr SDL_Renderer), Int, Int, Int, Int] ())

Draw a line from (ax, ay) to (bx, by).

rand

defn

(λ [Int] Int)

Generate a random integer from 0 to i.

random-between

defn

(λ [Int, Int] Int)

Generate a random integer from min to max.

rect

defn

(λ [(Ptr SDL_Renderer), Int, Int, Int, Int] ())

Draw a rectangle with (ax, ay) as origin, w as width, and h as height.