Author: Ouims
Added: 4y
Updated: Never
mIRC: Unknown
Hits: 847
Downloads: 11
Review: entropy
Size: 484B
1 0
Login to vote.
Drawing gradient colored text between 2 RGB colors
This snippet draw a text in a picture window, just like /drawtext is, except that you can pass two RGB colors and it draws a gradient between the two RGB colors.
In bonus, you get the $interpol alias, which can be used to get the color you need based on a percentage, $interpol(rgb1,rgb2,p) where p is 1 for 100%, and 0 for 0%
So if rgb1 is 255 and rgb2 is 64512 (green), $interpol(255,64512,0) is 255 $interpol(255,64512,1) is 64512 and $interpol(255,64512,0.5) is the color right in between both.
;/drawgradienttext x y font fontsize rgb1 rgb2 @win text
x y = coordinate
font fontsize = the font and fontsize, call the alias as an identifier if you need to pass a font name with a space in it
rgb1 = first color
rgb2 = second color
@win = the picture window
text = the text to be drawn,$chr(32) are replaced by $chr(160)
For example, execute:
//window -pdfoC +Lt @dgl -1 -1 600 600 | drawgradienttext 50 50 verdana 15 255 64512 @dgl this is a longggggg test
;drawgradienttext x y font size rgb1 rgb2 @win text alias drawgradienttext { var %a 1,%t $replace($8-,$chr(32),$chr(160)),%b $len(%t),%x $1 while $mid(%t,%a,1) != $null { drawtext -r $7 $interpol($5,$6,$calc(%a / %b)) $qt($3) $4 %x $2 $v1 inc %x $width($v1,$3,$4) inc %a } } alias interpol var %f $3 | tokenize 44 $rgb($1) $+ , $+ $rgb($2) | return $rgb($calc(($4 - $1) * %f + $1),$calc(($5 - $2) * %f + $2),$calc(($6 - $3) * %f + $3))
0