Class: Caman.Calculate
Defined in: | src/core/calculate.coffee |
Overview
Various math-heavy helpers that are used throughout CamanJS.
Class Method Summary
- + (Number) distance(x1, y1, x2, y2)
- + (Number) randomRange(min, max, getFloat = false)
- + (Number) luminance(rgba) Calculates the luminance of a single pixel using a special weighted sum.
- + (Array) bezier(start, ctrl1, ctrl2, end, lowBound, highBound) Generates a bezier curve given a start and end point, with two control points in between.
Class Method Details
+ (Number) distance(x1, y1, x2, y2)
+ (Number) randomRange(min, max, getFloat = false)
+ (Number) luminance(rgba)
Calculates the luminance of a single pixel using a special weighted sum.
+ (Array) bezier(start, ctrl1, ctrl2, end, lowBound, highBound)
Generates a bezier curve given a start and end point, with two control points in between. Can also optionally bound the y values between a low and high bound.
This is different than most bezier curve functions because it attempts to construct it in such a way that we can use it more like a simple input -> output system, or a one-to-one function. In other words we can provide an input color value, and immediately receive an output modified color value.
Note that, by design, this does not force X values to be in the range [0..255]. This is to generalize the function a bit more. If you give it a starting X value that isn't 0, and/or a ending X value that isn't 255, you may run into problems with your filter!