Brush effects / reticle system #12

Closed
opened 2024-08-17 22:36:31 +02:00 by liquidev · 1 comment
liquidev commented 2024-08-17 22:36:31 +02:00 (Migrated from github.com)

The PLT side, not the visual side.

Basically I'd like brushes to accept parameters, and that requires injecting them via an effect. This would become the basis of our reticle system for the future.

Essentially, instead of just drawing at (vec), you declare that you'd like to have a "plotter" reticle tell you where to draw:

(with-plotter (fn (a b pressure)
    (stroke
        (* 8 pressure)
        (rgba 0 0 0 1)
        a)))

and then the plotter reticle renders your brush in a roughly 500x500 area around it.

Likewise we'd later get (with-rectangle), (with-polyline), (with-polygon), etc. but that's unnecessary for this prototype.

The PLT side, not the visual side. Basically I'd like brushes to accept parameters, and that requires injecting them via an effect. This would become the basis of our reticle system for the future. Essentially, instead of _just_ drawing at `(vec)`, you declare that you'd like to have a "plotter" reticle tell you where to draw: ``` (with-plotter (fn (a b pressure) (stroke (* 8 pressure) (rgba 0 0 0 1) a))) ``` and then the plotter reticle renders your brush in a roughly 500x500 area around it. Likewise we'd later get `(with-rectangle)`, `(with-polyline)`, `(with-polygon)`, etc. but that's unnecessary for this prototype.
liquidev commented 2024-09-04 23:20:14 +02:00 (Migrated from github.com)

To kick off, now that we have the new haku syntax, let's define withDotter to be a reticle that draws dots at the mouse cursor.

withDotter
  draw : \(\tag -> _) -> scribble
  -> reticle

Usage:

withDotter \d ->
  stroke 8 #000 (line (d From) (d To))

d is a function that, when provided an argument for what type of data you'd like to extract, provides you with that data stored in the dotter. A dotter will store the following data types:

-- Cursor positions - last and current
From : vec
To   : vec

-- Number of dots drawn so far
Num  : number

What will make reticles especially powerful is that From and To will give you global coordinates, so you'll be able to draw pixels dependent on the position of the cursor on the canvas.

To help with the current ongoing issue of brushes leaving visible gaps between dots, a dotter is going to have access to the previous mouse position in addition to the current position. That way you can fill in the gap however you want.

Something that will not be done for now is equally subdividing or smoothing out the points anyhow. For that I'd like to have a more powerful interface you can move on to if you want more advanced controls.

To kick off, now that we have the new haku syntax, let's define `withDotter` to be a reticle that draws dots at the mouse cursor. ``` withDotter draw : \(\tag -> _) -> scribble -> reticle ``` Usage: ``` withDotter \d -> stroke 8 #000 (line (d From) (d To)) ``` `d` is a function that, when provided an argument for what type of data you'd like to extract, provides you with that data stored in the dotter. A dotter will store the following data types: ``` -- Cursor positions - last and current From : vec To : vec -- Number of dots drawn so far Num : number ``` What will make reticles especially powerful is that `From` and `To` will give you _global_ coordinates, so you'll be able to draw pixels dependent on the position of the cursor on the canvas. To help with the current ongoing issue of brushes leaving visible gaps between dots, a dotter is going to have access to the previous mouse position in addition to the current position. That way you can fill in the gap however you want. Something that will _not_ be done for now is equally subdividing or smoothing out the points anyhow. For that I'd like to have a more powerful interface you can move on to if you want more advanced controls.
liquidex added this to the Backlog project 2024-09-13 20:24:03 +02:00
liquidex added a new dependency 2024-09-13 21:21:20 +02:00
liquidex removed a dependency 2024-09-13 21:21:24 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: liquidex/rkgk#12
No description provided.