Author Topic: Sprites and Greyscale  (Read 4852 times)

0 Members and 1 Guest are viewing this topic.

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Sprites and Greyscale
« on: November 09, 2012, 09:48:51 pm »
So... How do I do a Pt-On() where only the 'on' points are turned on?
How do I make it so it graphs that to both buffers?
Do I need to use two commands, or can I do it all in one command?
And the same questions for Pt-Off()

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Sprites and Greyscale
« Reply #1 on: November 09, 2012, 09:53:58 pm »
Pt-On uses 'or' logic, so any black pixels in your sprite will be drawn black (n or 1 = 1), and anything white in the sprite will be transparent (n or 0 = n)
Pt-Off overwrites completely, so black will be black and white will be solid white.

To make them draw to the backbuffer, just add the ^r (radians symbol) at the end

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Sprites and Greyscale
« Reply #2 on: November 09, 2012, 10:00:03 pm »
How do I use an inverse function? Where it makes a white where it should be black, and black where it should be white?
And can I write to both buffers in one command? Not
Pt-On(X,Y,Pic1):Pt-On(X,Y,Pic1)^r
but Pt-On(X,Y,Pic1)^Coolsymbol
« Last Edit: November 09, 2012, 10:00:32 pm by dinosteven »

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Sprites and Greyscale
« Reply #3 on: November 09, 2012, 10:04:42 pm »
You can't do it in one command, nor should you want to. Grayscale sprites come in two layers, so (well, I guess you waste a few cycles reloading the x and y arguments) you'd most commonly have code that looks like pt-on(x,y,pic1) : pt-on(x,y,pic1+8)r
Pt-Change is the invert, and it uses xor logic. So anything black on the sprite will be black if the pixel that's being drawn on is white, (1 xor 0 = 1), and white (invert) if the pixel it's being drawn on is black (1 xor 1 = 0). White pixels in the sprite will be transparent (n xor 0 = n)
« Last Edit: November 09, 2012, 10:05:19 pm by squidgetx »

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Sprites and Greyscale
« Reply #4 on: November 09, 2012, 10:39:28 pm »
So say something is all white on the main buffer and either all black or all white on the back buffer. I want to do a Pt-On() of a sprite to both buffers so the black points are entirely black and the white points of the sprite depend on how it already was.
I also want to use the same sprite and turn on all points that should be white in the main buffer and turn off all points that should be white.
Basically, I want to output a sprite and its exact inverse onto a possible grey background.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Sprites and Greyscale
« Reply #5 on: November 10, 2012, 02:27:16 am »
could you draw that in a picture? i'm not really getting what you're trying to say.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Sprites and Greyscale
« Reply #6 on: November 10, 2012, 02:58:50 am »
Easiest and fastest way to draw an inverse sprite: Draw a filled sprite (or a black square) and pt-change on top of it. Great way to get transparency

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Sprites and Greyscale
« Reply #7 on: November 10, 2012, 08:49:18 am »
Here's what I wanted. Making the sprite black or white without any grey on it, regardless of the state of the background.
EDIT: But my RAM just cleared randomly, deleting all my sprites. ARGH
« Last Edit: November 10, 2012, 08:51:33 am by dinosteven »

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Sprites and Greyscale
« Reply #8 on: November 10, 2012, 08:55:26 am »
Well, that depends on what you're using. If you're using Black and white only, you ignore the back buffer entirely, but when using 3 or 4-level greyscale, just draw the sprite to both layers. That way, if it's black, it's all the way black, and white is all the way white.

To draw black, use pt-On.

To draw white, use pt-On then pt-Change (fill then invert)

To get a combination of the two, use pt-On with a silhouette, and use pt-change with a different sprite, which has all the white pixels as black.
« Last Edit: November 10, 2012, 08:57:18 am by willrandship »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Sprites and Greyscale
« Reply #9 on: November 10, 2012, 08:56:56 am »
I think pt-off is what you need.
EDIT: and an additional pt-off()^r when you use 4-lv gray.
« Last Edit: November 10, 2012, 08:57:52 am by aeTIos »
I'm not a nerd but I pretend: