Jump to content


Photo

Relatively blend colors in sprites ?


  • Please log in to reply
4 replies to this topic

#1 Ggd07

Ggd07

    GMC Member

  • GMC Member
  • 101 posts
  • Version:GM:Studio

Posted 08 January 2011 - 10:39 PM

Hello.

I like to ask a question, if possible.

Is there a way to relatively blend colors on a particular sprite, for example, I have a sprite of a character, and I want him to smoothly fade into blue, and back to white, and back to blue colors, to create an effect that he is glowing.

I tried something stupid.. using image_blend += color.. it blends, but it jumps to an unknown color after the particular steps.

:\

Edited by Ggd07, 09 January 2011 - 05:05 PM.

  • 0

#2 Jobo

Jobo

    No neurons left today

  • GMC Member
  • 2405 posts
  • Version:GM:Studio

Posted 08 January 2011 - 10:52 PM

Just make a sprite with it. It's a faster running process than making a code.

So the answer is: Make an animation in the sprite editor.

Edited by Jobo, 09 January 2011 - 01:21 PM.

  • 0

#3 mcmonkey

mcmonkey

    mcmonkey

  • GMC Member
  • 665 posts
  • Version:GM8

Posted 08 January 2011 - 10:54 PM

// create
mblue = 0
mgo = 1
// step
image_blend = make_color_rgb(0,0,mblue)
if mgo = 1
{
mblue += 1
}
else
{
mblue -= 1
}
if mblue > 244
{
mgo = 0
}
if mblue < 1
{
mgo = 1
}
How's that?
  • 0

#4 Ggd07

Ggd07

    GMC Member

  • GMC Member
  • 101 posts
  • Version:GM:Studio

Posted 09 January 2011 - 04:53 PM

Thanks MCMONKEY. Your idea gave me a kick start and I made a "more random" solution, that I was more interested in

    image_blend = make_color_rgb(redc,greenc,bluec);
    if bluecreverse == 0 { bluec += .5; } else { bluec -= .5; }
    if redcreverse == 0 { redc += .7; } else { redc -= .7; }
    if greencreverse == 0 { greenc += .3; } else { greenc -= .3; }
    if (bluec >= 244) {
    bluecreverse = 1;
    } else {
        if (bluec <= 10) {
        bluecreverse = 0;
        }
    }
    if (greenc >= 244) {
    greencreverse = 1;
    } else {
        if (greenc <= 10) {
        greencreverse = 0;
        }
    }
    if (redc >= 244) {
    redcreverse = 1;
    } else {
        if (redc <= 10) {
        redcreverse = 0;
        }
    }    
}

Basically, everything is so random, that totally random lighten,darken colors appear.

Thanks again mcmonkey!! <3
  • 0

#5 Katuko

Katuko

    GMC Member

  • GMC Member
  • 4886 posts

Posted 09 January 2011 - 05:34 PM

Skip the RGB values and go for HSV. That will let you do this:

Create event:
hue = 120; //or any hue you want
val = 255;
sat = 255;
fadetime = 0;
fadespeed = 0.1;

Step event:
fadetime = fadetime+fadespeed mod 360;
val = 255-(255*abs(sin(fadetime)));
image_blend = make_color_hsv(hue,val,sat);

This will make your sprite fade back and forth to the color you select via hue. If wanted, you can cycle hue as well (creating a sort of rainbow shine like in Super Mario) and also apply the color via additive blend mode and that d3d_fog trick. That makes it more of a "glow" and less of a "blend".
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users