Module P5__.Color
Makers
val make : ?sketch:P5.Sketch.t -> ?alpha:int -> int -> int -> int -> t
make r g b
creates a new colour using the values forr, g, b
. You can also provide an optional alpha value.
val make_gray : ?sketch:P5.Sketch.t -> ?alpha:int -> int -> t
make v
creates a new colour usingv
for ther, g, b
values.
val make_string : ?sketch:P5.Sketch.t -> string -> t
Making a colour with a string. The p5 reference explains in detail what can and cannot be passed as an argument here.
Accessors
val alpha : ?sketch:P5.Sketch.t -> t -> int
alpha c
extracts the alpha value from a colour
val blue : ?sketch:P5.Sketch.t -> t -> int
blue c
extracts the blue value from a colour
val brightness : ?sketch:P5.Sketch.t -> t -> int
brightness c
extracts the HSB brightness value from a colour
val green : ?sketch:P5.Sketch.t -> t -> int
green c
extracts the green value of a colour
val hue : ?sketch:P5.Sketch.t -> t -> int
hue c
extracts the HSB hue value from a colour
val lightness : ?sketch:P5.Sketch.t -> t -> int
lightness c
extracts the HSL lightness value from a colour
val red : ?sketch:P5.Sketch.t -> t -> int
red c
extracts the red value from a colour
val saturation : ?sketch:P5.Sketch.t -> t -> int
saturation c
extracts the HSL saturation value from a colour
Mutators
val set_green : t -> int -> unit
set_green c v
sets the green component of the colourc
to valuev
val set_red : t -> int -> unit
set_red c v
sets the red component of the colourc
to valuev
val set_blue : t -> int -> unit
set_blue c v
sets the blue component of the colourc
to valuev
val set_alpha : t -> int -> unit
set_alpha c v
sets the alpha component of the colourc
to valuev
val to_string : t -> Jstr.t
to_string c
converts the colourc
to a string
Useful Functions
val lerp_color : ?sketch:P5.Sketch.t -> t -> t -> float -> t
lerp_color c1 c2 amt
interpolates ("mixes") two coloursc1
andc2
by an amount specified byamt
.
Settings
val background : ?sketch:P5.Sketch.t -> t -> unit
background c
sets the canvas' background colour toc
val background_image : ?sketch:P5.Sketch.t -> P5.Image.t -> unit
background img
sets the canvas' background to theImage.t
img
val clear : ?sketch:P5.Sketch.t -> unit -> unit
Clears the buffer
val color_mode : ?sketch:P5.Sketch.t -> ?max:int -> mode -> unit
color_mode ?max mode
sets the colour mode and the range for all values
val color_mode_with_max : ?sketch:P5.Sketch.t -> ?max_alpha:int -> max_1:int -> max_2:int -> max_3:int -> mode -> unit
Same as
color_mode
but gives you more control over each of the ranges for a particularmode
val fill : ?sketch:P5.Sketch.t -> t -> unit
fill c
sets the colour to be used to fill shapes
val no_fill : ?sketch:P5.Sketch.t -> unit -> unit
Disables filling geometry
val stroke : ?sketch:P5.Sketch.t -> t -> unit
stroke c
sets the colour used to draw lines and borders around shapes
val no_stroke : ?sketch:P5.Sketch.t -> unit -> unit
no_stroke ()
disables drawing the outline
val erase : ?sketch:P5.Sketch.t -> ?fill_strength:int -> ?stroke_strength:int -> unit -> unit
erase ()
causes all subsequent draws to subtract from the canvas.fill_strength
andstroke_strength
will control how much the two properties will be erased. By default they are255
i.e. full strength
val no_erase : ?sketch:P5.Sketch.t -> unit -> unit
no_erase ()
ends erasing that was started witherase