Saving Image Location

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
minorpayne10
Posts: 4
Joined: Thu Dec 10, 2015 12:17 pm

Saving Image Location

Post by minorpayne10 » Thu Dec 10, 2015 12:23 pm

Hey all

I am doing an image translation and I need to save the y location in a variable to manipulate later. It's an image of a burette with graduated marks on it, for which I devised an equation to calculate the numbered mark using the y location of the image. But I don't know how to isolate that information from the location x,y. Do I need to use an array?

Please help.

-Madeline

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7022
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Saving Image Location

Post by FourthWorld » Thu Dec 10, 2015 12:37 pm

No array needed. You can just store the loc in a custom property for later retrieval:

Code: Select all

set the uSaveLoc of img 1 to the loc of image 1
A burette? If you don't mind my asking, what are you working on? Sounds interesting.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5154
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Saving Image Location

Post by jacque » Thu Dec 10, 2015 6:06 pm

The location of an object consists of two items, so the y will be item 2:

Code: Select all

put item 2 of the loc of <object> into tY
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

minorpayne10
Posts: 4
Joined: Thu Dec 10, 2015 12:17 pm

Re: Saving Image Location

Post by minorpayne10 » Sat Dec 12, 2015 12:43 am

Thanks Jacque! That's just what I needed :D

Question: When doing multiple math operations... do I have to:
subtract # from var and put into var2
divide # from var2 and put into var3
? It seems so inelegant.

I'm doing a virtual titration lab for my chemistry research project (chem major with a death wish). It's a pretty cool project and I'm having fun with it. I have a task that requires 0.5 g of NaOH to be weighed, and the mass button generates a random number from 0.4 to 0.6 g (it's hard to get the exact amount; what's important is knowing exactly how much NaOH you're have). The hard part is the actual titration animation. I have multiple animations going on at once:
A small stationary burette where the water level falls with drops falling into the flask with the analyte solution- the full picture of a titration
Zoomed in animation of the burette where the water is stationary, but the numbered burette image is moved upwards- shows the instantaneous water level
And I want to have a slider to adjust the movespeed of everything by some scale- to illustrate the opening and closing of the stopcock.
Oh, and the most important part: the color change of the analyte solution... which I want to occur at a random moment of the titration so that it's not so easy and predictable. I'm going to do this with blending in a pink liquid.

I've had to do some tricky layering. I don't know how I'm going to synchronize everything...

I could definitely use some help with how to move an image incrementally with an if loop. And how to do the random time color change.
This is my first code writing project and I fear I've bitten off more than I can chew.

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Saving Image Location

Post by WaltBrown » Sat Dec 12, 2015 2:44 am

LiveCode lends itself extremely well to taking small bites one at a time and seeing how they are digested... :-)
Walt Brown
Omnis traductor traditor

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5154
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Saving Image Location

Post by jacque » Sat Dec 12, 2015 5:08 am

Question: When doing multiple math operations... do I have to:
subtract # from var and put into var2
divide # from var2 and put into var3
? It seems so inelegant.
No, all the usual math symbols are available. For the most part you should be able to just write out the math normally.

put (5 + tVar) * tMultiplier / tDivisor into tResult

I made that up, have no idea what it does. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 11313
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Saving Image Location

Post by Klaus » Sat Dec 12, 2015 2:51 pm

Hi Madeline,

1. welcome to the forum! :D

2. To learn more about the very basics of Livecode, I recommend to work through some, if not all of these stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”