Skip to content

Z-order for some strokes is wrong, wrong, wrong. #1

Description

@Fweeb

A little background is in order here.

In SWF, every edge can have a line style and two fill styles. This is how SWF handles overlapping geometry. Taken from the SWF specification:

For example, if a shape consists of two overlapping squares, and only FillStyle0 is defined, Flash Player renders a ‘hole’ where the paths overlap. This area can be filled using FillStyle1. In this situation, the rule is that for any directed vector, FillStyle0 is the color to the left of the vector, and FillStyle1 is the color to the right of the vector

Now, the PYSWF library that has been pulled into this add-on helps a bit with its SWFShape object. In particular, if you run the _create_edge_maps() function, you populate the object's fill_edge_maps and line_edge_maps arrays which, in turn, are used by the _create_path_from_edge_maps() function. That last function is particularly useful because the resulting path is a sequence of edges with one line style and just one fill style.

The problem is that the library doesn't seem to do a good job of picking the correct fill style in the cases where you actually have a fill style index (indices start at 1, so an index of zero is considered not having a style). In fact, in those circumstances, you end up with two paths: one for each fill style. One of those paths is correctly filled. The other one has a fill style that matches the fill of larger stroke surrounding it (because, really, it's supposed to be a hole).

Granted, Grease Pencil strokes don't really support holes and you have to make due with a special holdout material... but that's a separate discussion.

The point here is that right now, imported paths get two strokes... and the wrong one is often on top. So you get a result like this (artwork courtesy of Stephen Brooks and his book Tradigital Animate CC):

zorder

Notice the fingers, Adam's apple, and ears.

I think the place to fix this is in the _process_sub_path() function in the SWFShape object definition here in data.py... but I could be wrong.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions