clojure2d.color.blend

Blending modes functions for colors, gradients and palettes.

Great collection of blending functions for color channel values. Channel values should be from [0.0,255.0] range.

Use blend-colors, blend-palettes and blend-gradients to blend colors, palettes and gradients.

blend-colors uses simple alpha blending strategy as described here.

Blending can be done separately for each channel.

add

(add a b)

Add channel values (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :add ...)

Simple calls

(b/add 50 200)
;;=> 250.0
(b/add 80 120)
;;=> 200.0
(b/add 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/add :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/add
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/add
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

alpha-blending

(alpha-blending cb cs blend)

and

(and a b)

Bitwise and of channel values.

Examples

Composed images

(clojure2d.color-example/blend-images :and ...)

Simple calls

(b/and 50 200)
;;=> 0.0
(b/and 80 120)
;;=> 80.0
(b/and 170 220)
;;=> 136.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/and :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/and
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/and
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

average

(average a b)

Average of two channel values.

Examples

Composed images

(clojure2d.color-example/blend-images :average ...)

Simple calls

(b/average 50 200)
;;=> 125.0
(b/average 80 120)
;;=> 100.0
(b/average 170 220)
;;=> 195.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/average
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/average
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/average
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

blend-colors

(blend-colors blend-fn cb cs)(blend-colors blend-fn1 blend-fn2 blend-fn3 cb cs)

Blend two colors using simple alpha composing.

Each channel can be blended using different function.

Formula from w3.org spec.

Examples

Multiply colors

(b/blend-colors b/multiply :brown :khaki)
[#9b2617] #vec4 [155.2941176470588, 37.88235294117647, 23.058823529411764, 255.0]

Modulo add colors

(b/blend-colors b/madd :brown :khaki)
[#9510b6] #vec4 [149.0, 16.0, 182.0, 255.0]

Hardmix colors

(b/blend-colors b/hardmix :brown :khaki)
[#ffff00] #vec4 [255.0, 255.0, 0.0, 255.0]

blend-gradients

(blend-gradients blend-fn g1 g2)(blend-gradients blend-fn1 blend-fn2 blend-fn3 g1 g2)

Blend two gradients.

Each channel can be blended using different function.

Examples

First gradient

(gradient (palette 5))

Second gradient

(gradient (palette 35))

Blend two gradients using burn mode

(b/blend-gradients b/burn
                   (gradient (palette 5))
                   (gradient (palette 35)))

Blend using different modes for each channel

(b/blend-gradients b/burn
                   b/divide
                   b/difference
                   (gradient (palette 5))
                   (gradient (palette 35)))

blend-palettes

(blend-palettes blend-fn pal1 pal2)(blend-palettes blend-fn1 blend-fn2 blend-fn3 pal1 pal2)

Blend two palettes.

Each channel can be blended using different function.

Examples

First palette

(palette 5)          

Second palette

(palette 35)          

Blend two palettes using burn mode

(b/blend-palettes b/burn (palette 5) (palette 35))          

Blend using different modes for each channel

(b/blend-palettes b/burn b/divide b/difference (palette 5) (palette 35))          

blends

Examples

Access

(b/blends :mdodge)
;;=> clojure2d.color.blend$mdodge@41a4c0f9
((b/blends :mdodge) 0.4 0.3)
;;=> 0.4004711425206125

blends-list

List of all blending functions.

Examples

List of blends

b/blends-list
;;=> (:add
;;=>  :and
;;=>  :average :burn
;;=>  :darken :difference
;;=>  :divide :dodge
;;=>  :exclusion :freeze
;;=>  :glow :hardlight
;;=>  :hardmix :heat
;;=>  :inverseburn :inversedodge
;;=>  :lighten :linearburn
;;=>  :linearlight :madd
;;=>  :mburn :mdivide
;;=>  :mdodge :mfreeze
;;=>  :mglow :mheat
;;=>  :minverseburn :minversedodge
;;=>  :mlinearburn :mlinearlight
;;=>  :mreflect :msoftburn
;;=>  :msoftdodge :mstamp
;;=>  :msubtract :multiply
;;=>  :mvividlight :negation
;;=>  :normal :or
;;=>  :overlay :pegtoplight
;;=>  :pinlight :reflect
;;=>  :screen :softburn
;;=>  :softdodge :softlight
;;=>  :stamp :subtract
;;=>  :vividlight :xor)

burn

(burn a b)

Burn mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :burn ...)

Simple calls

(b/burn 50 200)
;;=> 0.0
(b/burn 80 120)
;;=> 0.0
(b/burn 170 220)
;;=> 156.47727272727272

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/burn :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/burn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/burn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

ch0

(ch0 colorspace cb cs)(ch0 cb cs)

ch1

(ch1 colorspace cb cs)(ch1 cb cs)

ch2

(ch2 colorspace cb cs)(ch2 cb cs)

color

(color cb cs)

darken

(darken a b)

Darken mode.

Examples

Composed images

(clojure2d.color-example/blend-images :darken ...)

Simple calls

(b/darken 50 200)
;;=> 50.0
(b/darken 80 120)
;;=> 80.0
(b/darken 170 220)
;;=> 170.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/darken :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/darken
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/darken
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

difference

(difference a b)

Difference mode.

Examples

Composed images

(clojure2d.color-example/blend-images :difference ...)

Simple calls

(b/difference 50 200)
;;=> 150.0
(b/difference 80 120)
;;=> 40.0
(b/difference 170 220)
;;=> 50.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/difference
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/difference
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/difference
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

divide

(divide a b)

Divide channel values (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :divide ...)

Simple calls

(b/divide 50 200)
;;=> 63.75
(b/divide 80 120)
;;=> 170.0
(b/divide 170 220)
;;=> 197.04545454545453

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/divide :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/divide
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/divide
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

dodge

(dodge a b)

Dodge mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :dodge ...)

Simple calls

(b/dodge 50 200)
;;=> 231.8181818181818
(b/dodge 80 120)
;;=> 151.11111111111111
(b/dodge 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/dodge :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/dodge
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/dodge
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

exclusion

(exclusion a b)

Exclusion mode.

Examples

Composed images

(clojure2d.color-example/blend-images :exclusion ...)

Simple calls

(b/exclusion 50 200)
;;=> 171.5686274509804
(b/exclusion 80 120)
;;=> 124.70588235294117
(b/exclusion 170 220)
;;=> 96.66666666666669

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/exclusion
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/exclusion
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/exclusion
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

freeze

(freeze a b)

Freeze mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :freeze ...)

Simple calls

(b/freeze 50 200)
;;=> 44.875
(b/freeze 80 120)
;;=> 0.0
(b/freeze 170 220)
;;=> 222.1590909090909

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/freeze :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/freeze
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/freeze
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

glow

(glow a b)

Glow mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :glow ...)

Simple calls

(b/glow 50 200)
;;=> 195.1219512195122
(b/glow 80 120)
;;=> 82.28571428571429
(b/glow 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/glow :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/glow
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/glow
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

hardlight

(hardlight a b)

Hard light mode.

Examples

Composed images

(clojure2d.color-example/blend-images :hardlight ...)

Simple calls

(b/hardlight 50 200)
;;=> 166.5686274509804
(b/hardlight 80 120)
;;=> 75.29411764705883
(b/hardlight 170 220)
;;=> 231.66666666666666

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/hardlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/hardlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/hardlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

hardmix

(hardmix a b)

Hard mix channel values.

Examples

Composed images

(clojure2d.color-example/blend-images :hardmix ...)

Simple calls

(b/hardmix 50 200)
;;=> 0.0
(b/hardmix 80 120)
;;=> 0.0
(b/hardmix 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/hardmix
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/hardmix
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/hardmix
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

heat

(heat a b)

Heat mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :heat ...)

Simple calls

(b/heat 50 200)
;;=> 194.5
(b/heat 80 120)
;;=> 27.1875
(b/heat 170 220)
;;=> 247.7941176470588

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/heat :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/heat
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/heat
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

hue

(hue cb cs)

inverseburn

(inverseburn a b)

Inverse burn mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :inverseburn ...)

Simple calls

(b/inverseburn 50 200)
;;=> 0.0
(b/inverseburn 80 120)
;;=> 0.0
(b/inverseburn 170 220)
;;=> 202.50000000000003

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/inverseburn
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/inverseburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/inverseburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

inversedodge

(inversedodge a b)

Inverse dodge mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :inversedodge ...)

