Author Topic: Round Mask of a Sprite  (Read 5226 times)

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Round Mask of a Sprite
« on: 2009-Dec-12 »
I need to grab a sprite from a background image , thats easy done, but I need to make it to display a round sprite not square Just like on the iphone when selecting text you get a round select tool.


in other words I need the  hole in the middle to be my sprite.

please help.



Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1631
  • Particle Hawk
    • View Profile
Re: Round Mask of a Sprite
« Reply #1 on: 2009-Dec-13 »
Place this over your image....it is 128x128, you might need to adjust the size.
The edges are black, this you might also need to change this.

If you need it to be 32x32, edit in mspaint, and stretch/skew 25% 25%
If you need it to be 64x64, edit in mspaint, and stretch/skew 50% 50%
Dont resize it too much, you might introduce aliasing and get pink edge outline.
Best to start a new one the size you need it.

Edit: A better Alternate Solution for a circular sprite in my message below, has a sample attached to it.

[attachment deleted by admin]
« Last Edit: 2009-Dec-13 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Re: Round Mask of a Sprite
« Reply #2 on: 2009-Dec-13 »
before going down the road  with this png file  is it going to allow me to have a round sprite or just a square with a hole in the middle showing the back ground.

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Re: Round Mask of a Sprite
« Reply #3 on: 2009-Dec-13 »
I think you missed understood me.  but thanks, john

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Round Mask of a Sprite
« Reply #4 on: 2009-Dec-13 »
To grab a round sprite you need to color the part you don't want with the color for transparency. For example if you use the sprite hemlos posted, you set the transparency color to pink and draw it over the selection, then you change the transparency color to black and grab the sprite. This will make the black circle transparent but also any black colors in your sprite. Best would probably be to invert the colors, the outline of the circle in pink and center in black.

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Re: Round Mask of a Sprite
« Reply #5 on: 2009-Dec-13 »
I see, I will try and have a go, Many thank to both of you.

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Re: Round Mask of a Sprite
« Reply #6 on: 2009-Dec-13 »
still no luck, heres the code, sorry for being a ass,  but still not working, help

      SETTRANSPARENCY RGB(255,0,128)
      DRAWSPRITE test[PINK_HOLE].Sprite_number, test[SAS_MAIN].MouseX, test[SAS_MAIN].MouseY

      SETTRANSPARENCY RGB(0,0,0)            
      
      GRABSPRITE test[ZOOM_KEY_SPRITE].Sprite_number,test[SAS_MAIN].MouseX, test[SAS_MAIN].MouseY,22, 22

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1631
  • Particle Hawk
    • View Profile
Re: Round Mask of a Sprite
« Reply #7 on: 2009-Dec-14 »
Here you go, this is an alternative using polyvectors...its simple and looks cool.

http://www.glbasic.com/forum/index.php?topic=3951.0
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Re: Round Mask of a Sprite
« Reply #8 on: 2009-Dec-14 »
nice code, looks really good, thanks for the help.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1631
  • Particle Hawk
    • View Profile
Re: Round Mask of a Sprite
« Reply #9 on: 2009-Dec-15 »
Youre welcome, glad you like it..enjoy.
Im sure ill find a good use for it as well, i am impressed with the outcome.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline spudgunjake

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
Re: Round Mask of a Sprite
« Reply #10 on: 2009-Dec-16 »
I managed to do it another way. as well.

Is it true the getpixel command only gets from the back buffer and not from a virtual screen.

It would be nice to have the SETTRANSPARENCY command with work with any draw command. it would make life a lot easer

e.g drawsprite my_sprite, 0, 0, RGB(128,128,128) I remember on allegro you could do something like this to set TRANSPARENCY on the  fly.


Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Round Mask of a Sprite
« Reply #11 on: 2009-Dec-16 »
You can only set transparency before you create the sprite. Either by loading or grabbing. But you can change as often as you like.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1631
  • Particle Hawk
    • View Profile
Re: Round Mask of a Sprite
« Reply #12 on: 2009-Dec-17 »
Is it true the getpixel command only gets from the back buffer and not from a virtual screen.

I believe so...however, you can quickly clear the backbuffer with BLACKSCREEN command.
Getpixel is slow as heck, you should avoid this, or use it on just a few pixels.

Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10689
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Round Mask of a Sprite
« Reply #13 on: 2009-Dec-17 »
I think GETPIXEL also works on offscreen surfaces.