My vector graphics in my graphics library includes a canvas that can be bound to a draw target like a bitmap.
Accessed off the canvas, you perform drawing operations like arcs and paths.
Here's the trouble. Each drawing operation has numerous options:
The stroke (which is the outline of the shape basically) - it has a color a width, line join, and line cap. Or the "color" can be a linear gradient, a radial gradient or a texture.
Then there's the fill, which has the same kind of properties on it, minus line join, stroke width and line cap.
I could
a) take all of this information as parameters to each draw arc, line, path, etc function. This is my least desirable option because it requires more work on behalf of the developer/user + more stack
b) create complex structs with unions in them for the colors, line caps, textures, and gradients.
c) have a "current stroke color", "current fill color", "current line cap" etc as accessors/"properties" off the canvas.
I'm torn between b and c, although if anyone has other ideas I'm open to hearing them, as long as you're not suggesting I redesign everything, as I worked on the design for days, and it's got some important compromises in it that I don't want to have to explain.
What I have tried:
I'll put an example of what I mean
a) canvas.arc(..., stroke_color, stroke_width, line_cap, line_join, fill_color, texture, gradient)
b) canvas.arc(..., const paint_info&)
where paint_info is a complex struct that covers all the parameters.
c) canvas.stroke_color(color_t::green);canvas.stroke_width(10);
etc.