update system docs to the new scribble API
This commit is contained in:
parent
56be35e063
commit
f86d1f30ee
1 changed files with 18 additions and 90 deletions
108
docs/system.dj
108
docs/system.dj
|
@ -12,7 +12,8 @@ These descriptions read like this:
|
||||||
stroke
|
stroke
|
||||||
thickness : number
|
thickness : number
|
||||||
color : rgba
|
color : rgba
|
||||||
position : vec
|
from : vec
|
||||||
|
to : vec
|
||||||
-> scribble
|
-> 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.
|
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.
|
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
|
```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.
|
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.
|
- `scribble` - something that can be drawn on the wall.
|
||||||
- `reticle` - an interaction the user can make with 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:
|
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.
|
You can implement them using regular functions as a replacement.
|
||||||
|
|
||||||
```haku
|
```haku
|
||||||
boolAnd = \a, b ->
|
and' = \a, b ->
|
||||||
if (a)
|
if (a) b
|
||||||
if (b) True
|
else a
|
||||||
else False
|
|
||||||
else False
|
|
||||||
|
|
||||||
boolOr = \a, b ->
|
or' = \a, b ->
|
||||||
if (a)
|
if (a) a
|
||||||
True
|
else b
|
||||||
else
|
|
||||||
if (b) True
|
|
||||||
else False
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -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:
|
This means some loss of precision will happen, which may cause issues with brushes like this one:
|
||||||
|
|
||||||
```haku
|
```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.
|
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
|
## Scribbles
|
||||||
|
|
||||||
```haku
|
```haku
|
||||||
stroke
|
stroke
|
||||||
thickness : number
|
thickness : number
|
||||||
color : rgba
|
color : rgba
|
||||||
shape : shapeLike
|
from : vec
|
||||||
|
to : vec
|
||||||
-> scribble
|
-> scribble
|
||||||
```
|
```
|
||||||
|
|
||||||
Creates a stroke scribble, which outlines the provided shape with a stroke of the given thickness and color.
|
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.
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
## Reticles
|
## Reticles
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue