Author Topic: Quick Grayscale Tutorial  (Read 7994 times)

0 Members and 1 Guest are viewing this topic.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Quick Grayscale Tutorial
« on: February 17, 2011, 12:02:11 pm »
Quick Grayscale Tutorial

3 level gray:
Three level grayscale is utilized by using the command DispGraphr in place of the normal DispGraph command. Three level gray uses the backbuffer (L3) and the front buffer (L6). Everything on the back buffer will show as gray while everything on the front buffer will show as black. The front buffer is drawn over the back buffer, so if a pixel is "on" on both the front and back buffers, it will be shown as black.

You can change the common drawing operations Pt-On, Pt-Off, Pt-Change, Pxl-On, ClrDraw, Rect, Line, DrawInv, etc. to operate on the back buffer by adding the raidan r at the end of the command. For example, Pt-On(X,Y,Pic1)r will draw Pic1 to the backbuffer. If you then look at it with DispGraph, you will see it in gray.

Text, by default is drawn directly to the screen and not to the buffer. For this reason, it can appear as grayscale because it is being erased every time you call DispGraphr, and then redrawn very quickly. To make it so that text is drawn to the buffer, put a Fix 5 at the beginning of the program (and a Fix 4 at the end). To draw text to the back buffer, you will have to Exch the back and front buffers, write to the front buffer, and switch back:
Code: [Select]
Exch(L3,L6,768): Text(X,Y,"Text") : Exch(L3,L6,768)
4 level gray
With four level gray, the front buffer becomes somewhat transparent. Use the following table to figure out the pixel colors:
Code: [Select]
Front:Back:Color
0    :1   :Light Gray
0    :0   :White
1    :0   :Dark Gray
1    :1   :Black

Buffer operations remain the same. To display in four level gray, use DispGraphrr

Note: In order for the grayscale to show up, you must put the DispGraphr or DispGraphrr in a loop. In monochrome, you can get away with this:
Code: [Select]
:Pt-On(X,Y,Pic1)
:DispGraph
:Repeat getKey
:End
But with grayscale, you'll have to write the code like this:
Code: (displays Pic1 in dark gray) [Select]
:Pt-On(X,Y,Pic1)
:Repeat getKey
:DispGraph[sup]r[/sup][sup]r[/sup]
:End

edit: 1000 posts :D
« Last Edit: February 17, 2011, 12:02:37 pm by squidgetx »

Offline nabako

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Quick Grayscale Tutorial
« Reply #1 on: March 08, 2016, 12:48:05 pm »
I do have a question about the code You showed there.
What exactly is ""?
Is it a command? I only found "sub(" as a command.

The topic may be old, but I hope You anwser.

Nabako
Still a learning Axe coder, but lots of experience with BASIC :)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Quick Grayscale Tutorial
« Reply #2 on: March 08, 2016, 01:39:44 pm »
@nabako As you may be able to tell by your post's weird formatting, "[sub]" is the forum's opening tag for subscript text. However, I believe you may have misread what actually said "[sup]", which is the forum's opening tag for superscript text.

Neither of these tags work in code boxes, though, which the author of the original post didn't seem to realize. So I'm guessing you're really wondering about "[sup]r[/sup]", which is supposed to represent a superscript "r". On the calculator, this is the radians token, found in the angle (2nd + apps) menu.

Offline nabako

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
Re: Quick Grayscale Tutorial
« Reply #3 on: March 09, 2016, 06:41:45 am »
Ah okay  ;D
Still learning...
Now i do understand how it works.
Really appreciate your help.

Nabako
Still a learning Axe coder, but lots of experience with BASIC :)

Offline ClainBill

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +1/-0
  • Everybody's just a FREAK
    • View Profile
    • My still developing website
Re: Quick Grayscale Tutorial
« Reply #4 on: January 24, 2019, 06:49:32 am »
I'm new to this so don't judge me, but could you explain 4 level grayscale in more detail?
i've pretty much nailed 2 level and got the hang of 3 but 4 just confuses me

Thanks
"I don't think I've ever looked in this drawer." (opens it) "Wow, a gun!"

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Quick Grayscale Tutorial
« Reply #5 on: January 24, 2019, 08:02:10 am »
As in the concept? Think of buffers as two sheets of semi-transparent papers stacked together. If something is located on the both sheets, it will look the darkest (black). If there is nothing on both sheets, well, then there won't be anything (white). For greys, things drawn only on the back sheet will look lighter than the things only drawn on the front sheet because the paper is semi-transparent, right?

Therefore
* drawn on both front and back - black
* drawn on neither - white
* drawn on front only - darker gray
* drawn on back only - lighter gray

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Quick Grayscale Tutorial
« Reply #6 on: January 24, 2019, 06:20:32 pm »
O_o Yeong actually reappeared and posted? Wow!