Simple calls

(b/inversedodge 50 200)
;;=> 248.78048780487805
(b/inversedodge 80 120)
;;=> 174.85714285714286
(b/inversedodge 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/inversedodge
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/inversedodge
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/inversedodge
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

lighten

(lighten a b)

Lighten mode.

Examples

Composed images

(clojure2d.color-example/blend-images :lighten ...)

Simple calls

(b/lighten 50 200)
;;=> 200.0
(b/lighten 80 120)
;;=> 120.0
(b/lighten 170 220)
;;=> 220.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/lighten
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/lighten
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/lighten
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

linearburn

(linearburn a b)

Linear burn mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :linearburn ...)

Simple calls

(b/linearburn 50 200)
;;=> 0.0
(b/linearburn 80 120)
;;=> 0.0
(b/linearburn 170 220)
;;=> 135.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/linearburn
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/linearburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/linearburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

linearlight

(linearlight a b)

Linear light mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :linearlight ...)

Simple calls

(b/linearlight 50 200)
;;=> 45.0
(b/linearlight 80 120)
;;=> 25.0
(b/linearlight 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/linearlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/linearlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/linearlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

luminocity

(luminocity cb cs)

madd

(madd a b)

Add channel values (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :madd ...)

Simple calls

(b/madd 50 200)
;;=> 250.0
(b/madd 80 120)
;;=> 200.0
(b/madd 170 220)
;;=> 134.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/madd :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/madd
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/madd
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mburn

(mburn a b)

Burn mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mburn ...)

