Jump to content


Photo

FW beziers to Flash curves


  • Please log in to reply
9 replies to this topic

#1 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 03 April 2007 - 05:02 PM

The bottom line is I spent most of my math classes in school drawing flip book animations in my textbook(I need to digitized some of them! Star Wars in 500 frames, anyone?). I might have paid more attention if I had known I'd be attempting to use math to create cool stuff!

So here's the challenge. I have more than a few commands and panels which would need to render FW point data in Flash. The problem is that Flash's drawing API fundamentally works in a different manner than FW and other apps. In plain terms, I observed that Flash uses a single handle between two points to create a curve, where as most drawing applications use the classic two handles for each point. After some research, it appears this is Quadratic vs. Cubic Bezier curves.

What I need, I suppose, is some way to translate FW(Cubic?) Bezier curves into Flash(Quadratic?) Bezier curves, so I can render in Flash what the user is doing. I hopefully won't ever need to convert the other way around, if I do it right all manipulations will be done to the FW point data and re-translated and rendered.

Just wondering if anyone happens to to carry around a FW-to-Flash formula in their back pocket and could pass it my way, or lend any advice :)

#2 so1980==MikeTaylor

so1980==MikeTaylor

    FireworksNut

  • FwGurus
  • PipPipPipPipPipPip
  • 645 posts
  • Location:Brooklyn, New York, USA
  • Interests:Fireworks, Sociolinguistics, Dialects, New York City, & Burritos.

Posted 03 April 2007 - 07:10 PM

I don't really have an answer to your question, but I'm wondering if the problem you're working on will change with Flash CS3's new pen tool. It's supposed to be the same as Illustrator, so that might be a hint.

#3 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 04 April 2007 - 07:27 AM

Not really, the problem I'm working on is not really related to Flash tools vs. FW tools, it has to do with trying to display FW API point data in a SWF. See, Flash's drawing API - the way you draw stuff using ActionScript, specifically lineTo() and curveTo() - use different data than what you are used to drawing with pen tools, and what the FW API creates for points. So somehow I have to convert that kind of 'pen' data into 'Flash API data' simply so I can render it in a SWF and the user can actually see it.

That being said, at the bottom of the article I linked to it looks like he actually has just that(3 different flavors to choose from, too!). But how it works is not quite what I was expecting... it takes 4 control points(two anchors and two handles between), not 3(single anchor with preceding/succeeding handles). I guess that's because it's technically drawing a line segment, not points. I think I can make that work... stay tuned!

#4 senocular

senocular

    Fireworks Extender

  • Administrators
  • PipPipPipPipPip
  • 150 posts
  • Location:San Francisco, CA (USA)

Posted 05 April 2007 - 11:12 AM

timothee's article is the best resource I know for that.

Otherwise its just a matter of searching and finding those algorithyms that make that conversion.

#5 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 07 April 2007 - 06:39 AM

Cool, that worked out nicely. Here's my first use of it -- the 3D Rotate command(3D stolen from Trevor's kirupa article):

http://fireworks.abe.....3D Rotate.swf

[right-click above link, download to Fireworks 8/Configuration/Commands/, acces via Commands > 3D Rotate -- no restart required]

However, after I created the command I realized something that makes me feel very, very stupid. A FW command can actually update the canvas, so I didn't have to make that ridiculously big preview viewport with imported path data. Doh! I'm not sure if I should scrap that preview area thing and make the interface more like Illustrator's 3D Rotate with just a small interactive cube, or leave it like it is. What do you guys think?

#6 so1980==MikeTaylor

so1980==MikeTaylor

    FireworksNut

  • FwGurus
  • PipPipPipPipPipPip
  • 645 posts
  • Location:Brooklyn, New York, USA
  • Interests:Fireworks, Sociolinguistics, Dialects, New York City, & Burritos.

Posted 07 April 2007 - 09:40 AM

abeall, this is so friggin' cool.

personally, i don't mind the preview window, as it allows you to isolate what you're trying to "rotate." but, it also might be nice to see the canvas updating with the vector in context.

maybe "show axis" should be "show axes"?

but wow, you should sell this to adobe. it's that cool. ;)

#7 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 07 April 2007 - 11:39 AM

Yeah, I think I'll just leave it like it is and add an "Update Canvas" or "Canvas Preview" checkbox, sort of best of both worlds I guess. Except you can't see anything on the canvas easily when it's obscured by a 800x600 command window :) Haven't tried the command on a super complex shape yet either, to see if performance doesn't shrivel up and die, though I did try it out on some text converted to paths and it was okay.

You're right about the 'axes' :-)

I want to see if I can make it remember 3D transform so you can re-rotate or remove 3D rotation later. Also want to see if I can use the distortion tools to make it apply to anything(text, bitmaps, symbols, etc), that would be great.

#8 so1980==MikeTaylor

so1980==MikeTaylor

    FireworksNut

  • FwGurus
  • PipPipPipPipPipPip
  • 645 posts
  • Location:Brooklyn, New York, USA
  • Interests:Fireworks, Sociolinguistics, Dialects, New York City, & Burritos.

Posted 07 April 2007 - 01:45 PM

i tried to rotate your avatar, but the bitmaps were getting in the way. :) it seemed to do fine, but it certainly isn't the most complex. i even tried out a few autoshapes, and they rotated fine, until you tried to edit the points, then it pops back to '2d.'

#9 abeall

abeall

    FireworksNut

  • Administrators
  • PipPipPipPipPipPip
  • 523 posts

Posted 07 April 2007 - 01:50 PM

Cool, I didn't even realize my avatar was an editable PNG, that's neat! Your is flatted, 'sup with that? ;)

#10 fljaweiu

fljaweiu

    Fireworks Sparkle

  • Members
  • Pip
  • 3 posts

Posted 15 December 2010 - 12:47 AM

add more contrast. and you may want to put a call to action instead of "click here"