Module P5__.Color
Makers
val make : ?sketch:P5.Sketch.t -> ?alpha:int -> int -> int -> int -> tmake r g bcreates 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 -> tmake vcreates a new colour usingvfor ther, g, bvalues.
val make_string : ?sketch:P5.Sketch.t -> string -> tMaking 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 -> intalpha cextracts the alpha value from a colour
val blue : ?sketch:P5.Sketch.t -> t -> intblue cextracts the blue value from a colour
val brightness : ?sketch:P5.Sketch.t -> t -> intbrightness cextracts the HSB brightness value from a colour
val green : ?sketch:P5.Sketch.t -> t -> intgreen cextracts the green value of a colour
val hue : ?sketch:P5.Sketch.t -> t -> inthue cextracts the HSB hue value from a colour
val lightness : ?sketch:P5.Sketch.t -> t -> intlightness cextracts the HSL lightness value from a colour
val red : ?sketch:P5.Sketch.t -> t -> intred cextracts the red value from a colour
val saturation : ?sketch:P5.Sketch.t -> t -> intsaturation cextracts the HSL saturation value from a colour
Mutators
val set_green : t -> int -> unitset_green c vsets the green component of the colourcto valuev
val set_red : t -> int -> unitset_red c vsets the red component of the colourcto valuev
val set_blue : t -> int -> unitset_blue c vsets the blue component of the colourcto valuev
val set_alpha : t -> int -> unitset_alpha c vsets the alpha component of the colourcto valuev
val to_string : t -> Jstr.tto_string cconverts the colourcto a string
Useful Functions
val lerp_color : ?sketch:P5.Sketch.t -> t -> t -> float -> tlerp_color c1 c2 amtinterpolates ("mixes") two coloursc1andc2by an amount specified byamt.
Settings
val background : ?sketch:P5.Sketch.t -> t -> unitbackground csets the canvas' background colour toc
val background_image : ?sketch:P5.Sketch.t -> P5.Image.t -> unitbackground imgsets the canvas' background to theImage.timg
val clear : ?sketch:P5.Sketch.t -> unit -> unitClears the buffer
val color_mode : ?sketch:P5.Sketch.t -> ?max:int -> mode -> unitcolor_mode ?max modesets 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 -> unitSame as
color_modebut gives you more control over each of the ranges for a particularmode
val fill : ?sketch:P5.Sketch.t -> t -> unitfill csets the colour to be used to fill shapes
val no_fill : ?sketch:P5.Sketch.t -> unit -> unitDisables filling geometry
val stroke : ?sketch:P5.Sketch.t -> t -> unitstroke csets the colour used to draw lines and borders around shapes
val no_stroke : ?sketch:P5.Sketch.t -> unit -> unitno_stroke ()disables drawing the outline
val erase : ?sketch:P5.Sketch.t -> ?fill_strength:int -> ?stroke_strength:int -> unit -> uniterase ()causes all subsequent draws to subtract from the canvas.fill_strengthandstroke_strengthwill control how much the two properties will be erased. By default they are255i.e. full strength
val no_erase : ?sketch:P5.Sketch.t -> unit -> unitno_erase ()ends erasing that was started witherase