Creating a Mosaic Application

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
mtrigaux
Posts: 2
Joined: Wed Feb 17, 2010 6:21 am

Creating a Mosaic Application

Post by mtrigaux » Wed Feb 17, 2010 6:29 am

Hey Guys,

Just started using RevMedia, I am looking to create a mosaic type of application where I can create a shape and then click a button to make that shape "shatter" into a bunch of pieces. Those smaller pieces will then be used by the user to drag and re-arrange to create a mosaic in the same window. Any advice for best way to have a shape randomly split? Thanks so much!

--Matt

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Creating a Mosaic Application

Post by BvG » Wed Feb 17, 2010 2:22 pm

I don't know exactly what your question is. So I answer two in your general direction. Note: links go to wikipedia

You want to know how to make rev divide an object for you.

If you can absolutely not start with an object that is already pre-seperated, then this is not very simple. So the easy route is to "fake" the shattering by having a "whole" object, and meanwhile having the "splinters" hidden away somehow, then exchanging them. If you want to do it the hard way, I suggest looking at the irregular polygon. As you can define points, you can create slices using cartesian geometry, and then copy those new points into other irregular polygons (created on the fly). Alternatively, you can use the "import snapshot" command, either with pre-made forms that you put behind your object, or by using rectangles.

You want to know some math that makes dividing objects look fancy, regular or special in some way.

You could create a pre-made map of puzzle pieces, which you then superimpose over the object to be divided. They'd need to be stored in cartesian coordinates. Then you can create the slices from the object along those pre-made borders. Another way is to use some tessellation algorithm, personally, I'm very fond of delaunay tessellation (or more precisely it's inverse, the voronoi diagram). You can also randomly calculate lines that cut trough your object, but this might be too random (extremely large and one pixel pieces might result, depending on how you do it).
Many people like uniform tiling, and there's some nice math behind those that you can build on.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

mtrigaux
Posts: 2
Joined: Wed Feb 17, 2010 6:21 am

Re: Creating a Mosaic Application

Post by mtrigaux » Wed Feb 17, 2010 7:24 pm

Great BvG thanks so much for the reply! I think I'll look into possibly having the puzzle already pre-made and hiding the "splinters". Those diagram wiki links are great, thanks for the info!

Post Reply