Thanks! My post was getting a bit long and I wasn't sure if anyone cared about the code for those test scripts, so I didn't include them. But here they are! The final times in my screenshots are averaged over 50 runs (done in the script, not manually). As you run the script you'll see the averages update as more tests are run. Top right number is counting down from n to 0, bottom right number is total time elapsed.
Speed test for all shapes and gradient directions:
Code: Select all
{{/lib/graphics/gradient}}
' Test params
' -------------
n = 50 ' Number of draws for each gradient (for time avg)
bw = 0.5 ' GRADIENT.bandWidth (gradient resolution)
ea = 14 ' GRADIENT.easeAccel (color interpolation smoothing)
fs = 19 ' font size
nC = 0 ' Pos R G B
nC += 1 ! DATA 0, 1, 1, 0
nC += 1 ! DATA 0.5, 0, 1, 1
nC += 1 ! DATA 1, 1, 0, 1
nA = 0 ' Pos Alpha
nA += 1 ! DATA 0, 1
nA += 1 ! DATA 0.8, 0.5
nA += 1 ! DATA 1, 0
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
'==============================================================
GRAPHICS
GRAPHICS CLEAR 0,0,0,0
REFRESH OFF
OPTION TEXT POS CENTRAL
DRAW COLOR 0,0,0
DRAW SIZE 0.5
DRAW FONT SIZE fs
GRADIENT.bandwidth = bw
GRADIENT.easeAccel = ea
GET SCREEN SIZE scrW, scrH
'==============================================================
' Gradient positions and dimensions
' -----------------------------------
d = scrW*0.4
r = d/2
qr = 0.7 ' Quad rotation
x1 = scrW/4
x2 = scrW*3/4
y1 = scrH*0.3
y2 = scrH*0.555
y3 = scrH*0.8
DIM xQ1(4), yQ1(4)
xQ1(0) = x1 - r*qr ! yQ1(0) = y2 - r
xQ1(1) = x1 + r ! yQ1(1) = y2 - r*qr
xQ1(2) = x1 + r*qr ! yQ1(2) = y2 + r
xQ1(3) = x1 - r ! yQ1(3) = y2 + r*qr
DIM xQ2(4), yQ2(4)
FOR i = 0 TO 3
xQ2(i) = xQ1(i) + (x2-x1)
yQ2(i) = yQ1(i)
NEXT i
' Gradient speed rating
' -----------------------
/*
The number of colors (nC) and number of alpha values (nA) do not have a significant effect on gradient drawing time. Drawing time is better predicted by the following three attributes:
- Gradient size
- Gradient resolution (set with GRADIENT.bandWidth)
- Percentage of gradient with color & alpha transitions (pT)
pT affects gradient drawing speed because drawing each gradient segment is faster when the color and/or alpha values are remaining constant and do not need to be interpolated. Therefore, gradients with a lower pT value are drawn faster than gradients with a higher pT value. Min pT = 0, max pT = 1.
*/
pT = (cD(nC-1,0)-cD(0,0) + aD(nA-1,0)-aD(0,0)) / 2
'==============================================================
' Speed test
' ------------
DIM tD(6)
FOR i = 0 TO n-1
GRAPHICS CLEAR 1,1,1,0
t1 = TIME()
RECTGRAD(cD, aD, x1, y1, d, d, "x")
t2 = TIME()
tD(0) += t2-t1
DRAW RECT x1, y1 SIZE r+0.5, r+0.5
DRAW TEXT "RECTGRAD" AT x1, y1-fs*2
DRAW TEXT """x""" AT x1, y1-fs
DRAW TEXT tD(0)/(i+1) AT x1, y1
t1 = TIME()
RECTGRAD(cD, aD, x2, y1, d, d, "y")
t2 = TIME()
tD(1) += t2-t1
DRAW RECT x2, y1 SIZE r+0.5, r+0.5
DRAW TEXT "RECTGRAD" AT x2, y1-fs*2
DRAW TEXT """y""" AT x2, y1-fs
DRAW TEXT tD(1)/(i+1) AT x2, y1
t1 = TIME()
QUADGRAD(cD, aD, xQ1, yQ1, "14to23")
t2 = TIME()
tD(2) += t2-t1
DRAW QUAD xQ1(0),yQ1(0), xQ1(1),yQ1(1), xQ1(2),yQ1(2), xQ1(3),yQ1(3)
DRAW TEXT " QUADGRAD" AT x1, y2-fs*2
DRAW TEXT """14to23""" AT x1, y2-fs
DRAW TEXT tD(2)/(i+1) AT x1, y2
t1 = TIME()
QUADGRAD(cD, aD, xQ2, yQ2, "12to43")
t2 = TIME()
tD(3) += t2-t1
DRAW QUAD xQ2(0),yQ2(0), xQ2(1),yQ2(1), xQ2(2),yQ2(2), xQ2(3),yQ2(3)
DRAW TEXT " QUADGRAD" AT x2, y2-fs*2
DRAW TEXT """12to43""" AT x2, y2-fs
DRAW TEXT tD(3)/(i+1) AT x2, y2
t1 = TIME()
ELPSGRAD(cD, aD, x1, y3, r, r, "r")
t2 = TIME()
tD(4) += t2-t1
DRAW CIRCLE x1, y3 SIZE r+0.5, r+0.5
DRAW TEXT "ELPSGRAD" AT x1, y3-fs*2
DRAW TEXT """r""" AT x1, y3-fs
DRAW TEXT tD(4)/(i+1) AT x1, y3
t1 = TIME()
ELPSGRAD(cD, aD, x2, y3, r, r, "a")
t2 = TIME()
tD(5) += t2-t1
DRAW CIRCLE x2, y3 SIZE r+0.5, r+0.5
DRAW TEXT "ELPSGRAD" AT x2, y3-fs*2
DRAW TEXT """a""" AT x2, y3-fs
DRAW TEXT tD(5)/(i+1) AT x2, y3
OPTION TEXT POS NORMAL
DRAW TEXT "bw = "&bw AT scrW*0.1, scrH*0.05
DRAW TEXT "pT = "&pT AT scrW*0.1, scrH*0.05+fs
DRAW TEXT n-i-1 AT scrW*0.7, scrH*0.05
DRAW TEXT STR$(TIME(),"#.##") AT scrW*0.7, scrH*0.05+fs
OPTION TEXT POS CENTRAL
REFRESH
NEXT i
Speed test for fullscreen gradients:
Code: Select all
{{/lib/graphics/gradient}}
' Test params
' -------------
n = 50 ' Number of draws for each gradient (for time avg)
bw = 0.5 ' GRADIENT.bandWidth (gradient resolution)
ea = 14 ' GRADIENT.easeAccel (color interpolation smoothing)
fs = 19 ' font size
nC = 0 ' Pos R G B
nC += 1 ! DATA 0, 1, 1, 0
nC += 1 ! DATA 0.5, 0, 1, 1
nC += 1 ! DATA 1, 1, 0, 1
nA = 0 ' Pos Alpha
nA += 1 ! DATA 0, 1
nA += 1 ! DATA 0.8, 0.5
nA += 1 ! DATA 1, 0
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
'==============================================================
GRAPHICS
GRAPHICS CLEAR 1,1,1,0
REFRESH OFF
DRAW COLOR 0,0,0
DRAW FONT SIZE fs
GRADIENT.bandwidth = bw
GRADIENT.easeAccel = ea
GET SCREEN SIZE scrW, scrH
'==============================================================
' Gradient position and dimension
' ---------------------------------
w = scrW
h = scrH
x = w/2
y = h/2
' Text position
' ---------------
xT = scrW/2
yTx = scrH/2 - fs*3
yTy = scrH/2 + fs*3
' Gradient speed rating
' -----------------------
/*
The number of colors (nC) and number of alpha values (nA) do not have a significant effect on gradient drawing time. Drawing time is better predicted by the following three attributes:
- Gradient size
- Gradient resolution (set with GRADIENT.bandWidth)
- Percentage of gradient with color & alpha transitions (pT)
pT affects gradient drawing speed because drawing each gradient segment is faster when the color and/or alpha values are remaining constant and do not need to be interpolated. Therefore, gradients with a lower pT value are drawn faster than gradients with a higher pT value. Min pT = 0, max pT = 1.
*/
pT = (cD(nC-1,0)-cD(0,0) + aD(nA-1,0)-aD(0,0)) / 2
'==============================================================
' Speed test
' ------------
DIM tD(2)
FOR i = 0 TO n-1
GRAPHICS CLEAR 1,1,1,0
t1 = TIME()
RECTGRAD(cD, aD, x, y, w, h, "x")
t2 = TIME()
tD(0) += t2-t1
OPTION TEXT POS CENTRAL
DRAW TEXT "RECTGRAD" AT xT, yTx-fs*2
DRAW TEXT """x""" AT xT, yTx-fs
DRAW TEXT tD(0)/(i+1) AT xT, yTx
OPTION TEXT POS NORMAL
DRAW TEXT "bw = "&bw AT scrW*0.1, scrH*0.05
DRAW TEXT "pT = "&pT AT scrW*0.1, scrH*0.05+fs
DRAW TEXT n-i-1 AT scrW*0.7, scrH*0.05
DRAW TEXT STR$(TIME(),"#.##") AT scrW*0.7, scrH*0.05+fs
REFRESH
NEXT i
FOR i = 0 TO n-1
GRAPHICS CLEAR 1,1,1,0
t1 = TIME()
RECTGRAD(cD, aD, x, y, w, h, "y")
t2 = TIME()
tD(1) += t2-t1
OPTION TEXT POS CENTRAL
DRAW TEXT "RECTGRAD" AT xT, yTx-fs*2
DRAW TEXT """x""" AT xT, yTx-fs
DRAW TEXT tD(0)/n AT xT, yTx
DRAW TEXT "RECTGRAD" AT xT, yTy-fs*2
DRAW TEXT """y""" AT xT, yTy-fs
DRAW TEXT tD(1)/(i+1) AT xT, yTy
OPTION TEXT POS NORMAL
DRAW TEXT "bw = "&bw AT scrW*0.1, scrH*0.05
DRAW TEXT "pT = "&pT AT scrW*0.1, scrH*0.05+fs
DRAW TEXT n-i-1 AT scrW*0.7, scrH*0.05
DRAW TEXT STR$(TIME(),"#.##") AT scrW*0.7, scrH*0.05+fs
REFRESH
NEXT i
Ease acceleration comparison:
Code: Select all
{{/lib/graphics/gradient}}
' Test params
' -------------
nEA = 16 ' Number of ease acceleration values to compare
bw = 0.5 ' GRADIENT.bandWidth (gradient resolution)
fs = 19 ' font size
drawOutlines = 1
IF nEA < 0 THEN nEA = 0
IF nEA > 31 THEN nEA = 31
DIM ea(nEA)
FOR i = 0 TO nEA-1
ea(i) = i*(30/(nEA-1))
NEXT i
nC = 0 ' Pos R G B
nC += 1 ! DATA 0, 1, 1, 0
nC += 1 ! DATA 0.5, 0, 1, 1
nC += 1 ! DATA 1, 1, 0, 1
nA = 0 ' Pos Alpha
nA += 1 ! DATA 0, 1
nA += 1 ! DATA 0.8, 0.5
nA += 1 ! DATA 1, 0
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
'==============================================================
GRAPHICS
GRAPHICS CLEAR 1,1,1,0
REFRESH OFF
REFRESH
OPTION TEXT POS NORMAL
DRAW COLOR 0,0,0
DRAW SIZE 0.5
DRAW FONT SIZE fs
GRADIENT.bandwidth = bw
GET SCREEN SIZE scrW, scrH
'==============================================================
' Gradient position and dimension
' ---------------------------------
hOff = scrH*0.15
w = scrW*0.8
h = (scrH-hOff)/nEA
x = scrW*0.6
DIM y(nEA)
FOR i = 0 TO nEA-1
y(i) = (i+0.5)*h + hOff
NEXT i
' Text position
' ---------------
xT = scrW*0.05
DIM yT(nEA)
FOR i = 0 TO nEA-1
yT(i) = y(i)
NEXT i
' Gradient speed rating
' -----------------------
/*
The number of colors (nC) and number of alpha values (nA) do not have a significant effect on gradient drawing time. Drawing time is better predicted by the following three attributes:
- Gradient size
- Gradient resolution (set with GRADIENT.bandWidth)
- Percentage of gradient with color & alpha transitions (pT)
pT affects gradient drawing speed because drawing each gradient segment is faster when the color and/or alpha values are remaining constant and do not need to be interpolated. Therefore, gradients with a lower pT value are drawn faster than gradients with a higher pT value. Min pT = 0, max pT = 1.
*/
pT = (cD(nC-1,0)-cD(0,0) + aD(nA-1,0)-aD(0,0)) / 2
'==============================================================
' Ease acceleration comparison
' ------------------------------
DRAW TEXT "ea" AT scrW*0.05, scrH*0.05
DRAW TEXT "↓" AT scrW*0.05, scrH*0.05+fs
DRAW TEXT "bw = "&bw AT scrW*0.6, scrH*0.05
DRAW TEXT "pT = "&pT AT scrW*0.6, scrH*0.05+fs
REFRESH
FOR i = 0 TO nEA-1
GRADIENT.easeAccel = ea(i)
RECTGRAD(cD, aD, x, y(i), w, h, "x")
IF drawOutlines THEN
DRAW ALPHA 0.5
DRAW RECT x, y(i) SIZE w/2+0.5, h/2+0.5
DRAW ALPHA 1
END IF
IF INT(ea(i)) = ea(i) THEN
t$ = ea(i)
ELSE
t$ = STR$(ea(i),"#.#")
END IF
DRAW TEXT t$ AT xT, yT(i)-fs/2
REFRESH
NEXT i