Results 1 to 20 of 20

Thread: fabText(); Never use boring monochrome text again!

  1. #1
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default fabText(); Never use boring monochrome text again!

    EDIT(5/9/2015): condensed everything into a single procedure. added shiftPerc variable.

    I was bored yesterday so I started messing around the the colors on my progress reports. This is the result...

    fabText

    What does it do? It makes your text fabulous of course!

    like this:


    It's a modified version of drawText() with a few additional parameters to input.

    Here is what you need to give it:
    Simba Code:
    (txt: string; pnt: TPoint; font: string; color: TColor; shiftPerc: extended; leftToRight, shadow, random: boolean);
    where txt, pnt, font, color, and shadow are the same as in drawText(), and leftToRight and random are new.
    leftToRight just determines the direction of the hue shift (true=ROYGBIV, false=VIBGYOR).
    shiftPerc determines how much the hue is shifted. 50 --> full rainbow. I almost always use 5.
    random sets the starting hue to a random value.
    The picture above has all 3 booleans set to true:
    Simba Code:
    smartImage.fabText('bars: ' + intToStr(loadCount*28), point(mainscreen.x1+1, mainscreen.y1+15), loginchars, col, true, true, true);

    If you can't handle the full rainbow, don't worry! The hue can be shifted by any amount with shiftPerc
    Here is an example that shifts random colors between their corresponding analogous colors (30 deg hue shift):


    with random set to false:


    To get started, head on over here and pick a starting color.
    Note: the hex values need to be reversed for some reason. I wanted to use 99ffff, but to get that color I had to use TColor($ffff99). Maybe someone else can explain this.
    I recommend picking something with high saturation and lightness. All of the pictures above are at 100% saturation and 80% lightness.

    Here is the code:
    Simba Code:
    procedure TMufasaBitmap.fabText(txt: string; pnt: TPoint; font: string; color: TColor; shiftPerc: extended; leftToRight, shadow, random: boolean);
    var
      i, j, a, b, len: integer;
      step, deg, h, s, l: extended;
      aH: TExtendedArray;
      tpa, tpaShadow, temp: TPointArray;
      atpa: T2DPointArray;
      rainbow: TColorArray;
      hit: boolean;
    begin
      tpa := tpaFromText(txt, font);
      offsetTPA(tpa, pnt);
      tpaShadow := copyTPA(tpa);
      offsetTPA(tpaShadow, point(1, 1));
      self.drawTPA(tpaShadow, __SHADOW_COLOR);

      a := tpa.getBounds.x1;
      b := tpa.getBounds.x2+1;
      tpa.sortByXValue(true);
      setLength(atpa, (b-a));
      for j := a to b do
      begin
        hit := false;
        for i := 0 to high(tpa) do
        begin
          if j = tpa[i].x then
          begin
            atpa[j-a].append(tpa[i]);
            hit := true;
          end
          else if hit then break;
        end;
      end;

      colorToHSL(color, h, s, l);
      if random then h := random(100);
      len := length(atpa);
      if len < 1 then exit();
      deg := shiftPerc;
      if len = 2 then aH := [h-deg, h+deg];
      if len = 3 then aH := [h-deg, h, h+deg];
      if len < 4 then exit();
      step := (deg/((len-((len mod 2)+2))/2));
      for i := 0 to (len-1) do
      begin
        if leftToRight then
          aH.append((h-deg)+(i*step))
        else
          aH.append((h+deg)-(i*step));
      end;

      setLength(rainbow, (high(aH)+1));
      for i := 0 to high(aH) do
        rainbow[i] := hslToColor(aH[i], s, l);

      for i := 0 to high(atpa) do
        self.drawTPA(atpa[i], rainbow[i]);
    end;

    Feel free to use and modify this as you wish.

  2. #2
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    @KeepBotting
    @bonsai
    and maybe @Taric?

  3. #3
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Looks nice

  4. #4
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Awesome, rep+
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  5. #5
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Default

    Simba Code:
    function hueHueHUE()
    sat sat sat.
    got me. nice.

  6. #6
    Join Date
    Feb 2015
    Location
    Taguig, Philippines
    Posts
    342
    Mentioned
    15 Post(s)
    Quoted
    137 Post(s)

  7. #7
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    Simba Code:
    function hueHueHUE()
    got me. nice.


  8. #8
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    just updated code and attachment

  9. #9
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Haha that's a unique idea and you put it together nicely. Good job pal.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  10. #10
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    So, uhh, quick question. I'm calling fabText() 5 times in succession to display my progress report, but
    Simba Code:
    if randomCol then h := random(100);
    is giving me the same "random" number all 5 times. Why? I'm guessing it's too fast or something? If I add a small wait it fixes it but I feel like I shouldn't have to do that.

  11. #11
    Join Date
    Oct 2014
    Location
    With ezreal~
    Posts
    295
    Mentioned
    45 Post(s)
    Quoted
    255 Post(s)

    Default

    Quote Originally Posted by evilcitrus View Post
    So, uhh, quick question. I'm calling fabText() 5 times in succession to display my progress report, but
    Simba Code:
    if randomCol then h := random(100);
    is giving me the same "random" number all 5 times. Why? I'm guessing it's too fast or something? If I add a small wait it fixes it but I feel like I shouldn't have to do that.
    Simba Code:
    randomRange(0,100);
    Should give you a random number each time...

    Totally putting this in my smelting script when I get back from the Recruiters Office today. #Sexy #Iwantyourbabiesinsideofme



    It's not gay if it's efficient.

  12. #12
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Totally putting this in my smelting script when I get back from the Recruiters Office today.
    I had a feeling you would like it.

    Quote Originally Posted by Taric View Post
    Simba Code:
    randomRange(0,100);
    Should give you a random number each time...
    It's pretty inconsistent. Sometimes all 5 numbers are different, sometimes they're all the same, sometimes they're doubled up. I added a 10-15 ms wait to the procedure and it seems to be fixed.

  13. #13
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by evilcitrus View Post
    I had a feeling you would like it.



    It's pretty inconsistent. Sometimes all 5 numbers are different, sometimes they're all the same, sometimes they're doubled up. I added a 10-15 ms wait to the procedure and it seems to be fixed.
    Shot in the dark here but you could try calling
    Simba Code:
    randomize();
    before you generate your random number
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  14. #14
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    Shot in the dark here but you could try calling
    Simba Code:
    randomize();
    before you generate your random number
    Yeah I tried that but it didn't seem to help.

  15. #15
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by evilcitrus View Post
    Yeah I tried that but it didn't seem to help.
    *shrug*

    Simba Code:
    program new;
    var
      i, j:integer;

    begin
    for i := 0 to 49 do
     begin
       num := random(10);
       writeLn(j);
     end;
    end.

    That generates 50 numbers, different one each time & no wait in between, try using it like that
    Last edited by KeepBotting; 04-07-2015 at 08:37 PM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  16. #16
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Awesome release! I have a soft spot for silly code that does entertaining things.

    I almost feel like Taric is the only one who should be able to use something this fabulous.

    Can you explain stupidsort? Seems like you're sorting the X value after sorting the X value?

    Quote Originally Posted by evilcitrus View Post
    ... giving me the same "random" number all 5 times. Why? I'm guessing it's too fast or something? If I add a small wait it fixes it but I feel like I shouldn't have to do that.
    Quote Originally Posted by KeepBotting View Post
    *shrug*
    Simba Code:
    program broken;
    That generates 50 numbers, different one each time & no wait in between, try using it like that
    I suspect that was a phone post. The writeln would cause a delay too.

    This one runs fine, though. evilcitrus: if you writeln your 'h' value you will see it changing.

    What is probably happening is you are painting all 5 of them so fast to smartimage that it doesn't even update any of them except the last one. The delay you're needing is the time in between smartimage paints.

    Simba Code:
    program new;
    var
      i :integer;
      tia: TIntegerArray;

    begin
      setLength(tia, 50);
      for i := 0 to 49 do
      begin
        tia[i] := random(10);
      end;
      writeln(tia);
    end.

    Progress Report:
    Compiled successfully in 562 ms.
    [4, 7, 6, 1, 8, 9, 9, 0, 0, 9, 4, 5, 8, 7, 3, 3, 8, 2, 2, 1, 3, 7, 0, 7, 5, 8, 0, 0, 6, 4, 6, 9, 2, 3, 3, 7, 4, 1, 7, 0, 4, 1, 7, 4, 5, 8, 3, 2, 6, 0]

  17. #17
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    Can you explain stupidsort? Seems like you're sorting the X value after sorting the X value?
    It groups the TPoints from the tpa into columns (same X value) and makes each column a separate tpa in an atpa. Maybe there's a better way to do that, but I was just making it up as I went along.

    if you writeln your 'h' value you will see it changing
    I did that and was getting things like
    37
    37
    61
    61
    5

  18. #18
    Join Date
    Oct 2014
    Location
    With ezreal~
    Posts
    295
    Mentioned
    45 Post(s)
    Quoted
    255 Post(s)

    Default

    10/10 Would take to my mothers wedding.




    It's not gay if it's efficient.

  19. #19
    Join Date
    May 2012
    Location
    USA
    Posts
    169
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    Definitely going to try and use this next month when I work on scripting lol. Probably makes it 3x more fun.

  20. #20
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Slight update for anyone who cares.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •