Create a button's icon with a part of a big image? - Beleaguered Castle

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
Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image?

Post by Zax » Tue Aug 16, 2022 11:23 am

OK, I'll wait to see if somebody has deeper knowledge about resizeStack messages.

Bernd, it is really necessary to sort the pending Messages but time? The pendingMessages list is not already sorted by default?
Another question: when using repeat for each in CR-delimited list, are we sure the lines order is preserved? In some other languages, the use of each don't preserve the order.

Anyhow, the LC built-on dictionnary is rather inaccurate as it says in resizeStack description:
The resizeStack message is sent after the resizing is finished. This means that you cannot prevent a stack's size from being changed by trapping this message.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Create a button's icon with a part of a big image?

Post by bn » Tue Aug 16, 2022 11:52 am

Hi Zax,
Bernd, it is really necessary to sort the pending Messages by time? The pendingMessages list is not already sorted by default?
Another question: when using repeat for each in CR-delimited list, are we sure the lines order is preserved? In some other languages, the use of each don't preserve the order.
Yes, the pending messages are sorted ascending by time (item 2 of the pending messages).
That means the oldest message is the first one.

What I do is to sort pending messages descending. That is the first message is that last one sent. I then delete all pending messages except for the last one sent. I then exit the deletion part and the last pending message arrives and triggers the handler in the bottom part of the "doResize" handler. This way I get the last message with the final dimensions of the stack in pNewWidth, pNewHeight.

That is all. A bit complicated but a sound logic.

Regarding "repeat for each": in Livecodescript repeat for each the line order is always preserved.

Kind regards
Bernd

in case you are afraid you are the only one using my "resizeStack" hack here is another user
https://forums.livecode.com/viewtopic.p ... 89#p217080

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image?

Post by Zax » Tue Aug 16, 2022 4:02 pm

Thank you Bernd for your explanations, you convinced me.

Thanks to all your help, I now have a working game :)
Though I tried to optimize the code, card movement is a bit jerky on my old machine but should be fine on a newer machine.

Now back to my original problem: SVGs!
The cards I used for the development - thanks to the stack provided by Jeff (SVG_CardDemo.zip) - are not suitable for a Beleaguered Castle card game: the reference of each card is missing on the left side, which makes the tableau difficult to read. Besides, I don't find them very attractive.

bc.jpg

Jeff has also posted an URL that could be interesting but I'm totally lost in the project:
https://github.com/PaulMcClernan/OpenXT ... ayLibMaker

So how could I import other playing card SVGs (either the full tableau or card by card) into my stack? I can try using Inkscape, although I don't understand anything about that software (or any vector drawing software).

Another question about SVG picture: is there a way to its nominal width and height?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Tue Aug 16, 2022 4:41 pm

If you do a web search I am absolutely sure you will find SVG images of cards that do NOT contain fonty components.

I am not sure what you mean about something missing from the left sides.

This evening are having guests, tomorrow I'll see what I can come up with.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Tue Aug 16, 2022 11:11 pm

If you do a web search I am absolutely sure you will find SVG images of cards that do NOT contain fonty components.
Was I talking out of my rear end, or was I talking out of my rear end?

Just spent 30 fruitless minutes proving only one thing . . .

I have tried to convert the SVG suite I uploaded previously with Inkscape and got nowhere.

To import snapshots from Paul McClernan's cards is 2 minutes work: but what one ends up with
are bitmaps that go jaggy when resized:
-
SShot 2022-08-17 at 1.36.55.jpg

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Tue Aug 16, 2022 11:47 pm

HOWEVER . . .

https://opengameart.org/content/playing ... vector-png

The picture cards for SPADES and HEARTS do NOT thrill my gorilla much:
-
SShot 2022-08-17 at 1.46.20.png
-
The Letters/Numbers do NOT come through either; but, at least they are less cruddy than the Wikipedia ones.
Last edited by richmond62 on Wed Aug 17, 2022 1:32 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Tue Aug 16, 2022 11:55 pm

This lot, at least have full pictures, BUT the same problem with Letters/Numbers:

https://github.com/hayeah/playing-cards-assets

These:-
-
SShot 2022-08-17 at 1.54.57.png
-
Work . . . https://totalnonsense.com/download/vect ... -download/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Wed Aug 17, 2022 12:06 am

Attachments
LGPL 3.0 - LICENSING INFORMATION.txt.zip
Guff
(3.1 KiB) Downloaded 50 times

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image?

Post by Zax » Wed Aug 17, 2022 9:18 am

Thanks a lot richmond!

My bad in my previous post, I was talking about the top-right of the cards:
bca.jpg

The kind of cards I need doesn't seem to be easy to find, so maybe I could modify existing SVGs.
I finally found how to import an Inkscape document (even with text) in a LC stack, but how can I export a SVG image from LC to an SVG file?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Wed Aug 17, 2022 9:25 am

I don't think you can export SVG files from LC.

But you can go to that 'totalnonsense' URL and download those SVG files the way I did, modify them, and then import them into LC.

Mind you; presumably you want to have each card look something like this:
-
CLUB-11-JACK.png
CLUB-11-JACK.png (65.15 KiB) Viewed 4108 times
-
where its value is marked in ALL 4 corners.

Doing that in GIMP and exporting the result as a PNG image is dead easy, but how you will do that
in Inkscape to produce SVG images escapes me at the moment.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Wed Aug 17, 2022 10:57 am

Here's what some FREE online PNG-SVG converters managed:
-
SShot 2022-08-17 at 12.56.31.png
-
I feel that

https://www.freeconvert.com/png-to-svg

does a reasonable job.


Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image?

Post by Zax » Wed Aug 17, 2022 12:57 pm

Great!
If I'm totally lost with Inkscape, I'll use this converter to convert graphics from Photoshop.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Wed Aug 17, 2022 1:37 pm

With those initial SVG images imported into LC, you can automate putting their values in the other 2 corners, and exporting snapshots of them as PNG images: then use that free PNG-SVG thing and import those SVG images into LC.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9358
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Create a button's icon with a part of a big image?

Post by richmond62 » Wed Aug 17, 2022 3:41 pm

SShot 2022-08-17 at 17.37.37.png
-
This stack does the processing to produce PNG images like this:
-
DIAMOND-13-KING.png
DIAMOND-13-KING.png (52.68 KiB) Viewed 4025 times
-
You can then use the online converter to end up with SVG images.

https://www.dropbox.com/s/pa4c1owyh6zx7 ... e.zip?dl=0

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image?

Post by Zax » Wed Aug 17, 2022 4:41 pm

Meanwhile, I modified some SVGs found on the net with Inkscape - a long and boring work.
I'll try to use them in my stack tomorrow.

If it doesn't work as expected, I'll use your solution, richmond. Anyhow, your solution is very interesting for me in order to make several (and different) cards sets because it looks much easy and fast then working on SVG files (Inkscape is great, but weird and not very friendly. Besides, it often crashes on my machine).

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”