- How do I grab gfx current transparent color?
- 26 Feb 2021 05:02:07 pm
- Last edited by Alvajoy123 on 26 Feb 2021 08:45:57 pm; edited 3 times in total
So I've been working on a oxygen and just ran into some "errors" testing out sprite masking.
I need to grab the currently set gfx transparent color.
Users stated in the chat why don't I just set a variable to the transparent color.
I simple don't risk increase the size of oxygen and making it more complicated for devs to use, or I can simple you force devs to set a variable to a transparent color ... or I can simply grab it from the memory or something.
here's some code: (Not finished)
Code:
The dev gives a sprite they want to put a mask on and it set it to the transparent color.
// Don't mind the typo's <_<
I need to grab the currently set gfx transparent color.
Users stated in the chat why don't I just set a variable to the transparent color.
I simple don't risk increase the size of oxygen and making it more complicated for devs to use, or I can simple you force devs to set a variable to a transparent color ... or I can simply grab it from the memory or something.
here's some code: (Not finished)
Code:
void oxy_ApplyMaskToSprite(gfx_sprite_t *in_sprite, const gfx_sprite_t *mask_sprite)
{
uint8_t *in_data = in_sprite->data;
uint8_t in_width = in_sprite->width;
uint8_t in_height = in_sprite->height;
uint8_t *mask_data = mask_sprite->data;
uint8_t mask_width = mask_sprite->width;
uint8_t mask_height = mask_sprite->height;
uint8_t dim_error;
if (mask_width != in_width)
dim_error = 1;
if (mask_hieght != in_hieght)
dim_error = 1;
if (dim_error){
gfx_sprite_t *NewMask_Sprite;
gfx_MallocSprite(in_width, in_hieght);
gfx_ScaleSprite(mask_sprite, NewMask_Sprite);
// resets all mask info
mask_data = NewMask_Sprite->data;
mask_width = NewMask_Sprite->width;
mask_height = NewMask_Sprite->height;
// process
for (int i; i < mask_width * mask_hieght; i++){
if (mask_data[i] == oxy_ReturnTransparentColor()){
in_data[i] = oxy_ReturnTransparentColor();
}
}
return;
}
for (int i; i < mask_width * mask_hieght; i++){
if (mask_data[i] == oxy_ReturnTransparentColor()){
in_data[i] = oxy_ReturnTransparentColor();
}
}
return;
}
The dev gives a sprite they want to put a mask on and it set it to the transparent color.
// Don't mind the typo's <_<