Draw Gradient Rect picwin - mIRC Snippet | PremiumChat.ro Back

Draw Gradient Rect picwin

New Snippet section + /drawgradrect snippet that draw a rectangle filled with a gradient color

; Draw Gradient Rect
;
; Description: it draw a rectangle filled with a gradient color from <rgb value 1> to <rgb value 2>.
;
; Usage: /drawgradrect [-hnr] <@window> <rgb value 1> <rgb value 2> <X> <Y> <W> <H>
;  h: horizontal draw.
;  n: prevents the display from being updated immediately.
;  r: indicates that the color is in RGB format.
;
; Examples:
;  /drawgradrect -r @mywindowname $rgb(255,0,0) $rgb(255,255,0) 0 0 100 100
;  /drawgradrect -h @mywindowname 0 1 20 10 50 20
;
; Written by }|-|yRoN{ #[email protected]
; [email protected]
; http://osupdate.altervista.org/

alias drawgradrect {
  var %i,%r,%g,%b,%r2,%g2,%b2,%rStep,%gStep,%bStep,%rgbTmp1,%rgbTmp2,%hparm,%rparm,%nparm
  if (- isin $1) {
    if (h isin $1) %hparm = 1
    if (r isin $1) %rparm = 1
    if (n isin $1) %nparm = 1
    tokenize 32 $2-
  }
  if ($0 < 7) { echo $color(info) -a * /drawgradrect: insufficient parameters | return }
  elseif (!$window($1)) { echo $color(info) -a * /drawgradrect: invalid window | return }
  elseif (($2 !isnum) || ($3 !isnum)) { echo $color(info) -a * /drawgradrect: invalid rgb value parameter | return }
  elseif ($4 !isnum) { echo $color(info) -a * /drawgradrect: invalid x parameter | return }
  elseif ($5 !isnum) { echo $color(info) -a * /drawgradrect: invalid y parameter | return }
  elseif ($6 !isnum) { echo $color(info) -a * /drawgradrect: invalid w parameter | return }
  elseif ($7 !isnum) { echo $color(info) -a * /drawgradrect: invalid h parameter | return }
  if (%rparm) {
    %rgbTmp1 = $rgb($2)
    %rgbTmp2 = $rgb($3)
  }
  else {
    %rgbTmp1 = $rgb($color($2))
    %rgbTmp2 = $rgb($color($3))
  }
  %r2 = $calc($gettok(%rgbTmp2,1,44) - $gettok(%rgbTmp1,1,44))
  %g2 = $calc($gettok(%rgbTmp2,2,44) - $gettok(%rgbTmp1,2,44))
  %b2 = $calc($gettok(%rgbTmp2,3,44) - $gettok(%rgbTmp1,3,44))
  %r = $gettok(%rgbTmp1,1,44)
  %g = $gettok(%rgbTmp1,2,44)
  %b = $gettok(%rgbTmp1,3,44)
  if (%hparm) {
    %rStep = $calc(%r2 / $6)
    %gStep = $calc(%g2 / $6)
    %bStep = $calc(%b2 / $6)
    %i = $4
    while (%i < $calc($4 + $6)) {
      drawrect -rn $1 $rgb(%r,%g,%b) 1 %i $5 1 $7 
      inc %r %rStep
      inc %g %gStep
      inc %b %bStep
      inc %i
    }
  }
  else {
    %rStep = $calc(%r2 / $7)
    %gStep = $calc(%g2 / $7)
    %bStep = $calc(%b2 / $7)
    %i = $5
    while (%i < $calc($5 + $7)) {
      drawrect -rn $1 $rgb(%r,%g,%b) 1 $4 %i $6 1 
      inc %r %rStep
      inc %g %gStep
      inc %b %bStep
      inc %i
    }
  }
  if (!%nparm) drawdot $1
}