ExtractChannel
Extracts a channel from a pixmap or a sound.
Syntax
-
ExtractChannel(pm, fam, ch)
-
pm
is a pixmap -
fam
is one of"rgb"
,"hsv"
, and"hsl"
-
ch
is one of the characters infam
-
-
ExtractChannel(snd, n)
-
snd
is a sound -
n
is a non-negative integer
-
Description
If pm
is a pixmap, then ExtractChannel(pm, fam, ch)
returns the specified RGB, HSV, or HSL channel from pm
as a greyscale pixmap.
If snd
is a sound, then ExtractChannel(snd, n)
returns the channel with index n
in snd
as a single-channel sound. Sound channels indices are zero-based, so the first channel has index 0
.
Examples
S ≔ ExampleData("Sally"); pm ≔ CreatePixmap(width(S), (4/3)⋅height(S)); spm ≔ scale(S, 1/3); pm ≔ DrawRect(pm, S, 0, 0); for(i, 1, 3, ( pm ≔ DrawRect( pm, ExtractChannel(spm, "rgb", characters("rgb")[i]), width(spm)⋅(i − 1), height(S)) ) ); pm