Distorting backGroundPattern

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Distorting backGroundPattern

Post by richmond62 » Mon Dec 30, 2024 6:37 pm

I am distorting a graphic object to fake a card being flipped, but I am unaware of a way to distort a backGroundPattern so it is congruent with the graphic object as it distorts:
-
Screenshot 2024-12-30 at 19.34.19.jpg
Attachments
FLIPPER.livecode.zip
Stack.
(86.88 KiB) Downloaded 853 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Distorting backGroundPattern

Post by dunbarx » Mon Dec 30, 2024 7:51 pm

Richmond.

Not sure what you mean.

In any case, can't you use the "visual effect" command to simulate the action you want? Maybe a "wipe"?

Craig

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

Re: Distorting backGroundPattern

Post by bogs » Mon Dec 30, 2024 8:05 pm

If your talking about the actual background pattern you can apply through properties in Lc to an opaque control, then what your looking to do is not possible
because the image being used will always be displayed as is, your control (polygon most likely) is not going to distort that image in any way, unlike say, a photo editing software would be able too.
Screenshot_2024-12-30_13-53-41.png
it is a flat image you know....
Screenshot_2024-12-30_13-53-41.png (70.06 KiB) Viewed 12304 times
In order to achieve the effect your looking for, you would need a series of images, one for each point of your control's angle.
perspective.png
Lets put this into perspective...
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Distorting backGroundPattern

Post by dunbarx » Mon Dec 30, 2024 8:56 pm

Bogs.

Are you saying that Richmond wants to "rotate" the card visually, changing from the starting image to the final?

If so it seems to me that you need to narrow the starting image in a second or so down to zero width, and then expand the final image from zero to full width. That should look like you are rotating the image and changing it, like a sleight-of-hand thing.

Richmond?

Craig

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

Re: Distorting backGroundPattern

Post by bogs » Mon Dec 30, 2024 9:30 pm

dunbarx wrote:
Mon Dec 30, 2024 8:56 pm
Bogs.
Are you saying that Richmond wants to "rotate" the card visually, changing from the starting image to the final?
Well, ...
richmond62 wrote:
Mon Dec 30, 2024 6:37 pm
I am distorting a graphic object to fake a card being flipped, but I am unaware of a way to distort a backGroundPattern so it is congruent with the graphic object as it distorts:
it sounds to me like he wants to use a control, likely a N-gon, and have the background image go into perspective just as the n-gon does, as if it were attached to the n-gon's points.

In other words, it would look like the 2nd picture I posted while the n-gon were going through its motion, from flat (top pic) to angled (bottom pic, which I created in GIMP since it has facilities already for perspective).
If so it seems to me that you need to narrow the starting image in a second or so down to zero width, and then expand the final image from zero to full width. That should look like you are rotating the image and changing it, like a sleight-of-hand thing.
Yes, you *would* need to do that, as far as I am aware though, there isn't a built in function to do this in LC. I'm not saying it is impossible to code, but there are simpler ways to do it.

If you had say, 5 images, each skewed in a way that matched your trip in points for the n-gon's transformation, you could then simulate a pretty convincing card turn over.

But let's see what he says, maybe I've missed it completely.
Image

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: Distorting backGroundPattern

Post by SparkOut » Mon Dec 30, 2024 10:22 pm

There's a stack by [-hh] somewhere that does [at least some of] that. Thank you Hermann, RIP.
I'll try and track down where, when I get chance on my computer.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Distorting backGroundPattern

Post by dunbarx » Mon Dec 30, 2024 11:03 pm

A quick test stack attached. Did not try it with the front and back of a playing card.

Craig
Flipping.livecode.zip
(1 KiB) Downloaded 775 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Distorting backGroundPattern

Post by dunbarx » Mon Dec 30, 2024 11:20 pm

OK, here it is with Richmond's cards.

Craig
Flipping2.livecode.zip
(86.27 KiB) Downloaded 761 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Distorting backGroundPattern

Post by richmond62 » Tue Dec 31, 2024 10:57 am

Yes, well, I have already been 'there', but it misses the point which is best illustrated by the following images:
-
b1.png
-
b6.png
-
b14.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Distorting backGroundPattern

Post by richmond62 » Tue Dec 31, 2024 12:14 pm

I had to make a whole sequence of images in GIMP:
-
Screenshot 2024-12-31 at 11.59.21.png
-

AND, having just discovered this, GIMP goes up in my estimation like nobody's business!

https://www.gimp.org/
Last edited by richmond62 on Tue Dec 31, 2024 7:13 pm, edited 1 time in total.

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

Re: Distorting backGroundPattern

Post by bogs » Tue Dec 31, 2024 1:04 pm

SparkOut wrote:
Mon Dec 30, 2024 10:22 pm
There's a stack by [-hh] somewhere that does [at least some of] that. Thank you Hermann, RIP.
I'll try and track down where, when I get chance on my computer.
Yup, Hermann did this (better than I heh, his contributions were always amazing to me), and this question has come up previously in other formats (engine running comes to mind).

I don't know that there was ever a consensus on the best way, but by far the most approachable way (in that almost anyone could do it with reasonable ease) is having a series of images (doesn't have to be gif, I just use that for the automation built in), and using that for the visual effect.
richmond62 wrote:
Tue Dec 31, 2024 12:14 pm
I had to make a whole sequence of images in GIMP:
A sequence yes, how many did you wind up making total? My testing showed minimum 3 and max 5 necessary for visually smooth flipping motion. Depending on what exact type of thing your trying to do (outside of cards), the number could be as low as 2-3 or as high as 10, but 10 is likely overkill for almost everything aside from progress bar type things.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Distorting backGroundPattern

Post by richmond62 » Tue Dec 31, 2024 2:35 pm

Oh, 19, but I was feeling fancy.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Distorting backGroundPattern

Post by dunbarx » Tue Dec 31, 2024 4:41 pm

Richmond.

Was 19 enough resolution to make the action smooth? My gadget had 80 discrete steps in each direction, which was the minimum I felt in order to look OK.

Can you post yours?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Distorting backGroundPattern

Post by richmond62 » Tue Dec 31, 2024 5:06 pm

It is quite a size: I'll pop it up on Dropbox in about 2-3 hours time.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Distorting backGroundPattern

Post by richmond62 » Tue Dec 31, 2024 6:55 pm

Here the thing is:

https://www.dropbox.com/scl/fi/2niqqi3y ... sc6bi&dl=0

736 KB

Oh, and while I am here: using 10 images does NOT produce any obvious degradation.

Post Reply