## 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

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

### Saving Image Location

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?

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

### Re: Saving Image Location

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.
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com

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

### Re: Saving Image Location

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

Thanks Jacque! That's just what I needed

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

LiveCode lends itself extremely well to taking small bites one at a time and seeing how they are digested...
Walt Brown

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

### Re: Saving Image Location

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: 11057
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact: