A[asciilib] Colors

This commit is contained in:
2021-04-24 14:59:24 -06:00
parent fe4e2cc509
commit 3cebeb1a70
8 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
-lib kiss
-cp src
--main Main
--interp

View File

@@ -0,0 +1,8 @@
package;
import kiss.Kiss;
import kiss.Prelude;
import asciilib.Surface;
@:build(kiss.Kiss.build("src/Main.kiss"))
class Main {}

View File

@@ -0,0 +1,2 @@
(defun :Void main []
(print "Hello world!"))

View File

@@ -0,0 +1,16 @@
package asciilib;
import haxe.io.Bytes;
import kiss.Prelude;
typedef Color = {
r:Int,
g:Int,
b:Int,
}
/**
* The Colors class represents a 2D grid of colors. Under the hood, it's byte channels
*/
@:build(kiss.Kiss.build("src/asciilib/Colors.kiss"))
class Colors {}

View File

@@ -0,0 +1,17 @@
(defnew [_width _height &opt :Color fillColor]
[:Int width _width
:Int height _height
:Int area (* width height)
:Bytes red (Bytes.alloc area)
:Bytes green (Bytes.alloc area)
:Bytes blue (Bytes.alloc area)]
(unless fillColor (set fillColor Black))
(fill fillColor))
(defmethod fill [:Color color]
(red.fill 0 area color.r)
(green.fill 0 area color.g)
(blue.fill 0 area color.b))
(defvar Black (object r 0 g 0 b 0))

View File

@@ -0,0 +1,6 @@
package asciilib;
import asciilib.Colors;
@:build(kiss.Kiss.build("src/asciilib/Surface.kiss"))
class Surface {}

View File

@@ -0,0 +1,3 @@
#! /bin/bash
haxe build.hxml