Drawing clear solid rectangles in NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Drawing clear solid rectangles in NXC

Post by mattallen37 »

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 ;)
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: Drawing clear solid rectangles in NXC

Post by mightor »

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
| 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)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Drawing clear solid rectangles in NXC

Post by mattallen37 »

How about I post a program that draws in white.

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);
}
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.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Drawing clear solid rectangles in NXC

Post by mattallen37 »

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 ;)
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Drawing clear solid rectangles in NXC

Post by muntoo »

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.
That "standard" way to do it is:

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);
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Drawing clear solid rectangles in NXC

Post by mattallen37 »

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 ;)
m-goldberg
Posts: 73
Joined: 29 Sep 2010, 12:05

Re: Drawing clear solid rectangles in NXC

Post by m-goldberg »

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?
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.
Regards, Morton
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Drawing clear solid rectangles in NXC

Post by muntoo »

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.)

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.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Drawing clear solid rectangles in NXC

Post by mattallen37 »

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 ;)
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 4 guests