Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Automatic label anchor #806

Closed
wants to merge 52 commits into from
Closed

Conversation

karimnaaji
Copy link
Member

@karimnaaji karimnaaji commented Jun 24, 2016

Support for automatic anchoring fallbacks (based off #749).

Defined in the stylesheet as the following (series of fallback separated by commas):

text:
    anchor: right, bottom, left, top

For any labels with potential anchor fallbacks, when a collision happens a label would enter in the anchor_fallback state at frame n, they would enter within this state, the collision system will then try their new position at frame n+1, if no collision happens, they would then get to their visible state, otherwise they would keep trying the next fallbacks on the next frames until they have looped on all of them.

Anchor fallback and dynamic text realignment

  • If no align: property is given, the fallback would automatically realign the text;
    • fallback anchor to right, automatic realignment to left
      screen shot 2016-06-24 at 12 31 41 pm
    • fallback anchor to bottom, automatic realignment to center
      screen shot 2016-06-24 at 12 31 54 pm
  • If align: property is given, the preferred alignment would be assigned to every anchor fallback.

To implement realignment when anchor is being switched, the text quads are being drawn for each of the fallbacks (so quads would be correctly positioned for each of the fallbacks). Then a list of quad ranges associated with their alignment are being given to the text label so it can switch between the quad ranges at render time.

To improve determinism

When a label is colliding and fallbacks to the next anchor, it would stick to this anchor until a new collision happens (where it should fallback to the preferred anchor when space is again available):

should-refallback

TODO

  • Update unit tests

hjanetzek added 30 commits June 16, 2016 10:07
- move quads, copying only used quads on the caller side
- this caused way too many labels in isect2d buckets
- having it inlined should give the compiler some options to optimize
- todo: test if compiler is smart enough to omit 2 divisions
- major speedup compared to collecting all possible collisions first
@bcamper
Copy link
Member

bcamper commented Jun 24, 2016

This is cool! For syntax, while it's in some ways a little less friendly, I'd prefer to use a YAML list to specify multiple anchors. While it's more verbose, it's more consistent with how we've handled single vs. multiple values for other parameters, and it's more explicit and only uses built-in YAML processing vs. being dependent on additional string parsing, e.g. both are valid:

Single value: anchor: top
Multiple values: anchor: [right, bottom, left, top]

@bcamper
Copy link
Member

bcamper commented Jun 24, 2016

I'll make an issue for this for JS. Note that initially we may have to just stub this out, making it take the first specified anchor value and ignore the rest (but accept this syntax rather than failing to parse the feature, for scene file compatibility).

@karimnaaji
Copy link
Member Author

Closing in favor of #842

@karimnaaji karimnaaji closed this Jul 19, 2016
@karimnaaji karimnaaji deleted the automatic-label-anchor branch July 20, 2016 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants