diff --git a/docs/system.dj b/docs/system.dj index 1b9f474..e9a09f5 100644 --- a/docs/system.dj +++ b/docs/system.dj @@ -12,7 +12,8 @@ These descriptions read like this: stroke thickness : number color : rgba - position : vec + from : vec + to : vec -> scribble ``` @@ -28,13 +29,13 @@ The argument name usually does not matter when calling the function - it is only The argument _type_ however is important. If you try to use a function with the wrong type of value as its argument, it will fail with an error. -For example, consider a brush where we pass a number as `stroke`'s `color` and `position` arguments. +For example, consider a brush where we pass a bunch of numbers into `stroke`'s arguments. ```haku -stroke 1 1 1 +stroke 1 1 1 1 ``` -This brush will fail to render, since `stroke` expects an `rgba` as its 2nd argument. +This brush will fail to render, since `stroke` expects an `rgba` as its 2nd argument, and `vec`s as its 3rd and 4th arguments. With that said, there are several types of values in haku that can be passed into, and returned by functions. @@ -53,7 +54,7 @@ With that said, there are several types of values in haku that can be passed int - `scribble` - something that can be drawn on the wall. - `reticle` - an interaction the user can make with the wall. -The syntax `a | b` may be used to signify that one of the listed types is accepted or returned. +The syntax `a | b` may be used to signify that one of the listed types is accepted or returned. The following syntax: @@ -454,18 +455,13 @@ Note that `and` and `or` are currently missing from this list, but are reserved You can implement them using regular functions as a replacement. ```haku -boolAnd = \a, b -> - if (a) - if (b) True - else False - else False +and' = \a, b -> + if (a) b + else a -boolOr = \a, b -> - if (a) - True - else - if (b) True - else False +or' = \a, b -> + if (a) a + else b ``` @@ -594,7 +590,8 @@ Before scribbles are drawn to the wall, colors are converted to 8-bit integers f This means some loss of precision will happen, which may cause issues with brushes like this one: ```haku -stroke 128 #00000004 (vec 0 0) +withDotter \d -> + stroke 128 #00000004 d.From d.To ``` If you try to to use this brush to fill up a single spot with black, you will notice that despite all the math suggesting so, the color will end up gray instead. @@ -716,88 +713,19 @@ join: \a, b -> flatten [a, b] ``` -## Shapes - -```haku -toShape - value : _ - -> () | shape -``` - -Converts the given value to a shape. - -- For `shape`, clones the shape that was passed in. -- For `vec`, returns a point `shape`. -- For anything else, returns `()`. - -```haku -line - start : vec - end : vec - -> shape -``` - -Creates a line segment shape with the provided `start` and `end` points. - -```haku -rect - position : vec - size : vec - -> shape - -rect - x : number - y : number - width : number - height : number - -> shape -``` - -Creates a rectangle shape with its top-left corner at `position`, with a given `size` stretching from the top-left corner. - -The alternative 4-argument version takes in the rectangle's X/Y coordinates, width, and height as separate arguments instead of aggregating them into a `vec`. - -```haku -circle - center : vec - radius : number - -> shape - -circle - x : number - y : number - radius : number - -> shape -``` - -Creates a circle shape, with its center at `center`, with the provided radius. - -The alternative 3-argument version takes in the circle's center X/Y coordinates as separate arguments instead of aggregating them into a `vec`. - ## Scribbles ```haku stroke thickness : number color : rgba - shape : shapeLike + from : vec + to : vec -> scribble ``` -Creates a stroke scribble, which outlines the provided shape with a stroke of the given thickness and color. - -Point shapes are drawn as circles, and `line` shapes have round caps at the line's endpoints. - -```haku -fill - color : rgba - shape : shapeLike - -> scribble -``` - -Creates a fill scribble, which fills in the entire area of the provided shape with a solid color. - -Since this requires the shape to have a surface area, this does not do anything when point and `line` shapes are passed in. +Creates a stroke scribble, which draws a line between the two points `from` and `to`, with the provided `thickness` and `color`. +The line's caps are round, to make strokes connect neatly with each other. ## Reticles