GradientRect

The GradientRect function fills the rectangular area by gradient changed colors (fountain fill). The rectangle is not outlined.

GradientRect nXStart, nYStart, nXEnd, nYEnd, nC1, nC2 [,bHorizontal]

Parameters

nXStart
Specifies the x-coordinate of the first base corner of the rectangle

nYStart
Specifies the y-coordinate of the first base corner of the rectangle

nXEnd
Specifies the x-coordinate of the second base corner of the rectangle

nYEnd
Specifies the y-coordinate of the second base corner of the rectangle

nC1
The color number to start

nC2
The color number to finish

bHorizontal
Optional. Specifies whether the color will be changed horizontally or vertically in the filled area. The default value is False (the color changed vertically)

Remarks

The function begins to fill in the point nXStart,nYStart with color nC1 and finishes in the point nXEnd,nYEnd with color nC2.
If you produce a GIF image, do not forget to recalculate palette just before GifImage calling (you can use the BuildPalette function, for example).

Example
View result

<%
Set g=CreateObject("shotgraph.image")
' Chart size
xsize=300
ysize=200
' Image size
maxx=320
maxy=240
' Basis points of chart rectangle
x1=(maxx-xsize)\2
y1=(maxy-ysize)\2
x2=x1+xsize-1
y2=y1+ysize-1

Main()

Sub Main()
g.CreateImage maxx,maxy,256
' Background color
g.SetColor 0,255,255,255
' Drawing color (black)
g.SetColor 1,0,0,0
g.SetBgColor 0
' Starting color for gradient
g.SetColor 2,0,0,255
' Ending color for gradient
g.SetColor 3,201,201,255
g.SetDrawColor 1
' Fill the whole image with background
g.FillRect 0,0,maxx-1,maxy-1
' Drawing chart rectangle
g.Rectangle x1,y1,x2,y2
' Drawing dotted line
g.CreatePen "PS_DOT",1,1
g.SetBkMode "TRANSPARENT"
g.Line x1,maxy\2,x2,maxy\2
' Set brush to zero for outbounding rectangles
g.CreateBrush "BS_NULL",0,""
g.SetDrawColor 1
DrawBar x1+10,100,50
DrawBar x1+110,150,50
DrawBar x1+210,160,50
' Recalculate palette
g.BuildPalette 4
g.GifImage -1,0,"test.gif"
End Sub

' This sub draws fountain filled bar
' and outline rectangle
Sub DrawBar(x,height,width)
g.GradientRect x,y2-height-1,x+width,y2,3,2
g.Rectangle x,y2-height-1,x+width,y2
End Sub
%>