Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple Common Lisp library for generation of color gradients.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 README
Octocat-spinner-32 color-gradients.asd
Octocat-spinner-32 gradients.lisp
Octocat-spinner-32 package.lisp
README
A simple color gradient generation library for Common Lisp. It computes linear of radial gradients. Multistop color progression using linear or sin^2 interpolation is available.

Usage:

*steps-per-stop* controls a default number of steps in color interpolation table per color stop

make-linear-gradient (point-1 point-2
		      &key (color-1 '(0 0 0 255)) (color-2 '(255 255 255 255))
			   (steps (* 2 *steps-per-stop*)) (table nil) (fixnum-xy nil) (repeat :pad))

This returns two values. A primary values is a closure of two arguments, coordinates in a gradient space returning a list of RGBA components of a color, as integers in 0-255 range. Returned lists are shared, and so should not be modified.

The second value is a color table, to allow reuse of precomputed color tables for gradients.

The arguments for make-linear-gradient:
 point-1 point-2 are lists of two coordinates of points delimiting a gradient
 color-1 color-2 are lists of color components of form (R G B) or (R G B A), opaque black is default for color-1, opaque white for color-2, if no alpha is provided it defaults to 255
 steps is a number of steps in precomputed color table
 table is an array of lists of colors, if this argument is provided color-1, color-2 and steps are ignored and table is use used as a precomputed color table. This allows sharing tables between gradients by capturing second return value and using arbitrary color progressions.
 fixnum-xy if not null, a closure is generated which arguments are declared to be fixnums
 repeat is one of :pad, :repeat or :reflect, and it determines whether color just continues behind boundary, it is repeated by jumping from color-2 to color-1 directly, or is went through in reverse

make-radial-gradient is similar, except is takes circle-1 and circle-2 instead of points, which are lists of form (x y radius) defining the circles. circle-1 should be entirely contained inside circle-2, but this is not checked. fixnum-xy is ignored, other arguments are identical

make-angular-gradient is also similar, but has three non-optional arguments: center point, start angle and end angle

make-multistop-table (stops &key (steps nil) (interpolation :linear))
stops is a list of lists of four or five elements, first marking a stop position between 0 and 1, and the rest specify color components as above, there have to be at least two stops, but they do not have to be in order
steps specify the size of color table, if not provided it is *steps-per-stop* times the number of steps is assumed
interpolation is one of :linear :sin2, specify color interpolation between stops

this table can be used by :table argument to make-*-gradient functions, see above
Something went wrong with that request. Please try again.