Author: Ouims
Added: 4y
Updated: 4y
mIRC: Unknown
Hits: 688
Downloads: 6
Review: entropy
Size: 455B
1 0
Login to vote.
Drawing gradient colored circle between 2 RGB colors
This snippet draw a circle in a picture window, just like /drawline -e is, except that you can pass two RGB colors and it draws a gradient between the two points.
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.
;/drawgradientcircle x y w h rgb1 rgb2 size @win [angle]
x y w h = coordinate and size of circle
rgb1 = first color
rgb2 = second color
size = the size of the circle, same as /drawdot
@win = the picture window
angle = optional angle parameter, by default the first color is drawn at angle 0 which is when 'x' is at its maximum and y = 0, if you provide this parameter, the first rgb color will start at this angle
For example, execute:
//window -pdfoC +Lt @dgl -1 -1 600 600 | drawgradientcircle 50 50 100 100 255 64512 8 @dgl 72
alias drawgradientcircle { var %theta 0 while %theta < 360 { drawdot -r $8 $interpol($5,$6,$calc(%theta / 360)) $7 $calc(($1 + $3) / 2 + $3 / 2 * $cos($calc(%theta + $9)).deg) $calc(($2 + $4) / 2 - $4 / 2 * $sin($calc(%theta + $9)).deg) inc %theta 0.01 } } 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