1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Text Shadow

Discussion in 'Tutorials' started by SP1D3R, Mar 28, 2017.

  1. SP1D3R

    SP1D3R Member

    Joined:
    Jun 20, 2016
    Posts:
    13
    GM Version: All
    Target Platform: Windows, but probably all
    Download: see text below
    Links: na

    Maybe some people can use this little script i created last night.
    It will transform your text with a simple shadow effect.
    Save this script as draw_text_shadow
    Code:
    /// draw_text_shadow(x, y, string, font, shadow_size, shadow_colour, text_colour);
    var _x, _y, _string, _font, _shadow_size, shadow_colour, text_colour;
    _x = argument[0];
    _y = argument[1];
    _string = argument[2];
    _font = argument[3];
    _shadow_size = argument[4];
    _shadow_colour = argument[5];
    _text_colour = argument[6];
    draw_set_font(_font);
    draw_set_colour(_shadow_colour);
    draw_text((_x + _shadow_size), (_y + _shadow_size), string(_string));
    draw_set_colour(_text_colour);
    draw_text(_x, _y, string(_string));
    Have fun with it!
     
    Last edited by a moderator: Mar 29, 2017
  2. rekamemag2

    rekamemag2 Member

    Joined:
    Apr 16, 2019
    Posts:
    2
    Hi SP1D3R,

    Thanks for your script! It got me thinking and I added another "Text Soft Shadow Version" (kinda sorta similar to photoshop drop shadows).
    Play with parameters shadow_blurriness and shadow_strenght to adjust the looks based on your font.
    Warning: Uses alot more draws to get the soft look.
    Use at your own risk.



    [​IMG]

    Code:
    /// @function draw_text_softshadow
    /// @param x_position
    /// @param y_position
    /// @param text
    /// @param font_name
    /// @param text_colour
    /// @param shadow_colour
    /// @param shadow_offset_x
    /// @param shadow_offset_y
    /// @param shadow_blurriness (higher numbers will be slower!)
    /// @param shadow_strenght of shadow, (0.01=soft, 1=strong);
    /// example: draw_text_softshadow(10,10,"Hello World!", font_name, c_white, c_black, 0,5,6,0.01, );
    
    var _x, _y, _string, _font, _offset_x, _offset_y, _blurfactor, _shadow_colour, _shadow_strenght, _text_colour, ix, iy;
    _x = argument0;
    _y = argument1;
    _string = argument2;
    _font = argument3;
    _text_colour = argument4;
    _shadow_colour = argument5;
    _offset_x = argument6;
    _offset_y = argument7;
    _blurfactor = argument8;
    _shadow_strenght = argument9;
    
    draw_set_font(_font);
    var shadow_strenght_calc = _shadow_strenght/(_blurfactor * _blurfactor)
    draw_set_alpha(shadow_strenght_calc);
    draw_set_colour(_shadow_colour);
    //draw_text((_x + _offset_x), (_y + _offset_x), string(_string));
    var bx = _blurfactor/2;
    var by = _blurfactor/2;
    
    for (ix = 0; ix < _blurfactor; ix++) {
        for (iy = 0; iy < _blurfactor; iy++) {
            draw_text((_x-bx) +_offset_x + ix, (_y-by) +_offset_y + iy, string(_string));
        }
    }
    draw_set_alpha(1);
    draw_set_colour(_text_colour);
    draw_text(_x, _y, string(_string));
    
     

    Attached Files:

    Last edited: Feb 1, 2020
    SP1D3R likes this.

Share This Page