Skip to content

Implement Sprite rotation attributes #55

@jimbojw

Description

@jimbojw

Currently, sprites are always aligned with the coordinate axes. Instead, sprites should have one or more rotation attributes. This would enable downstream features such as line segments and slanted labels.

Design question: When should the rotation(s) be applied relative to other operations, specifically scaling? To support line segments, the rotation must be applied after scaling. But other use cases (such as rotating a polygon) may be desirable before scaling. The name of each rotation attribute should imply when it is applied relative to these other operations.

API Proposal:

  /**
   * Rotation in radians to apply to the sprite before and after scaling.
   */
  {
    attributeName: 'Rotation',
    isInterpolable: true,
    components: ['BeforeScaling', 'AfterScaling'],
  },

Example:

const sprite = scene.createSprite();
sprite.enter(s => {
  s.RotationAfterScaling = Math.PI / 2;  // Rotate 90 degrees counter-clockwise.
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions