Post by warspyking on Dec 5, 2016 20:28:43 GMT
Made with pre-multitouch app (used my iPod that can't update) so you'll have to adapt it yourself.
You swipe your finger and it creates a right triangle, the hypotenuse being a line from the beginning to end of your touch. If you tap your finger it will toggle whether measurements are shown or not.
I thought this was a really cool but simple program, could potentially be used as a draw example program if adapted to multi touch (hint hint nudge nudge Admin )
You swipe your finger and it creates a right triangle, the hypotenuse being a line from the beginning to end of your touch. If you tap your finger it will toggle whether measurements are shown or not.
I thought this was a really cool but simple program, could potentially be used as a draw example program if adapted to multi touch (hint hint nudge nudge Admin )
--Set Up Draw Screen
draw.setscreen(1)
draw.settitle("Right Triangle Visual")
draw.setantialias(false)
local width, height = draw.getport() --Get Screen Size
--Preset Necessary Variables
local text = {}
local visible = false
function DrawTexts(visible)
--Loop Texts and change Visibility
for i,v in ipairs(text) do
draw.string(v[1],v[2],v[3],visible and v[4] or draw.black)
end
end
do
local startx,starty --Points user first touch in swipe
function began(x,y)
startx,starty = x,y --Set necessary start points of finger swipe
end
function move(x,y)
end
function finish(x,y)
if math.abs(x-startx) > 5 and math.abs(y-starty) > 5 then
--Draw Triangle
--X Line and Angle
draw.line(startx, starty, x, starty, draw.blue)
text[#text+1] = {math.abs(x-startx), (startx+x)/2, starty, draw.red}
text[#text+1] = {math.ceil(math.deg(math.atan(math.abs(y-starty)/math.abs(x-startx)))-0.5).."°", startx, starty, draw.orange}
--Y Line and Angle
draw.line(x, starty, x, y, draw.blue)
text[#text+1] = {math.abs(starty-y), x, (starty+y)/2, draw.red}
text[#text+1] = {math.ceil(math.deg(math.atan(math.abs(x-startx)/math.abs(y-starty)))-0.5).."°", x, y, draw.orange}
--Diagonal Line
draw.line(startx,starty,x,y, draw.white)
text[#text+1] = {math.ceil(math.sqrt((math.abs(startx-x))^2+(math.abs(starty-y))^2)-0.5), (startx+x)/2, ((starty+y)/2)-40, draw.red}
--Right Angle
text[#text+1] = {"90°", x, starty, draw.orange}
if visible then
draw.string(math.abs(x-startx), (startx+x)/2, starty, draw.red)
draw.string(math.ceil(math.deg(math.atan(math.abs(y-starty)/math.abs(x-startx)))-0.5).."°", startx, starty, draw.orange)
draw.string(math.abs(starty-y), x, (starty+y)/2, draw.red)
draw.string(math.ceil(math.deg(math.atan(math.abs(x-startx)/math.abs(y-starty)))-0.5).."°", x, y, draw.orange)
draw.string(math.ceil(math.sqrt((math.abs(startx-x))^2+(math.abs(starty-y))^2)-0.5), (startx+x)/2, ((starty+y)/2)-40, draw.red)
draw.string("90°", x, starty, draw.orange)
end
else
--Display Stats
DrawTexts(not visible)
visible = not visible
end
end
--Set Draw Events
draw.tracktouches(began,move,finish)
end
--Set Screen to Black
draw.clear(draw.black)
--Start Program Loop
while true do
draw.beginframe() --Start drawing frame
draw.doevents() --Do all touch events
sleep(100) --Yield for .1 seconds
draw.endframe() --End drawing frame
end