Im working on a Calculator that can determine the Hypotanuse length and the base and Height of a triangle simply by adjusting the values, but im trying to get it so the line adapts to a parameter.integer input, Can anyone make it work?
Height = TriangleHeight
Base = TriangleBase
Base = 100
Height = 100
Hypotanuse = Base/2*Base/2+Height*Height
Area = Base*Height/2
function setup()
saveProjectInfo("Description", "A Calculator that Finds The Hypotanuse and Area of a Triangle")
readProjectInfo("Description")
parameter.watch("Base")
parameter.watch("Height")
parameter.watch("Hypotanuse")
parameter.number("Base",1,99,Base)
parameter.integer("Height",0,99,Height)
parameter.action("Clear Calculations", output.clear)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
spriteMode(CENTER)
sprite("Cargo Bot:Opening Background",WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
stroke(0, 0, 0, 255)
line(Base,Height)
-- This sets the line thickness
strokeWidth(2)
-- Do your drawing here
fill(255, 255, 255, 255)
textMode(CORNER)
textAlign(CENTER)
font("AmericanTypewriter-Light")
fontSize(25)
text("Double Tap to Calculate", 10, HEIGHT-50)
pushMatrix()
lineCapMode(ROUND)
strokeWidth(8)
stroke(255, 255, 255, 255)
smooth()
noFill()
line(Base, Base, Base, Base)
line(Height, Height, Height, Height)
popMatrix()
end
function touched(touch)
if touch.tapCount == 2 and touch.state == ENDED then
print("--------------")
print("Base: "..Base)
print("Height: "..Height)
print("Hypotanuse: "..Hypotanuse)
print("Calculations are in Centimeters, Assuming the numbers are also Centimeters")
end
end