Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Text Gradient tester.


  • Please log in to reply
11 replies to this topic
gamax92
  • Members
  • 411 posts
  • Last active: Aug 06 2013 05:00 AM
  • Joined: 05 Dec 2010
Gradient text tester
I'm seeing if I can maniplate a percentage and a loop field.
So far it seems to be working.
I can also get a gray gradient.
And a cyan colored one too!

I also got this weird inverted one.

tomoe_uehara
  • Members
  • 2112 posts
  • Last active: Apr 06 2014 06:00 PM
  • Joined: 05 Sep 2009
Wow cool!! 8)

Eedis
  • Members
  • 1774 posts
  • Last active: Feb 07 2014 01:11 AM
  • Joined: 12 Jun 2009
Do share!

gamax92
  • Members
  • 411 posts
  • Last active: Aug 06 2013 05:00 AM
  • Joined: 05 Dec 2010
String =

(

Place strings here.

They will become gradients!

)



Loop, parse, String, `n, `r

{

	SubString := A_LoopField

	Loop, % StrLen(SubString)

	{

		SetFormat, Float, 100.100

		Percentage := A_Index/StrLen(SubString)

		SetFormat, Float, 3.0



; Mess with these values, they produce cool gradients

		R := 255 - (255 * Percentage)

		G := 255

		B := 0



		SetFormat, Float, 100.100

		Encoded .= "[color=#" . RGB2HEX(R . "|" . G . "|" . B, "|") . "]" . SubStr(SubString,A_Index,1) . "[/color]"

	}

	Encoded .= "`r`n"

}

StringTrimRight, Encoded, Encoded, 2

Clipboard := Encoded

ExitApp

Return



;Credit goes to SKAN for this.

RGB2HEX(RGBString,Delimiter="") 

{ 

 If Delimiter=

    Delimiter=,

 StringSplit,_RGB,RGBString,%Delimiter%



 SetFormat, Integer, Hex 

 _RGB1+=0

 _RGB2+=0

 _RGB3+=0



 If StrLen(_RGB1) = 3

    _RGB1= 0%_RGB1%



 If StrLen(_RGB2) = 3

    _RGB2= 0%_RGB2%



 If StrLen(_RGB3) = 3

    _RGB3= 0%_RGB3%



 SetFormat, Integer, D 

 HEXString = % _RGB1 _RGB2 _RGB3

 StringReplace, HEXString, HEXString,0x,,All

 StringUpper, HEXString, HEXString



Return, HEXString

}


Eedis
  • Members
  • 1774 posts
  • Last active: Feb 07 2014 01:11 AM
  • Joined: 12 Jun 2009
Place strings here.
They will become gradients!

Eedis
  • Members
  • 1774 posts
  • Last active: Feb 07 2014 01:11 AM
  • Joined: 12 Jun 2009
That is cool. I like it. :) Thanks.

SKAN
  • Administrators
  • 9105 posts
  • Last active:
  • Joined: 26 Dec 2005
Related: PhiLho's Version <!-- m -->http://www.autohotke... ... 0308#60308<!-- m -->

TheDewd
  • Members
  • 835 posts
  • Last active: Today, 12:58 PM
  • Joined: 28 Mar 2010
Cool!

I can't get PhiLho's version to work with AHK_L.

sinkfaze
  • Moderators
  • 6365 posts
  • Last active:
  • Joined: 18 Mar 2008
Here's a re-write of PhiLho's function compatible with AHK_L:

Escape::
Clipboard :=	GradientText(Clipboard)
return

GradientText(text) {

	rgb :=	[]
	Loop, 6
	{
		Random, out, %	(A_Index < 4) ? 50 : -10, %	(A_Index < 4) ? 240 : 10
		rgb.Insert(out)
	}
	Loop, parse, text
	{
		if	(A_LoopField~="\S")
		{
			For i, c in rgb
				d :=	rgb[i + 3], rgb[i] +=	(c + d < 0 || c + d > 255) ? (-d) : d
			Until	(i=3)
			orig :=	A_FormatInteger
			SetFormat, Integer, Hex
			gradientText .=	"[color=#" SubStr(0x1000000 + (rgb[1] << 16) + (rgb[2] << 8) + rgb[3],4) "]" A_LoopField "[/color]"
			SetFormat, Integer, %orig%
		}
		else	gradientText .=	A_LoopField
	}
	return	gradientText
}


nimda
  • Members
  • 4368 posts
  • Last active: Jan 15 2014 02:47 PM
  • Joined: 26 Dec 2010
Nice work, sinkfaze! This version is fairly interesting... it'll take me a few minutes to understand it!
gamax92's script seems to follow a slightly different method.

TheDewd
  • Members
  • 835 posts
  • Last active: Today, 12:58 PM
  • Joined: 28 Mar 2010

Here's a re-write of PhiLho's function compatible with AHK_L:...

Thanks, sinkfaze! Works quite nicely now...

sinkfaze
  • Moderators
  • 6365 posts
  • Last active:
  • Joined: 18 Mar 2008
I made what should've been a rather obvious change in the function to allow it to skip any whitespace and not just spaces. I also simplified the internal math with a for-loop.