I know I can set a .png to the same color as the background with gfx_TransparentSprite() but how do I make it smoothly go over the sprite behind it, like a mouse cursor?
You'll need to:
Pick a transparency color to use in your sprites. In your PNG images, set anything that you want to be transparent to be this color.
Add a fixed entry in your palette in the convimg.yaml file, where r, g, and b correspond with the color you used, like so:

Code:
fixed-entries:
  - color: {index: 0, r: 255, g: 0, b: 255}

Use gfx_SetTransparentColor to set the transparency color index to the value of index you used for the palette entry.
Use gfx_TransparentSprite to display the sprite.

If you're using the default palette, you can skip the fixed entry step, and just use whichever xlibc palette entry is closest to the transparency color you chose as the argument for gfx_SetTransparentColor:
commandblockguy wrote:
You'll need to:
Pick a transparency color to use in your sprites. In your PNG images, set anything that you want to be transparent to be this color.
Add a fixed entry in your palette in the convimg.yaml file, where r, g, and b correspond with the color you used, like so:

Code:
fixed-entries:
  - color: {index: 0, r: 255, g: 0, b: 255}

Use gfx_SetTransparentColor to set the transparency color index to the value of index you used for the palette entry.
Use gfx_TransparentSprite to display the sprite.

If you're using the default palette, you can skip the fixed entry step, and just use whichever xlibc palette entry is closest to the transparency color you chose as the argument for gfx_SetTransparentColor:

I understand that, like I said, but is there a way to make blank pixels actually transparent? If I had a background like Bliss from Windows XP, and I wanted a cursor on it without a rectangle of solid color around it, how would I do that? How do I make transparent pixels actually transparent?
Quote:
I understand that, like I said, but is there a way to make blank pixels actually transparent? If I had a background like Bliss from Windows XP, and I wanted a cursor on it without a rectangle of solid color around it, how would I do that? How do I make transparent pixels actually transparent?

Did you read what he actually said? He explained what you want to do quite well.

This example also shows what you want to do: https://github.com/CE-Programming/toolchain/blob/master/examples/graphx/sprites
This example also shows mouse-like sprite behavior: https://github.com/CE-Programming/toolchain/tree/master/examples/graphx/sprites_moving

Look at the examples please.
MateoConLechuga wrote:
Quote:
I understand that, like I said, but is there a way to make blank pixels actually transparent? If I had a background like Bliss from Windows XP, and I wanted a cursor on it without a rectangle of solid color around it, how would I do that? How do I make transparent pixels actually transparent?

Did you read what he actually said? He explained what you want to do quite well.

This example also shows what you want to do: https://github.com/CE-Programming/toolchain/blob/master/examples/graphx/sprites
This example also shows mouse-like sprite behavior: https://github.com/CE-Programming/toolchain/tree/master/examples/graphx/sprites_moving

Look at the examples please.

I already did. My mouse code is based off of it. It works just fine. I have a detailed background with multiple different colors behind the cursor. When you set the transparency color, you are setting a solid color. I can change the color to be similar to the background, sure, but I want it TRANSPARENT. Included picture: https://imgur.com/a/JAhZ7zd
commandblockguy only said how to change the color of the "transparency"
Did you look at any of the links I gave you. It shows you *exactly* how to do what you want. I'm not the one interpreting what you are saying incorrectly Wink

The transparency color is NOT the background color. It is a color in the PNG that is chosen to be the color that will allow any pixel behind it to show through.
If you can see a rectangle of pixels like that, that means that the transparency isn't working correctly.
Internally, "transparency" is treated as a special color, so you have to make sure that the index for that color is set properly and that the color that's used for transparency in your sprite has the same index as the fake transparency color. If those aren't set properly, you'll just get a regular non-transparent color instead of a transparent one, like you see there.
You can think of it as basically taking any pixels in the sprite that exactly match the color you specify for gfx_SetTransparentColor, and then just not drawing those pixels. If the color doesn't exactly match the special transparency color, it will get drawn even if you don't want it to.

It would be helpful if we could see your code, the convimg.yaml file, and the image that you used for the cursor, so that we could figure out what's not working. Most likely, the image's background color just doesn't match the transparent index you specified.
commandblockguy wrote:
If you can see a rectangle of pixels like that, that means that the transparency isn't working correctly.
Internally, "transparency" is treated as a special color, so you have to make sure that the index for that color is set properly and that the color that's used for transparency in your sprite has the same index as the fake transparency color. If those aren't set properly, you'll just get a regular non-transparent color instead of a transparent one, like you see there.

It would be helpful if we could see your code, the convimg.yaml file, and the image that you used for the cursor, so that we could figure out what's not working. Most likely, the image's background color just doesn't match the transparent index you specified.

Ok, I think I understand now. I believe something to be wrong with the example then, or just my copy of the compiler, because it even happens to the examples. I’ll troubleshoot more tomorrow. Thank you for the help!
slimefolf wrote:
If I had a background like Bliss from Windows XP, and I wanted a cursor on it without a rectangle of solid color around it, how would I do that? How do I make transparent pixels actually transparent?


So something like this?
epsilon5 wrote:
slimefolf wrote:
If I had a background like Bliss from Windows XP, and I wanted a cursor on it without a rectangle of solid color around it, how would I do that? How do I make transparent pixels actually transparent?


So something like this?

Yes
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement