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: 45
Joined: Tue Jan 20, 2015 5:01 pm
Location: Ukraine/Armenia

Fit backgroundPattern image to a smaller stack

Post by tomsve » Fri Oct 27, 2017 2:39 pm

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

Re: Fit backgroundPattern image to a smaller stack

Post by Klaus » Fri Oct 27, 2017 3:31 pm

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: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Fit backgroundPattern image to a smaller stack

Post by bogs » Fri Oct 27, 2017 4:15 pm

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: 45
Joined: Tue Jan 20, 2015 5:01 pm
Location: Ukraine/Armenia

Re: Fit backgroundPattern image to a smaller stack

Post by tomsve » Fri Oct 27, 2017 4:34 pm

Great, thanks both of you. I'll try it.

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

Re: Fit backgroundPattern image to a smaller stack

Post by jacque » Fri Oct 27, 2017 6:55 pm

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: 45
Joined: Tue Jan 20, 2015 5:01 pm
Location: Ukraine/Armenia

Re: Fit backgroundPattern image to a smaller stack

Post by tomsve » Fri Oct 27, 2017 7:05 pm

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

Return to “Getting Started with LiveCode - Complete Beginners”