georgedoescode / generative-utils

A collection of handy generative art utilities
MIT License
289 stars 22 forks source link

Update spline.js #4

Closed johnfmorton closed 10 months ago

johnfmorton commented 10 months ago

Updated so a closed spline's path does not loop back over itself.

johnfmorton commented 10 months ago

Hi George,

I've been playing with the spline and points on a path and wanted to share changes I've made for a project to these functions--if you find them worthwhile, great! If not, no problem.

I am drawing random shapes, and I wanted to be able to use "points on a line" to even out the distribution. The revised version makes sure you get exactly the number of points you ask for and that the last point always falls exactly on the end of the path.

Next, I wanted to make a spline so that the being and end points didn't overlap. That's what the revised spline function does. I intend for the new function's results to create the exact same shape created with your spline function.

Here's an example that shows you what the changes do: https://johnfmorton.github.io/svg-gen-closing-the-loop/

Thanks for all the work on this repo!

-John

johnfmorton commented 10 months ago

I'm closing this pull request for the time being. It's not incorporating the 'tension' value like I intended.