oters_gui 0.1.0

Graphical library definitions for the oters programming language
Documentation
use gui::shape::*
use gui::image::*
use gui::input::*
use gui::Color

let line = (draw_shape (Shape::Line((80,80), (140, 140), 4, Color {r: 255, g: 255, b: 0, a: 255}))) << @line
let circle = (draw_shape (Shape::Circle((100,100), 20, Color {r: 0, g: 255, b: 0, a: 255}))) << @circle
let triangle = (draw_shape (Shape::Triangle((140,140), (100, 140), (120, 120), Color {r: 0, g: 0, b: 255, a: 255}))) << @triangle
let rect = (draw_shape (Shape::Rect((100,100), (40, 40), Color {r: 255, g: 0, b: 0, a: 255}))) << @rect

let angles = {
  let aux = fn n -> n << @(aux (n+0.05));
  aux 0.0
}

let nats = {
  let aux = fn n -> n << @(aux (n+1));
  aux 0
}

let otter_img = img_from_file "assets/otter.png"
let rot_img = fn img -> {
  let r = rotate_img (!#img, (std::stream::head angles));
  set_pixel (r, ((std::stream::head nats) % r.width, 100), Color {r: 255, g: 0, b: 0, a: 255});
  (draw_img (r, (0, 0), (r.width, r.height), (0, 0, r.width, r.height))) << @(rot_img #r)
}

let x = rot_img #otter_img

let on_x = 
  if is_key_down "X" then
    (draw_shape (Shape::Circle((600,400), 20, Color {r: 0, g: 0, b: 255, a: 255}))) << @on_x
  else
    () << @on_x
  
let cursor = (draw_shape (Shape::Circle(mouse_pos (), 5, Color {r: 0, g: 255, b: 0, a: 255}))) << @cursor