Comments (17)
Hey Tim, that's a valid thought. However, i've never encountered any SWF that has overlapping edges - at least not those produced by Adobe tools. Theoretically though, i think it is possible (the SWF spec doesn't explicitly forbid that). Have you ever tried to create a SWF that has overlapping edges? What does the Flash Player do with it?
from as3swf.
Well, I assume the exporter works as it works now due to fillStyle0 / fillStyle1 (winding rules). To find clockwise / counter-clockwise paths. That in itself works perfect.
Now the problem is that "stroke info" isn't passed into begin_fill(), so exporters don't know how to stroke the fill.
Anyway: I think Flash player works as follows:
1] draw the shapes including stroke info (if the shape is stroked / has_line_style of course)
2] draw "empty" shapes, or in other words: "strokes only"
Of course I might be mistaken.
Here's an example swf: https://dl-web.dropbox.com/get/Public/drumstel.swf?w=8368cbb9
Its a drumkit. Problem is with the bass-drum: there's a rectangle which left/right sides stroke "over" the bass-drum. This is not correct: the strokes should be "behind", ie: on the z-position of the rectangle shape.
from as3swf.
Of course: this isn't a very common case.
Users have to really force things for this issue to show (as Adobe Tools often take care of overlapping edges as you noted).
However: if users persist they can create SWFs exposing the issue.
from as3swf.
Here's a PNG showing the drumkit issue: https://dl-web.dropbox.com/get/Public/drumstel.png?w=9b8af18d
=> you see the base-drum's sides thru the 2 drums above it.
=> that 2 drums and the base-drum are defined within the same Shape
from as3swf.
Your Dropbox links don't work for me (?)
from as3swf.
hmmm, weird.
https://github.com/timknip/as3swf/blob/master/data/
(sorry for this odd route :)
from as3swf.
Anyway: I'll do some more research on this. Let you know later this week what I find.
Just feel it would be better if lineStyle and fillStyle are exported in the same loop:
if lineStyle: handler.beginLine()
if fillStyle: handler.beginFill()
moveTo
lineTo
....
if fillStyle: handler.endFill()
[repeat for remaining edge-records]
from as3swf.
Hm. Did some reading (including your post http://wahlers.com.br/claus/blog/hacking-swf-1-shapes-in-flash/)
It sure looks likely sorting of strokes goes by lineStyle. Lets forget for a moment non-Adobe tools like Ming et al.
Also the strokes after fills looks like its correct (i'm backtracking :)
Imported "drumstel.swf" into Flash CS5 and observed the drum-kit shapes are grouped.
After ungrouping and saving the SWF the export is correct!
Question of course: is it possible to detect this grouping?
Flash player might work for a single shape like:
startGroup()
renderFills()
renderStrokes()
[some magic code]
endGroup()
startGroup()
renderFills()
renderStrokes()
etc...
Quest continues....
[edit]
actually: this theory seems nonsense :-) All I know that for some reason grouping seems related to the issue.
from as3swf.
Hmm interesting. How did you create the drumkit swf?
from as3swf.
Unproved Theory:
The main sorting is by fillStyle. After output of the current fillStyle directly output the strokes (in lineStyle order).
Repeat for each fillStyle.
Finally output edges having no fillStyle.
Investigating...
from as3swf.
drumkit is for sure Adobe output.
from as3swf.
Oh i thought that was home grown. Ok, then this absolutely deserves investigating.
from as3swf.
Interesting pattern while tracing out shape records of drum-kit swf :
[...]
LINE_TO
LINE_TO
SELECTING LINESTYLE: 0
SELECTING FILLSTYLE_0: 0
SELECTING FILLSTYLE_1: 0
MOVE_TO
SELECTING LINESTYLE: 2
SELECTING FILLSTYLE_1: 5
MOVE_TO
LINE_TO
LINE_TO
The reset of ls, fs0 and fs1 to zero might indicate "end of group".
from as3swf.
This are subsequent records (note the state flags!):
[...]
[SWFShapeRecordStraightEdge] Horizontal: 36
[SWFShapeRecordStraightEdge] General: -4 1
[SWFShapeRecordStyleChange] moveTo: 0 0 fs0: 0 fs1: 0 linestyle: 0 state_flags: 1 1 1
[SWFShapeRecordStyleChange] moveTo: 946 -1127 fs0: 0 fs1: 8 linestyle: 5 state_flags: 0 1 1
[SWFShapeRecordStraightEdge] Horizontal: 16
[SWFShapeRecordStraightEdge] General: 13 8
[...]
Don't believe this is coincidence: maybe fills and strokes should be "flushed" at this point to keep z-order?
from as3swf.
You might be on to something there. I was wondering about subsequent moveTo's myself, as that doesn't make sense (i ignore those when exporting). Maybe it's there for a good reason after all..
from as3swf.
Tim, check this out:
11289c0
http://codeazur.com.br/stuff/drumstel.png
Looks better, eh?
from as3swf.
Ha!
Cool, thanks! I'll throw some more SWF at it to solidify the theory :-)
Will put a python-port on github (pyswf :) later this week or next week.
Also will update my as3swf fork with a descent SWF=>SVG exporter (bitmap-fills, basic filters) asap.
Closing the issue.
from as3swf.
Related Issues (20)
- [Bug] Matrix rotation format needs to be in radians HOT 1
- [Bug]Unknown fill style type: 0x63, Tag: DefineMorphShape2, Index: 4 HOT 1
- defineShape3 - defineFont3
- Include actionScript HOT 3
- Unknown fill style type: 0x5f HOT 2
- https://github.com/doublefx/easyWorker HOT 16
- Info HOT 1
- How to export Embeds ? HOT 1
- TagProductInfo.compileDate doesn't works with AIR SDK and ASC2 compiler HOT 5
- how to write a definesprite to a swf
- 求大神指教如何把一段影片剪辑写入到swf文件中 HOT 3
- Scripts on Timeline HOT 6
- NetStream HOT 7
- Position of path incorrect when exporting as SVG
- fontHeight not read while hasFontClass is true in TagDefineEditText HOT 2
- Info HOT 1
- Parse DefineBitsLossless into a BitmapData HOT 5
- TagDefineBitsLossless2 gives wrong value for the format in toString
- Missing vows for LTS HOT 1
- How to create Shape from Bitmap?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from as3swf.