Simple calls

(b/mburn 50 200)
;;=> 249.62500000000003
(b/mburn 80 120)
;;=> 139.125
(b/mburn 170 220)
;;=> 156.47727272727272

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mburn :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mdivide

(mdivide a b)

Divide channel values (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mdivide ...)

Simple calls

(b/mdivide 50 200)
;;=> 63.75
(b/mdivide 80 120)
;;=> 170.0
(b/mdivide 170 220)
;;=> 197.04545454545453

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mdivide
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mdivide
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mdivide
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mdodge

(mdodge a b)

Dodge mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mdodge ...)

Simple calls

(b/mdodge 50 200)
;;=> 231.8181818181818
(b/mdodge 80 120)
;;=> 151.11111111111111
(b/mdodge 170 220)
;;=> 214.57142857142867

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mdodge :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mdodge
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mdodge
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mfreeze

(mfreeze a b)

Freeze mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mfreeze ...)

Simple calls

(b/mfreeze 50 200)
;;=> 44.875
(b/mfreeze 80 120)
;;=> 255.79166666666666
(b/mfreeze 170 220)
;;=> 222.1590909090909

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mfreeze
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mfreeze
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mfreeze
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mglow

(mglow a b)

Glow mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mglow ...)

Simple calls

(b/mglow 50 200)
;;=> 195.1219512195122
(b/mglow 80 120)
;;=> 82.28571428571429
(b/mglow 170 220)
;;=> 57.41176470588232

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mglow :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mglow
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mglow
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mheat

(mheat a b)

Heat mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mheat ...)

Simple calls

(b/mheat 50 200)
;;=> 194.5
(b/mheat 80 120)
;;=> 27.1875
(b/mheat 170 220)
;;=> 247.7941176470588

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mheat :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mheat
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mheat
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

minverseburn

(minverseburn a b)

Inverse burn mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :minverseburn ...)

Simple calls

(b/minverseburn 50 200)
;;=> 230.49999999999997
(b/minverseburn 80 120)
;;=> 80.6875
(b/minverseburn 170 220)
;;=> 202.50000000000003

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/minverseburn
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/minverseburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/minverseburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

minversedodge

(minversedodge a b)

Inverse dodge mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :minversedodge ...)

Simple calls

(b/minversedodge 50 200)
;;=> 248.78048780487805
(b/minversedodge 80 120)
;;=> 174.85714285714286
(b/minversedodge 170 220)
;;=> 148.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/minversedodge
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/minversedodge
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/minversedodge
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mlinearburn

(mlinearburn a b)

Linear burn mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mlinearburn ...)

Simple calls

(b/mlinearburn 50 200)
;;=> 251.0
(b/mlinearburn 80 120)
;;=> 201.0
(b/mlinearburn 170 220)
;;=> 135.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mlinearburn
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mlinearburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mlinearburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mlinearlight

(mlinearlight a b)

Linear light mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mlinearlight ...)

Simple calls

(b/mlinearlight 50 200)
;;=> 45.0
(b/mlinearlight 80 120)
;;=> 25.0
(b/mlinearlight 170 220)
;;=> 49.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mlinearlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mlinearlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mlinearlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mreflect

(mreflect a b)

Reflec mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mreflect ...)

Simple calls

(b/mreflect 50 200)
;;=> 45.45454545454545
(b/mreflect 80 120)
;;=> 47.407407407407405
(b/mreflect 170 220)
;;=> 57.714285714285666

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mreflect
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mreflect
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mreflect
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

msoftburn

(msoftburn a b)

Soft burn mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :msoftburn ...)

Simple calls

(b/msoftburn 50 200)
;;=> 124.39024390243902
(b/msoftburn 80 120)
;;=> 87.42857142857143
(b/msoftburn 170 220)
;;=> 28.97727272727273

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/msoftburn
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/msoftburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/msoftburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

msoftdodge

(msoftdodge a b)

Soft dodge mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :msoftdodge ...)

Simple calls

(b/msoftdodge 50 200)
;;=> 115.9090909090909
(b/msoftdodge 80 120)
;;=> 75.55555555555556
(b/msoftdodge 170 220)
;;=> 228.75

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/msoftdodge
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/msoftdodge
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/msoftdodge
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mstamp

(mstamp a b)

Stamp mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mstamp ...)

Simple calls

(b/mstamp 50 200)
;;=> 195.0
(b/mstamp 80 120)
;;=> 65.0
(b/mstamp 170 220)
;;=> 99.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mstamp :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mstamp
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mstamp
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

msubtract

(msubtract a b)

Subtract channel values (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :msubtract ...)

Simple calls

(b/msubtract 50 200)
;;=> 106.0
(b/msubtract 80 120)
;;=> 216.0
(b/msubtract 170 220)
;;=> 206.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/msubtract
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/msubtract
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/msubtract
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

multiply

(multiply a b)

Multiply channel values.

Examples

Composed images

(clojure2d.color-example/blend-images :multiply ...)

Simple calls

(b/multiply 50 200)
;;=> 39.21568627450981
(b/multiply 80 120)
;;=> 37.64705882352941
(b/multiply 170 220)
;;=> 146.66666666666666

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/multiply
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/multiply
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/multiply
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

mvividlight

(mvividlight a b)

Vivid light mode (mod 255).

Examples

Composed images

(clojure2d.color-example/blend-images :mvividlight ...)

Simple calls

(b/mvividlight 50 200)
;;=> 115.9090909090909
(b/mvividlight 80 120)
;;=> 69.0625
(b/mvividlight 170 220)
;;=> 107.28571428571433

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/mvividlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/mvividlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/mvividlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

negation

(negation a b)

Negation mode.

Examples

Composed images

(clojure2d.color-example/blend-images :negation ...)

Simple calls

(b/negation 50 200)
;;=> 250.0
(b/negation 80 120)
;;=> 200.0
(b/negation 170 220)
;;=> 120.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/negation
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/negation
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/negation
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

normal

(normal _ b)

Return second value only.

Examples

Composed images

(clojure2d.color-example/blend-images :normal ...)

Simple calls

(b/normal 50 200)
;;=> 200.0
(b/normal 80 120)
;;=> 120.0
(b/normal 170 220)
;;=> 220.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/normal :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/normal
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/normal
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

or

(or a b)

Bitwise or of channel values.

Examples

Composed images

(clojure2d.color-example/blend-images :or ...)

Simple calls

(b/or 50 200)
;;=> 250.0
(b/or 80 120)
;;=> 120.0
(b/or 170 220)
;;=> 254.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/or :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/or
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/or
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

overlay

(overlay a b)

Overlay mode.

Examples

Composed images

(clojure2d.color-example/blend-images :overlay ...)

Simple calls

(b/overlay 50 200)
;;=> 78.43137254901961
(b/overlay 80 120)
;;=> 75.29411764705883
(b/overlay 170 220)
;;=> 231.66666666666666

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/overlay
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/overlay
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/overlay
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

pegtoplight

(pegtoplight a b)

