Fit backgroundPattern image to a smaller stack

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
tomsve
Posts: 46
Joined: Tue Jan 20, 2015 5:01 pm

Fit backgroundPattern image to a smaller stack

Post by tomsve »

Developing for mobile.

I've important an image in a substack that I want to use as a background in my normal stack. Because the imported image is bigger than the stack, the background now looks strange (too big - because my image is 1.4 times bigger) when I use it as backgroundPattern.

Is there any way to resize the image used for backgroundPattern to fit a slightly smaller stack? I use a bigger image because I don't want the background image to have bad quality if someone uses an iPhone Plus for example.

The alternative seems to be to use an image control with Layer 1, but then it's not possible to tap outside the input fields to remove the keyboard toggle.

Any ideas?

Thanks,
Tom
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Fit backgroundPattern image to a smaller stack

Post by Klaus »

Hi Tom,

do something like this, maybe "on preopenstack":
...
## In any case set the LOCLOCK of the image to true first in the inspector!

## First resize the image:
set the rect of img "you image here..." to the rect of this stack
## Or set width and height as you wish...

## NOW set the backgroundpattern via script:
set the backgroundpattern of this stack to xxx
##(the id of that image)
...

Best

Klaus
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Fit backgroundPattern image to a smaller stack

Post by bogs »

tomsve wrote: Fri Oct 27, 2017 2:39 pm I've important an image in a substack that I want to use as a background in my normal stack. Because the imported image is bigger than the stack, the background now looks strange (too big - because my image is 1.4 times bigger) when I use it as backgroundPattern.
Alternately, you could just resize the image in any image editor, then use it in the program. However, if your stack size changes a lot, what Klaus said.
Image
tomsve
Posts: 46
Joined: Tue Jan 20, 2015 5:01 pm

Re: Fit backgroundPattern image to a smaller stack

Post by tomsve »

Great, thanks both of you. I'll try it.
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Fit backgroundPattern image to a smaller stack

Post by jacque »

If I remember right a background pattern will only use its native size, but try it. If that doesn't work, use a second image instead and disable it. That will allow taps to go through to the card normally and dismiss the keyboard.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
tomsve
Posts: 46
Joined: Tue Jan 20, 2015 5:01 pm

Re: Fit backgroundPattern image to a smaller stack

Post by tomsve »

I tried a little bit back and forth and eventually I got it to work with Klaus method, but in the preOpenCard.

That's also a suggestion jacque, thanks. I'll have that in mind. I was thinking that might be a solution to a problem I just posted now about the datagrid borders, but I think not.

Thanks for quick help. Hopefully I'll have my next app in the store soon :-)
Post Reply