Comments (3)
Hey @jcquinlan
I don't know if I'm understanding your message correctly, but I think you might be able to do just what you need with the Position class: https://github.com/acamposuribe/p5.brush?tab=readme-ov-file#exposed-classes
The Position class lets you create a new coordinates object with new brush.Position(x,y)
, which you can then move through the flowfield, whatever distance you want. This is equivalent to how flowlines are drawn. The only thing is that the movement of Position objects goes in steps, and by default this step coincides with the currently active brush. Before folowing lines, you might want to make sure that the same brush is still active.
You can use the brush.Position class like this:
// Let's set the HB
brush.set("HB", "black", 1)
// Let's draw a "horizontal" 0 degrees flowline starting at (10,30), of 100px length
brush.flowLine(10, 30, 100, 0)
// Let's say we want to find the coordinates in these path, every 10px
let coordinates = []
// We create a Position object in the starting coordinates
let pos = new brush.Position(10,30)
// We move 10px through the 0 degrees path
// It's important to notice that this movement is cumulative, that is,
// once the position has been moved, its coordinates are updated
for (let i = 0; i < 10; i++) {
pos.moveTo(10, 0)
coordinates.push([pos.x, pos.y])
}
// These are the 10 points through the flow path
console.log(coordinates)
I hope this helps!
(I'm pushing a small change to the code in order to make this work better, since I just found a small problem)
from p5.brush.
In any case, if what you want to do is draw a series of segments with different sizes and different directions, it's probably much easier to use the Plot class, that lets you create just that!
To be honest, the documentation for the three exposed classes is very minimal, but these are basically the core of the whole library. If you learn to use them, you can do almost everything
from p5.brush.
Circling back on this to say A.) thanks for pointing me in the right direction, as the Position class indeed allowed me to do what I was thinking originally, and B.) apologize for not having more thoroughly explored the docs before creating an issue!
I'll close the issue now, thanks for all your hard work!
from p5.brush.
Related Issues (15)
- Validate input for brush name HOT 1
- Animations being very slow HOT 2
- Support for instance mode? HOT 8
- Can't save frames with CCapture.js HOT 3
- brush.point not working HOT 3
- Marker brushes rendering black-ish after canvas resize HOT 4
- brush.circle is not working on 1.1 HOT 1
- Drawing multiple elements but they only display in chunks, not the moment they are drawn - buffering problem? HOT 2
- Instance mode not working HOT 2
- Processing desktop version? HOT 3
- A series of bugs/enhancements that need solving
- Arc Support HOT 2
- Issues when attempting to rotate() HOT 3
- Publishing to NPM / support for Typescript? HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5.brush.