The previous post showed cutting an object with lines and a curve. I've worked the code and can now slice an image into many pieces.
As before, if you would like this for your own projects, please get in touch on the CoronaLabs forums - user Horacebury.
Showing posts with label videos. Show all posts
Showing posts with label videos. Show all posts
Friday, April 11, 2014
Friday, March 21, 2014
Polygon Slicing With Corona SDK
As we all know by now, Corona SDK includes the fantastic 2D physics engine Box2D. Play with this for long enough and knowing how to manipulate polygons becomes very useful indeed. I've wanted to implement everything from Angry Birds to iSlash, so it was awesome to see Corona Labs include the new display.newOutline() function in a recent build.
This cool function basically takes a PNG with web transparency and returns a table of x,y coordinates for the circumference polygon of the visible pixels in the PNG. That polygon can then be plugged into a new constructor parameter of the physics.addBody() function to actually create a physics body against an image for that image's outline.
I wanted to take that further, ala iSlash, and decided to produce a library which would take the outline polygon and the end points of a line and separate the polygon into sliced parts. I won't go into the painful details of trying to dig up the code from the internet but suffice to say that code I found was either unintelligable enough to use or simply a mass of maths that I couldn't fathom.
Fast forward a few days and having tried at least 3 different methods I finally hit upon a winner. Here's the proof, running on Mac Corona simulator...
[View full size video]
As you can see, the intersection code works both for a single line cutting straight through the object at any any angle and even re-entering the polygon multiple times. It also handles a hand-drawn curve which, likewise, can start anywhere and enter/exit the shape as often as required. This allows quite a powerful set of options ranging from effects seen in iSlash to cutting shapes into unordered pieces.
I won't be posting the code this time as I fully intend to use this in my own productions. If you would like to implement this in your own production please get in touch via the Corona forums or on twitter: @horacebury
This cool function basically takes a PNG with web transparency and returns a table of x,y coordinates for the circumference polygon of the visible pixels in the PNG. That polygon can then be plugged into a new constructor parameter of the physics.addBody() function to actually create a physics body against an image for that image's outline.
I wanted to take that further, ala iSlash, and decided to produce a library which would take the outline polygon and the end points of a line and separate the polygon into sliced parts. I won't go into the painful details of trying to dig up the code from the internet but suffice to say that code I found was either unintelligable enough to use or simply a mass of maths that I couldn't fathom.
Fast forward a few days and having tried at least 3 different methods I finally hit upon a winner. Here's the proof, running on Mac Corona simulator...
[View full size video]
As you can see, the intersection code works both for a single line cutting straight through the object at any any angle and even re-entering the polygon multiple times. It also handles a hand-drawn curve which, likewise, can start anywhere and enter/exit the shape as often as required. This allows quite a powerful set of options ranging from effects seen in iSlash to cutting shapes into unordered pieces.
I won't be posting the code this time as I fully intend to use this in my own productions. If you would like to implement this in your own production please get in touch via the Corona forums or on twitter: @horacebury
Thursday, June 27, 2013
Angry Birds in 30 Mins
It's a bit old now, but the proof still stands and this is a very entertaining video: Seb Lee-Delisle teaching an audience how to code up a simple Angry Birds in 30 mins with CoronaLabs' CoronaSDK.
You can follow Seb on Twitter: https://twitter.com/seb_ly and browse his internet wanderings: http://seb.ly/
You can follow Seb on Twitter: https://twitter.com/seb_ly and browse his internet wanderings: http://seb.ly/
Friday, June 19, 2009
Too Awesome For Words...R2
http://www.wired.com/video/latest-videos/latest/1815816633/10000-fully-functional-r2d2/24892334001
R2-D2 droids for sale - $10,000 each.
Saturday, June 06, 2009
Acorn Gamez - Reliving The Wonder
While getting a bit hacked off with a PC yesterday, I went looking for some videos from years gone by. I found some videos by a guy who really should be linked: http://www.youtube.com/user/peetvanpeebles
Wednesday, June 03, 2009
Literal Music Video
Just been sent a link for literal music videos on youtube: http://www.youtube.com/watch?v=lj-x9ygQEGA
Very funny.
Monday, June 01, 2009
Tuesday, April 28, 2009
Monday, April 27, 2009
Windows Mobile Video Blogging
I want to be able to stream video direct from my Windows Mobile HTC camera, but until I find (or build) a mobile app to let me do that, I'll have to make do with the ideas in this cool little post:
Or the video equivelent of twitter:
And an update, it is possible, but only with Nokia and iPhone:
Better update:
Just discovered service Qik which provides live video streaming apps for a hell of a lot of mobile phones so I signed up, installed and am up and running! A revolution in blogging!
Check out the mobile links for the sites I found!
Labels:
12seconds,
links,
social,
twitter,
video blogging,
videos,
vlogging,
webcam,
windows mobile
Thursday, April 16, 2009
Plain English RSS
If you are a bit confused by RSS or have not heard of it before, this little beauty should sort you out...
Wednesday, March 25, 2009
Sunday, March 15, 2009
Microsoft links I have yet to read, but really should...
How Do I: Create a Breakpoint
Using Conditions?
How Do I: Create a Breakpoint Using Hit Count?
How Do I; Learn Tips and Tricks for Debugging in Visual Studio?
Office Development with Visual Studio Developer
Center Just Launched!
Microsoft Cloud Computing Tools
How Do I: Add Tool Windows to the Visual Studio IDE?
How Do I: Add a New Tool Window to Visual Studio?
How Do I: Integrate With the Error List?
How Do I: Create a Basic Language Service Using the Managed Babel System?
How Do I: Create Custom
Project Templates Using Visual Studio 2008?
How Do I: Create an Item Template Using Visual Studio 2008?
How Do I: Write to the Output Window?
Explore the New Features of Visual Studio 2008
How Do I: Create a Debugger Visualizer?
How Do I: Place My Commands Into Different Kinds of Visual Studio Menus?
How Do I: Add Commands
and Controls Into the Visual Studio IDE?
How Do I: Get Started with the VisualStudio Domain Specific Languages?
Heroes Happen Here
DotNetNuke® and Visual Studio 2008
Visual Studio Tip of the Day
How Do I: Add AJAX Functionality to an Existing ASP.NET Page?
How Do I: Debug a Windows Presentation Foundation Application in Visual Studio 2008?
How Do I: Use the LINQ-Enabled
XML API in Visual Studio 2008?
Using Conditions?
How Do I: Create a Breakpoint Using Hit Count?
How Do I; Learn Tips and Tricks for Debugging in Visual Studio?
Office Development with Visual Studio Developer
Center Just Launched!
Microsoft Cloud Computing Tools
How Do I: Add Tool Windows to the Visual Studio IDE?
How Do I: Add a New Tool Window to Visual Studio?
How Do I: Integrate With the Error List?
How Do I: Create a Basic Language Service Using the Managed Babel System?
How Do I: Create Custom
Project Templates Using Visual Studio 2008?
How Do I: Create an Item Template Using Visual Studio 2008?
How Do I: Write to the Output Window?
Explore the New Features of Visual Studio 2008
How Do I: Create a Debugger Visualizer?
How Do I: Place My Commands Into Different Kinds of Visual Studio Menus?
How Do I: Add Commands
and Controls Into the Visual Studio IDE?
How Do I: Get Started with the VisualStudio Domain Specific Languages?
Heroes Happen Here
DotNetNuke® and Visual Studio 2008
Visual Studio Tip of the Day
How Do I: Add AJAX Functionality to an Existing ASP.NET Page?
How Do I: Debug a Windows Presentation Foundation Application in Visual Studio 2008?
How Do I: Use the LINQ-Enabled
XML API in Visual Studio 2008?
Subscribe to:
Posts (Atom)