Drawing clear solid rectangles in NXC
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Drawing clear solid rectangles in NXC
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?
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Drawing clear solid rectangles in NXC
Clear solid? What do you mean exactly? Can you draw it in ms paint or something similar so we know what it is supposed to look like?
- Xander
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Drawing clear solid rectangles in NXC
How about I post a program that draws in white.You can draw solid shapes using the DRAW_OPT_FILL_SHAPE macro. You can draw white on black using the DRAW_OPT_CLEAR macro. I want to draw solid white on a black background.
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);
}
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Drawing clear solid rectangles in NXC
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.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Drawing clear solid rectangles in NXC
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);
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Drawing clear solid rectangles in NXC
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?
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 73
- Joined: 29 Sep 2010, 12:05
Re: Drawing clear solid rectangles in NXC
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?
Regards, Morton
Re: Drawing clear solid rectangles in NXC
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?
For flags, you use Bitwise-OR ("|") *. For other stuff (I don't know what exactly), you use adding, or whatever you use. My point is... OK, hold on, I've asked it on programmers.stackexchange.com HERE.
Someone over here is using the Bitwise-OR method.
*That looks strangely like a messed up smiley.
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Drawing clear solid rectangles in NXC
Ah yes, I see it now. The third and sixth least significant bits (0x04 and 0x20) are the ones used here. Thanks for the clarification/explanation.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: No registered users and 13 guests