openrndr / orx

A growing library of assorted data structures, algorithms and utilities for OPENRNDR
https://openrndr.org
BSD 2-Clause "Simplified" License
121 stars 37 forks source link

[orx-shade-styles] Implement multi-color linear and radial gradients #137

Closed hamoid closed 4 years ago

hamoid commented 4 years ago

For linear, maybe pass startPoint, endPoint, colorArray, positionsArray. This last variable should contain an array of normalized values to indicate where between startPoint and endPoint the color is located.

For radial, replace positionsArray with radiiArray? Specify center and colorArray.

Use a simple linear interpolation of colors?

hamoid commented 4 years ago

I went for changing linear gradient and radial gradient as little as possible: https://github.com/openrndr/orx/pull/139

Note: the current approach centers the gradient on the shape being drawn (using it's bounding box), instead of what I planned above, which was to specify either two points (for a linear gradient) or a center and a radius (for a radial gradient).

Each approach can have its uses, but for now I chose to follow what is already implemented.