Code: Select all
/*
Gradient Draw Quad
by rbytes, August 2018
displays a QUAD gradient created in
GradientEditor by matt7
*/
{{/Library/Graphics/Gradients.lb}}
bw = .5 ' GRADIENT.bandWidth (gradient resolution = Retina)
ea = 6 ' GRADIENT.easeAccel (color interpolation smoothing = SmoothStep)
GRADIENT.bandwidth = bw
GRADIENT.easeAccel = ea
SET TOOLBAR OFF
GRAPHICS
GRAPHICS CLEAR
DRAW COLOR 0,0,0
'===================================================
' COPY THE CODE LINES DEFINING nC and nA FROM A QUAD GRADIENT FILE SAVED BY GradientEditor
' AND PASTE IT BETWEEN THE DOUBLE LINES HERE, ERASING ANY PREVIOUS DEFINITIONS OF nC and nA
nC = 0 ' Pos Red Green Blue
nC += 1 ! DATA 0.0000, 1.0000, 0.7059, 0.0000
nC += 1 ! DATA 0.2510, 0.8902, 0.2627, 0.8902
nC += 1 ! DATA 0.5020, 1.0000, 0.7059, 0.0000
nC += 1 ! DATA 0.7490, 0.8902, 0.2627, 0.8902
nC += 1 ! DATA 1.0000, 1.0000, 0.7059, 0.0000
nA = 0 ' Pos Alpha
nA += 1 ! DATA 0.0000, 1.0000
nA += 1 ! DATA 1.0000, 0.9608
'-------------------------------------------------------
DIM cD(nC,4)
FOR iC = 0 TO nC-1
READ cD(iC,0)
READ cD(iC,1)
READ cD(iC,2)
READ cD(iC,3)
NEXT iC
DIM aD(nA,2)
FOR iA = 0 TO nA-1
READ aD(iA,0)
READ aD(iA,1)
NEXT iA
'===================================================
'Set x,y points to define shape
x1=500
x2=650
x3=800
x4=300
y1=100
y2=200
y3=500
y4=650
'Load x,y values into arrays
DIM xQ1(4), yQ1(4)
xQ1(0) = x1 ! yQ1(0) = y1
xQ1(1) = x2 ! yQ1(1) = y2
xQ1(2) = x3 ! yQ1(2) = y3
xQ1(3) = x4 ! yQ1(3) = y4
DIM xQ2(4), yQ2(4)
FOR i = 0 TO 3
xQ2(i) = xQ1(i) + (x2-x1)
yQ2(i) = yQ1(i)
NEXT i
'Define the direction of the gradient
'dir$="14to23" 'Vertical
dir$="12to43" 'Horizontal
'-------------------------------------------------------
QUADGRAD(cD, aD, xQ1, yQ1, dir$)
DRAW QUAD xQ1(0),yQ1(0), xQ1(1),yQ1(1), xQ1(2),yQ1(2), xQ1(3),yQ1(3)
PAUSE 5