'============================================================
'DrawGradLine 指定描画領域に、SetGradColorプロシージャで
' 指定された色で直線グラデーションを描く
'------引数--------------------------------------------------
'Pic 描画領域のオブジェ
'sx,sy 描画開始位置
'wid,hei 描画幅,高さ(gapx<>0の時wid無視、gapy<>0の時hei無視)
'gapx,gapy 描画向き(gapx=1の時、左から右)、1カウントごとの飛び
'count グラデーションのカウント
'============================================================
Public Sub DrawGradLine(Pic As Object, _
sx As Long, sy As Long, _
wid As Long, hei As Long, _
gapx As Long, gapy As Long, count As Long)
Dim r As Long, g As Long, b As Long
Dim i As Long
Dim xw As Long, yh As Long
If gapx <> 0& Then wid = 0& 'ここのコードにちょっと無理が・・
If gapy <> 0& Then hei = 0&
r = r1: g = g1: b = b1 '初期値の格納
'グラデーションの回数まで
For i = 0& To count - 1&
'終了値まで、色を変化させていく
If Abs(r - r2) >= Abs(rm) Then r = r1 + CLng(rm * CSng(i))
If Abs(g - g2) >= Abs(gm) Then g = g1 + CLng(gm * CSng(i))
If Abs(b - b2) >= Abs(bm) Then b = b1 + CLng(bm * CSng(i))
xw = gapx * i: yh = gapy * i
If gapx <> 0& And gapy <> 0& Then 'いわゆる斜線の描画
Pic.Line (sx, sy + yh)-(sx + xw, sy), RGB(r, g, b)
Else '普通の直線描画
Pic.Line (sx + xw, sy + yh)- _
(sx + xw + wid, sy + yh + hei), RGB(r, g, b)
End If
DoEvents '←これがある方が見ていて面白い?
Next i
End Sub
|