Pegtop soft light mode.

Examples

Composed images

(clojure2d.color-example/blend-images :pegtoplight ...)

Simple calls

(b/pegtoplight 50 200)
;;=> 72.85659361783931
(b/pegtoplight 80 120)
;;=> 76.77047289504037
(b/pegtoplight 170 220)
;;=> 211.11111111111111

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/pegtoplight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/pegtoplight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/pegtoplight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

pinlight

(pinlight a b)

Pin light mode.

Examples

Composed images

(clojure2d.color-example/blend-images :pinlight ...)

Simple calls

(b/pinlight 50 200)
;;=> 100.0
(b/pinlight 80 120)
;;=> 120.0
(b/pinlight 170 220)
;;=> 220.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/pinlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/pinlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/pinlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

reflect

(reflect a b)

Reflect mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :reflect ...)

Simple calls

(b/reflect 50 200)
;;=> 45.45454545454545
(b/reflect 80 120)
;;=> 47.407407407407405
(b/reflect 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/reflect
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/reflect
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/reflect
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

saturation

(saturation cb cs)

screen

(screen a b)

Screen mode.

Examples

Composed images

(clojure2d.color-example/blend-images :screen ...)

Simple calls

(b/screen 50 200)
;;=> 210.7843137254902
(b/screen 80 120)
;;=> 162.3529411764706
(b/screen 170 220)
;;=> 243.33333333333334

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/screen :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/screen
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/screen
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

softburn

(softburn a b)

Soft burn mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :softburn ...)

Simple calls

(b/softburn 50 200)
;;=> 124.39024390243902
(b/softburn 80 120)
;;=> 87.42857142857143
(b/softburn 170 220)
;;=> 28.97727272727273

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/softburn
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/softburn
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/softburn
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

softdodge

(softdodge a b)

Soft dodge mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :softdodge ...)

Simple calls

(b/softdodge 50 200)
;;=> 115.9090909090909
(b/softdodge 80 120)
;;=> 75.55555555555556
(b/softdodge 170 220)
;;=> 228.75

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/softdodge
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/softdodge
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/softdodge
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

softlight

(softlight a b)

Soft light mode.

Examples

Composed images

(clojure2d.color-example/blend-images :softlight ...)

Simple calls

(b/softlight 50 200)
;;=> 85.7757066526373
(b/softlight 80 120)
;;=> 76.77047289504037
(b/softlight 170 220)
;;=> 197.718534138296

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/softlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/softlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/softlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

stamp

(stamp a b)

Stamp mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :stamp ...)

Simple calls

(b/stamp 50 200)
;;=> 195.0
(b/stamp 80 120)
;;=> 65.0
(b/stamp 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/stamp :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/stamp
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/stamp
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

subtract

(subtract a b)

Subtract channel values (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :subtract ...)

Simple calls

(b/subtract 50 200)
;;=> 0.0
(b/subtract 80 120)
;;=> 0.0
(b/subtract 170 220)
;;=> 0.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/subtract
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/subtract
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/subtract
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

vividlight

(vividlight a b)

Vivid light mode (clamped).

Examples

Composed images

(clojure2d.color-example/blend-images :vividlight ...)

Simple calls

(b/vividlight 50 200)
;;=> 115.9090909090909
(b/vividlight 80 120)
;;=> 69.0625
(b/vividlight 170 220)
;;=> 255.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/vividlight
                                     :salmon
                                     :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/vividlight
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/vividlight
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))

xor

(xor a b)

Bitwise xor of channel values.

Examples

Composed images

(clojure2d.color-example/blend-images :xor ...)

Simple calls

(b/xor 50 200)
;;=> 250.0
(b/xor 80 120)
;;=> 40.0
(b/xor 170 220)
;;=> 118.0

Blend two colors

[:salmon :mediumturquoise
 (clojure2d.color.blend/blend-colors b/xor :salmon :mediumturquoise)]      

Blend two palettes

(clojure2d.color.blend/blend-palettes b/xor
                                      (clojure2d.color/palette 5)
                                      (clojure2d.color/palette 35))          

Blend two gradients

(clojure2d.color.blend/blend-gradients
 b/xor
 (clojure2d.color/gradient (clojure2d.color/palette 5))
 (clojure2d.color/gradient (clojure2d.color/palette 35)))