Skip to content

[0.8] Apply mask to overlay objects #136

@cyberbit

Description

@cyberbit

Describe your idea (If you have more than one idea, please open the rest in other issues)

In the current overlay system, 2D objects are always rendered in their entirety. This makes certain outcomes difficult (text clipping) or impossible (half/quarter circle). An optional, per-object, rectangular mask would solve many of these issues.

The user surface could be accomplished with a few new 2D object APIs:

  • Properties: maskMinX, maskMinY, maskMaxX, maskMaxY
  • Set mask: setMask(minX, minY, maxX, maxY). There may be utility in a shortened signature of setMask(maxX, maxY) for common overflow use cases.
  • Clear mask: clearMask(). Mask defaults would be the bounding box of the object.

The coordinate system for XY here may need further discussion. There are advantages and disadvantages to using screen coordinates vs relative coordinates.

Simple text clip example:

sg.createText{
    x = 50,
    y = 50,
    content = "This is some really long text",
	maskMaxX = 75 -- stop rendering text object pixels after x = 75
}

Describe alternatives you've considered if any

No response

Additional context

No response

Linked Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions