Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 picXor ???
Index -> Programming, Turing -> Turing Tutorials
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message

PostPosted: Fri Jan 09, 2004 4:21 pm   Post subject: picXor ???

As most of you know when you draw a pic on an existing background with picXor the colours get all messed up. Why does this happen and why would we ever use it?

What is happening?
Each pixel in the picture is being stored as a number. Instead of replacing the old pixel with the new pixel (as with picCopy) the pixel displayed becomes
<old pixel> XOR <new pixel>
so if the old pixel is colour 6 and the new one is colour 5 the result is colour 3.

XOR (exclusive or)
Each of the numbers is ultimately stored in its binary form so (in 4 bits):
6 = 0110
5 = 0101

If I XOR these two numbers I do it one bit at a time following the rules for exclusive or.

Exclusive or is basically the english version of the OR, one or the other, but not both.
0 XOR 0 = 0
1 XOR 0 = 1
0 XOR 1 = 1
1 XOR 1 = 0
XOR 0101

or 3.

Why the heck would you ever use this???
Well XOR has the neat property. When you XOR a picture onto a backround the colours get messed up, but if you XOR the same picture back to the same spot it refreshes the old background. So if I XOR my 5 back on the 3 I should get 6.


like such.

PostPosted: Fri Jan 09, 2004 7:24 pm   Post subject: (No subject)

XOR is the most useless command ive ever seen in Turing. I asked my teacher how to stop the flickering in my program...he told me to use i did...and soon after gave up on a graphical project, and went to text based. Not until I joined CompSci did I learn
I dont think there is a real point anymore to XOR... but maybe the creators of Turing didnt know that the combo of the setscreen and view.update would stop flickering, so they included the XOR gate? Im not quite sure...but ill never use it, unless there is a really good reason to.

PostPosted: Fri Jan 09, 2004 7:32 pm   Post subject: (No subject)

Well the inclusion of XOR came before the inclusion of page-flipping (the combo of "offscreenonly" and View.Update). It is only good on extreamly slow machines. I was not advocating it use, just clearing up confusion. As an aside, the old DOS version allowed you to set your screen to draw in XOR mode. This was very good for drawing preview lines and boxes.

PostPosted: Fri Jan 09, 2004 8:01 pm   Post subject: (No subject)

I see...I was just merely stating that in the modern version of Turing, XOR is quite useless....hmm, by the way, why is this under [Tutorials]?? heh

PostPosted: Fri Jan 09, 2004 8:23 pm   Post subject: (No subject)

I saw it as a tutorial. As per a tutorial is:
Something that provides special, often individual instruction, especially:
A book or class that provides instruction in a particular area.

it bugs me seeing picXor explained as "when the colours go all weird". To me tutorials are the places people go to learn the basics or dig up obscure tidbits. It is not a "how-to" tutorial, but rather a "what is?" tutorial. I might be wrong, if so they can move it, but I think this is the best place for it.

PostPosted: Fri Jan 09, 2004 9:31 pm   Post subject: (No subject)

LOL... tutorial... ahaha

PostPosted: Fri Jan 09, 2004 10:14 pm   Post subject: (No subject)

well XOR is just a logic gate operator that returns true, only when two values are different. In picture mode, it's a binary operation that allows you to draw those weird colored preview lines... Which is not that great anyways since the colors are so messed up Rolling Eyes
Latest from Tony's programming blog. DWITE - a programming contest.

PostPosted: Sat Jan 10, 2004 2:52 am   Post subject: (No subject)

well it is good to know if you whont to wrok with some of the graifks stuff in dos c++ witch some schools uses for grade 10 compsci.

Thank you McKenzie for wirting this up.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!

PostPosted: Sat Jan 10, 2004 9:52 am   Post subject: (No subject)

It's more trivia than anything else, and I knew that upfront. One of the interesting things about it is if you extend the idea it allows you to swap the value in two variables without the need for a third like so:

//sorry for using C in a Turing section
int x=123, y=6;
x=x^y;      // ^ is the bitwsie XOR in C

At the end of the code x & y will have their values swaped. Highly efficient, Questionable. Clear code, nope. Alpha Geek status requirement...yep.

PostPosted: Sun May 09, 2004 12:41 pm   Post subject: XORING is okay

I think XORing is okay, but you almost have to change the colours to their opposited and then it will look fine.

PostPosted: Mon May 31, 2004 7:12 am   Post subject: (No subject)

picXor is pretty neat.

I use it frequently where i don't want to have to redraw segments of background.

i'll dig up the file at school, but it is possible to have some nice effects with picxor.

Mr. Green


PostPosted: Sun Dec 25, 2005 9:39 pm   Post subject: (No subject)

Could you post a sample code using picXor?

Thanks Smile

PostPosted: Sun Dec 25, 2005 11:52 pm   Post subject: (No subject)

Just make it yourself like so:

Pic.Draw (pic, 0, 0, picCopy)
Pic.Draw (pic, 0, 0, picXor)

PostPosted: Sun Jan 01, 2006 5:23 pm   Post subject: (No subject)

Hmm I think Xor could be useful for encryption purposes, Also I was talking to my dad about this, he said back in his days of BASIC (haha) they used Xor to light up/dark out pixels for graphical purposes...

PostPosted: Sun Jan 01, 2006 6:01 pm   Post subject: (No subject)

Is there a way to use Xor in Turing without using it as picXor?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to: