Page 1 of 1
Pinch resizing more than one image on a card
Posted: Sun Mar 23, 2014 4:39 pm
by tyarmsteadBUSuSfT
I am able to pinch resize one image on the card, but am having problems if I have more than one image on the card. Is it possible to pinch resize more than one image on a card? I've tried to differentiate which image at the touch start code with and if statement. Am I on the right track?
Thank you
Ty
Re: Pinch resizing more than one image on a card
Posted: Sun Mar 23, 2014 5:46 pm
by Klaus
Hi Ty,
you can check "the target" on touchstart, then you know if and what image to handle.
Is that what you mean?
Best
Klaus
Re: Pinch resizing more than one image on a card
Posted: Sun Mar 23, 2014 9:29 pm
by tyarmsteadBUSuSfT
Yes, I tried that, but let me re look at the code. Now that I know I can do, that helps a great deal.
Thank you
Ty
Re: Pinch resizing more than one image on a card
Posted: Mon Mar 24, 2014 12:11 am
by tyarmsteadBUSuSfT
Klause, This is where I am starting with the touch start:
local sinputId
local sTouchArray, sFRAMEWIDTH, sFRAMEHEIGHT
on touchStart pId, pX, pY
get target
if the target is image "itemPic1" or image "itemPic3" or image "itemPic4" then
put it into tPic
#to check if it is putting the target into tPic
answer yes
put the width of image tPic into sFRAMEWIDTH
put the height of image tPic into sFRAMEHEIGHT
else
end if
#to see if it is the correct target
answer the target
end touchStart
I can't get the if to work.
Re: Pinch resizing more than one image on a card
Posted: Mon Mar 24, 2014 1:05 am
by Simon
if the target is image "itemPic1" or image "itemPic3" or image "itemPic4" then
if "itemPic1" is in the target or "itemPic3" is in the target or "itemPic4" is in the target then
See if that works, didn't test it.
Simon
Re: Pinch resizing more than one image on a card
Posted: Mon Mar 24, 2014 1:31 pm
by Klaus
Hi guys,
this should to the trick, please note the correct use of "IF... OR... OR"
Code: Select all
local sinputId
local sTouchArray, sFRAMEWIDTH, sFRAMEHEIGHT
on touchStart pId, pX, pY
put the short name of the target into tImageName
if tImageName = "itemPic1" OR tImageName = "itemPic2" OR tImageName = "itemPic4" then
put the width of image tImageName into sFRAMEWIDTH
put the height of image tImageName into sFRAMEHEIGHT
end if
## to see if it is the correct target
answer the target
end touchStart
Best
Klaus
Re: Pinch resizing more than one image on a card
Posted: Tue Mar 25, 2014 12:50 am
by tyarmsteadBUSuSfT
Klause, thank you that part is working, but clearly I'm doing something else incorrectly. I want the user to be able to resize any of the three images that they have taken using the camera on this card card. I had it working for one image but when I started trying to use variables, that is when I ran into the problem of none of the images resizing.
Thank you so much for your help.
Ty
global gItemInfo
global gSeqNumb
local sinputId
local sTouchArray, sFRAMEWIDTH, sFRAMEHEIGHT
on touchStart pId, pX, pY
put the short name of the target into tImageName
if tImageName = "itemPic1" OR tImageName = "itemPic3" OR tImageName = "itemPic4" then
put the width of image tImageName into sFRAMEWIDTH
put the height of image tImageName into sFRAMEHEIGHT
end if
end touchStart
on touchEnd pId
delete variable sTouchArray[pId]
set the textSIZE of image tImageName to round(sFRAMEHEIGHT)
end touchEnd
on touchMove pId, pX, pY
if sTouchArray[pId]["startloc"] is empty then
put (pX & comma & pY) into sTouchArray[pId]["startloc"]
end if
put (pX & comma & pY) into sTouchArray[pId]["currentloc"]
if the number of lines of the keys of sTouchArray is 2 then
# First lets get the data out of the array
put line 1 of the keys of sTouchArray into tPointOne
put line 2 of the keys of sTouchArray into tPointTwo
put sTouchArray[tPointOne]["startloc"] into tStartLoc1
put sTouchArray[tPointTwo]["startloc"] into tStartLoc2
if tStartLoc1 is not empty and tStartLoc2 is not empty then
put resizeDistance(tStartLoc1, tStartLoc2) into tStartDistance
put resizeDistance(sTouchArray[tPointOne]["currentloc"], sTouchArray[tPointTwo]["currentloc"]) into tCurrentDistance
resizeImage tStartDistance, tCurrentDistance
end if
end if
end touchMove
function resizeDistance pLoc1, pLoc2
local dy, dx, tDistance
put item 2 of pLoc1 - item 2 of pLoc2 into dy
put item 1 of pLoc1 - item 1 of pLoc2 into dx
put sqrt((dy*dy) + (dx*dx)) into tDistance
return tDistance
end resizeDistance
on opencard
if environment() = "mobile" then
mobileControlCreate "input"
put the result into sinputID
mobileControlSet sinputID, "rect", "38,726,748,916"
mobileControlSet sinputID, "visible", "true"
mobileControlSet sinputID, "opaque", "true"
end if
end opencard
function resizeDistance pLoc1, pLoc2
local dy, dx, tDistance
put item 2 of pLoc1 - item 2 of pLoc2 into dy
put item 1 of pLoc1 - item 1 of pLoc2 into dx
put sqrt((dy*dy) + (dx*dx)) into tDistance
return tDistance
end resizeDistance
on resizeImage pStartDistance, pNewDistance
# Work out the percentage change between the old and new image
put round((pNewDistance / pStartDistance) * 100) into tPercentage
# Store the original location of the graphic
put the loc of image tImageName into tLoc
set the width of image tImageName to round(sFRAMEWIDTH * (tPercentage / 100))
set the height of image tImageName to round(sFRAMEHEIGHT * (tPercentage / 100))
set the loc of image tImageName to tLoc
set the textSIZE of image tImageName to round(sFRAMEHEIGHT )/5
unlock screen
end resizeImage
Re: Pinch resizing more than one image on a card
Posted: Tue Mar 25, 2014 12:55 pm
by Klaus
Hi Ty,
Klaus, my name is Klaus, without any E!
OK, maybe adding:
will help?
Question:
What does setting the textsize of an image do except not throwing an error?
Best
Klaus
Re: Pinch resizing more than one image on a card
Posted: Tue Mar 25, 2014 11:08 pm
by tyarmsteadBUSuSfT
Klaus,
That did the trick.
Thank you and I apologize for the "e". I appreciate that as people often drop the e"e" from my name.
Ty
Re: Pinch resizing more than one image on a card
Posted: Wed Mar 26, 2014 12:55 pm
by Klaus
tyarmsteadBUSuSfT wrote:Thank you and I apologize for the "e". I appreciate that as people often drop the e"e" from my name.
No probem, Tie
