Module P5.Color
Makers
val make : ?sketch: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:Sketch.t -> ?alpha:int -> int -> t
make v
creates a new colour usingv
for ther, g, b
values.
val make_string : ?sketch: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 brightness : ?sketch:Sketch.t -> t -> int
brightness c
extracts the HSB brightness 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
Settings
val background_image : ?sketch:Sketch.t -> Image.t -> unit
background img
sets the canvas' background to theImage.t
img
val clear : ?sketch:Sketch.t -> unit -> unit
Clears the buffer
val color_mode : ?sketch: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: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 no_fill : ?sketch:Sketch.t -> unit -> unit
Disables filling geometry
val stroke : ?sketch:Sketch.t -> t -> unit
stroke c
sets the colour used to draw lines and borders around shapes
val no_stroke : ?sketch:Sketch.t -> unit -> unit
no_stroke ()
disables drawing the outline
val erase : ?sketch: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