Jump to content


Photo

Text Gradient tester.


  • Please log in to reply
11 replies to this topic

#1 gamax92

gamax92
  • Members
  • 410 posts

Posted 11 March 2012 - 03:23 AM

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.

#2 tomoe_uehara

tomoe_uehara
  • Members
  • 2077 posts

Posted 11 March 2012 - 04:02 AM

Wow cool!! 8)

#3 Eedis

Eedis
  • Members
  • 1591 posts

Posted 11 March 2012 - 04:20 AM

Do share!

#4 gamax92

gamax92
  • Members
  • 410 posts

Posted 11 March 2012 - 05:00 AM

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

}


#5 Eedis

Eedis
  • Members
  • 1591 posts

Posted 11 March 2012 - 07:03 AM

Place strings here.
They will become gradients!

#6 Eedis

Eedis
  • Members
  • 1591 posts

Posted 11 March 2012 - 07:09 AM

That is cool. I like it. :) Thanks.

#7 SKAN

SKAN
  • Administrators
  • 9062 posts

Posted 11 March 2012 - 03:36 PM

Related: PhiLho's Version <!-- m -->http://www.autohotke... ... 0308#60308<!-- m -->

#8 TheDewd

TheDewd
  • Members
  • 823 posts

Posted 12 March 2012 - 08:08 PM

Cool!

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

#9 sinkfaze

sinkfaze
  • Moderators
  • 6087 posts

Posted 12 March 2012 - 09:22 PM

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
}


#10 nimda

nimda
  • Members
  • 4301 posts

Posted 12 March 2012 - 10:00 PM

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.

#11 TheDewd

TheDewd
  • Members
  • 823 posts

Posted 13 March 2012 - 01:18 PM

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

Thanks, sinkfaze! Works quite nicely now...

#12 sinkfaze

sinkfaze
  • Moderators
  • 6087 posts

Posted 13 March 2012 - 03:10 PM

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.