Advertisement
Night_Wood

draw_text_wavy

Jan 5th, 2017
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///draw_text_wavy(x, y, text, height, [sep], [wavelength], [time])
  2. // Arguments in [brackets] are optional
  3.  
  4. // Variables
  5. var drawX, drawY, text, height, sep, wavelength, time;
  6. drawX       = argument[0];
  7. drawY       = argument[1];
  8. text        = argument[2];
  9. height      = argument[3];  // Amplitude of the wave
  10. sep         = 0;            // Separation between chars
  11. wavelength  = 2 * pi;       // 2*pi is one full wavelength
  12. time        = 500;          // [1 -- X], larger means slower
  13.  
  14. // Set optional arguments if they are provided
  15. if(argument_count >= 5) { sep = argument[4]; }
  16. if(argument_count >= 6) { wavelength = argument[5]; }
  17. if(argument_count >= 7) { time = argument[6]; }
  18.  
  19. draw_set_valign(fa_center);
  20.  
  21. for(var i = 1; i <= string_length(text); i++) {
  22.     var char = string_char_at(text, i);
  23.     var dy = drawY + (height * sin((i * wavelength / string_length(text))
  24.             + (current_time / time)));
  25.    
  26.     draw_text(drawX, dy, string_char_at(text, i));
  27.    
  28.     drawX += string_width(char) + sep;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement