You need to access this example with a touch enabled device.
When the screen is touched a circle is created.
As long as you hold this touch the circle will grow for awhile.
If you continue to hold and drag your finger the circle will follow your finger.
When you release your finger the circle will shrink until it disappears.
@SteveOW
When testing touch devices:
- Watch the speed at which the circle grows and shrinks
- Watch how well the circle tracks the movement of your finger
- Note how many fingers on the screen produce a circle
The program allows you to put multiple fingers on the touch screen and get multiple circles.
My Samsung Droid Charge only allows for 1 circle at a time.
Online linkBrowserBasic code:
var off as number = 0
var grow as number = 1
var shrink as number = 2
Type TCircle
var x as number
var y as number
var radius as number = 100
var alpha as number
var color as string
var index as number
var state as number = off
endtype
var circles [10] as TCircle ' an array to hold all of the circles
' Load is here used for basic setup only (line width, for the animated circles)
function OnLoad ()
setLineWidth(3)
endfunction
function OnDraw()
'
var i as number
setAlpha(1)
for i = 0 to UBound(circles) - 1
If circles[i].state <> off then
If circles[i].state = grow then
circles[i].radius = circles[i].radius + 1
if circles[i].radius > 300 then
circles[i].radius = 300
endif
endif
If circles[i].state = shrink then
circles[i].radius = circles[i].radius - 1
if circles[i].radius < 0 then
circles[i].radius = 0
circles[i].state = off
endif
endif
setColor(0,255,0)
fillCircle(circles[i].x, circles[i].y, circles[i].radius)
endif
next
endfunction
' When a finger touches the screen, show a circle expanding away
function OnTouchPressed(finger as number, x as number, y as number)
circles[finger].state = grow
circles[finger].x = x
circles[finger].y = y
circles[finger].radius = 50
endfunction
' When a finger leaves the screen, draw a circle "compressing to the point where
' the finger was
function OnTouchReleased(finger as number, x as number, y as number)
circles[finger].state = shrink
circles[finger].x = x
circles[finger].y = y
endfunction
function OnTouchMoved(finger as number, x as number, y as number)
circles[finger].x = x
circles[finger].y = y
endfunction