Code: [Local Link Removed for Guests]
' DECLARE SUB arrow(x, y, w, h, color, up)
' up = 1, UP arrow; up = 0, DOWN arrow
' ===========================================
prevX = 1 : prevY = 1 : prevW = 1 : prevH = 1
red = tft.color(red)
blue = tft.color(blue)
cyan = tft.color(cyan)
green = tft.color(green)
white = tft.color(white)
black = tft.color(black)
yellow = tft.color(yellow)
orange = tft.color(orange)
azulReal = tft.rgb(65,105,225)
vga.delete
vga.init 2
vga.fill black
vga.show
pause 5000 ' Waiting for my monitor to turn on
' DEMO:
while 1
x=220 : y=30 : w = 140 : h = 280
arrow x, y, w, h, azulReal, 1
pause 6000
arrow x, y, w, h, azulReal, 0
pause 6000
x=400 : y=150 : w = 36: h = 70
arrow x, y, w, h, orange, 1
pause 3000
x=50 : y=220 : w = 136: h = 225
arrow x, y, w, h, red, 0
pause 3000
x=150 : y=22 : w = 18: h = 40
arrow x, y, w, h, green, 1
pause 3000
x=325 : y=10 : w = 180: h = 320
arrow x, y, w, h, blue, 0
pause 3000
vga.fill black
vga.show
pause 3000
wend
END
' -----------------------------
SUB arrow(x, y, w, h, color, up)
' -----------------------------
LOCAL x1, x2, x3, xR, y1, y2, y3, yR, wR, hR
' x1, y1 = top for up = 1; bottom for up =0
' x2 , y2 = left and x3 , y3 = right for both
' Delete previous arrow:
vga.rect prevX, prevY, prevW+2, prevH+2, black, 1
' Calculate new arrowhead:
x1 = x + w/2
x2 = x
x3 = x + w
if up then y1 = y else y1 = y + h
y2 = cint(((w*1.732)/2)+0.5)
if up then y2 = y2 + y else y2 = y1 - y2
y3 = y2
' Draw arrowhead:
vga.triangle x1, y1, x2, y2, x3, y3, color, 1
' Calculate new arrow shaft:
xR = cint((x3-x2)/4 + x + 0.5)
wR = w/2
if up then yR = y3 + 1 else yR = y
if up then hR = h - (y2-y1) else hR = h - (y1-y2)
' Draw arrow shaft
vga.rect xR, yR, wR, hR, color, 1
vga.show
' Preserve frame data
prevX=x : prevY=y : prevW=w : prevH=h
' gosub Test ' Uncomment for test
END SUB
' -------------------------------------------------------
Test:
if color = blue then fColor = orange else fColor = blue
for i = prevX to prevX + prevW + 1 step 3
vga.line i, y, i, y+h, fColor
next i
vga.show
return