G'Day Folks,
At present I have a bunch of (drawing) options in a program, when doing some drawing, I compare a variable to the options to decide whether to do a particular option. For example:
const
sz = 3;
// drawing options
oNotFill = 1; // don't draw filled
oSqPts = 2*oNotFill; // draw points (as squares)
oCrPts = 2*oSqPts; // draw points (as circles)
oPts = 2*oCrPts; // draw shape's key points
oExtRect = 2*oPts; // draw extents rectangle
oExtPts = 2*oExtRect; // draw extents' min/max pts
oCen = 2*oExtPts; // draw centre point (ellipse, regpoly, star, arc)
... // up to 32 options
procedure draw(draw_options : cardinal; p1,p2 : tpoint);
begin
...
if draw_options and oSqPts <> 0 then
begin
with p1 do fillrect(x-sz,y-sz, x+sz,y+sz);
with p2 do fillrect(x-sz,y-sz, x+sz,y+sz);
end;
...
end;
...
draw(oNotFill+oSqPts+oExtRect, point(100,100), point(200,200));
All this works fine; but, I am wondering though whether there might be a more elegant way to achieve this!?
In particular the const declarations seem quite messy.
Any advice / comments would be welcome!
cheers
S.