Sudha247 / ocaml-joy

MIT License
21 stars 14 forks source link

Adding color handling #90

Closed FayCarsons closed 5 months ago

FayCarsons commented 6 months ago

My first attempt at a system for coloring shapes and setting background in init. Shapes now have a color field that is an 8bit RGB three-tuple. Shape constructors are the same, inserting black as default, but shapes can be piped to a new function with_color that returns a new shape with the color field set to the arg.

So creating a gray circle can look like this:

let c = circle 50 |> with_color (128, 128, 128)
nikochiko commented 6 months ago

Thanks! This looks great!

I have suggested some renaming and refactor changes. Please go through the review.

FayCarsons commented 6 months ago

Applied changes, caught a couple of small issues, and added color mapping functions: map_color which applies a fn to both stroke and fill, and map_stroke/map_fill which apply a fn to specific color fields in a shape.

FayCarsons commented 5 months ago

Fixed merge conflicts!