Drawing clear solid rectangles in NXC
Posted: 04 Dec 2010, 20:40
How do you draw clear solid rectangles in NXC? I know how to draw clear rectangles, OR solid rectangles, but how do you do clear solid rectangles?
Give a child a robot, he'll play for an hour. Teach him to build, and he'll play forever.
https://mindboards.org:443/
Code: Select all
task main()
{
RectOut(0, 0, 100, 64, DRAW_OPT_FILL_SHAPE); //Blacks out a solid rectangle
RectOut(25, 16, 50, 32, DRAW_OPT_CLEAR); //Whites out a normal rectangle
RectOut(25, 24, 50, 32, DRAW_OPT_CLEAR); //Whites out a normal rectangle
RectOut(25, 8, 50, 32, DRAW_OPT_CLEAR); //Whites out a normal rectangle
RectOut(13, 16, 50, 32, DRAW_OPT_CLEAR); //Whites out a normal rectangle
RectOut(37, 16, 50, 32, DRAW_OPT_CLEAR); //Whites out a normal rectangle
while(true);
}
That "standard" way to do it is:mattallen37 wrote:Never mind, I just figured it out. The two macros have the values of 32 and 4, so I just tried combining them using the value 36, and it works. Thanks anyhow.
Code: Select all
int There = 51, AndBackAgain = 52; // This is how little folk code
int ToTheFuture = 99; // Mad scientists code this
int AndLOTRpwnsBTTF = true; // Geniuses only
RectOut(There, AndBackAgain, ToTheFuture, AndLOTRpwnsBTTF, DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE);
In Standard C and NXC, '|' is bit-wise OR. Since the drawing options are all powers of two (a common way to implement boolean options), '+' and '|' have the same effect in this case.mattallen37 wrote:Ok. I would think though that you would do something like DRAW_OPT_CLEAR + DRAW_OPT_FILL_SHAPE instead of DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE for the last parameter. Using the "+" obviously adds the constants (macros), thus still getting a sum of 36 (which is the value I am using). What does the single "|" do?
You sound like Linus . (I saw him using '+' to add macros.)mattallen37 wrote:Ok. I would think though that you would do something like DRAW_OPT_CLEAR + DRAW_OPT_FILL_SHAPE instead of DRAW_OPT_CLEAR | DRAW_OPT_FILL_SHAPE for the last parameter. Using the "+" obviously adds the constants (macros), thus still getting a sum of 36 (which is the value I am using). What does the single "|" do?