Pinch resizing more than one image on a card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Pinch resizing more than one image on a card
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
Thank you
Ty
Re: Pinch resizing more than one image on a card
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
you can check "the target" on touchstart, then you know if and what image to handle.
Is that what you mean?
Best
Klaus
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: Pinch resizing more than one image on a card
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
Thank you
Ty
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: Pinch resizing more than one image on a card
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Pinch resizing more than one image on a card
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
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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Pinch resizing more than one image on a card
Hi guys,
this should to the trick, please note the correct use of "IF... OR... OR"
Best
Klaus
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
Klaus
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: Pinch resizing more than one image on a card
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
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
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
Klaus, my name is Klaus, without any E!
OK, maybe adding:
Code: Select all
local tImageName
Question:
What does setting the textsize of an image do except not throwing an error?
Best
Klaus
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: Pinch resizing more than one image on a card
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
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
No probem, TietyarmsteadBUSuSfT wrote:Thank you and I apologize for the "e". I appreciate that as people often drop the e"e" from my name.