Hi guys! I'm creating a game in ice but haven't been able to figure out how to create transparent sprites and export them to my calc yet. Could someone help me out please?
-
commandblockguy
- Minor Calculator Deity (Posts: 1129)
- 05 Sep 2020 12:19:48 am
- Last edited by commandblockguy on 05 Sep 2020 11:33:47 am; edited 1 time in total
I'd recommend checking out the convimg documentation.
Basically, you'll want to pick one color to use as the background that should be replaced with transparency - I like either hot pink or green, whichever is less likely to appear in my sprites.
Then, you need to create a fixed color palette entry to use for this color - generally, you can use the index 0 for this.
If you're using an index besides 0, you need to run SetTransparentColor for that color.
Here's an example convimg.yaml file - just run convimg in the same directory as this file, and it will produce ice.txt with the hex codes for the sprite.
Assuming that your background is #00ff00 (max green):
Code:
EDIT: the syntax in the example was slightly outdated - I updated it
Basically, you'll want to pick one color to use as the background that should be replaced with transparency - I like either hot pink or green, whichever is less likely to appear in my sprites.
Then, you need to create a fixed color palette entry to use for this color - generally, you can use the index 0 for this.
If you're using an index besides 0, you need to run SetTransparentColor for that color.
Here's an example convimg.yaml file - just run convimg in the same directory as this file, and it will produce ice.txt with the hex codes for the sprite.
Assuming that your background is #00ff00 (max green):
Code:
output: ice
palettes:
- palette
converts:
- sprites
palette: palette
fixed-entries:
- color: {index: 0, r: 0, g: 255, b: 0}
images: automatic
convert: sprites
palette: palette
transparent-color-index: 0
images:
- (your sprites)
EDIT: the syntax in the example was slightly outdated - I updated it
Thank you! The ice documentation was outdated, so I was a bit confused
EDIT: can I create transparent sprites using the setTransparentColor command and the sprite creator on calc? And also, does setTransparentColor use xlibc colors or hex colors? And another question how can I get sprites to be in an appvar and use them later?
EDIT: can I create transparent sprites using the setTransparentColor command and the sprite creator on calc? And also, does setTransparentColor use xlibc colors or hex colors? And another question how can I get sprites to be in an appvar and use them later?
This code is assuming that you're using a custom palette, which you probably should be doing unless you're doing all of the graphics on-calc.
If you still want to use the xlibc palette, just use setTransparentColor with the xlib color of the color that you want to be transparent.
You can use convimg to produce a sprites appvar - here's an example convimg.yaml for a custom palette:
Code:
And here's one that uses xlibc:
Code:
Unfortunately, there's not really an easy way to get sprites out of the appvar using ICE, since the offsets of the sprites are not available:
If you still want to use the xlibc palette, just use setTransparentColor with the xlib color of the color that you want to be transparent.
You can use convimg to produce a sprites appvar - here's an example convimg.yaml for a custom palette:
Code:
palettes:
- name: global_palette
fixed-entries:
- color: {index: 0, r: 255, g: 255, b: 255}
images: automatic
converts:
- name: sprites
palette: global_palette
images:
- (your images)
outputs:
- type: appvar
name: vargfx
source-format: ice
palettes:
- global_palette
converts:
- sprites
And here's one that uses xlibc:
Code:
converts:
- name: sprites
palette: xlibc
images:
- (your images)
outputs:
- type: appvar
name: vargfx
source-format: ice
converts:
- sprites
Unfortunately, there's not really an easy way to get sprites out of the appvar using ICE, since the offsets of the sprites are not available:
Quote:
<commandz> should source-format: ice for an appvar convert produce additional output besides the 8xv?
<MateoC> PT_ still hasn't told me what it should do; so it does the same thing as the "none" option right now
<commandz> wonderful
<commandz> maybe just a TXT with offsets? idk
<MateoC> idk :P
<MateoC> don't want to add anything and then have to change it
<MateoC> PT_ still hasn't told me what it should do; so it does the same thing as the "none" option right now
<commandz> wonderful
<commandz> maybe just a TXT with offsets? idk
<MateoC> idk :P
<MateoC> don't want to add anything and then have to change it
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
» 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
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