[Go to site: main page, start]

Class EllipseShapeData

The data model for an ellipse shape.

Hierarchy

  • ClientShapeData<this>
    • EllipseShapeData
Index

Properties

_index: number | undefined

The index of this shape within the array of shapes in its parent. See foundry.data.fields.ShapesField.

_source: object

The source data object for this DataModel instance. Once constructed, the source object is sealed such that no keys may be added nor removed.

parent: DataModel<object, DataModelConstructionContext> | null

An immutable reverse-reference to a parent DataModel to which this model belongs.

The defined and cached Data Schema for all instances of this DataModel.

LOCALIZATION_PREFIXES: string[] = ...
TYPE: string = ""

The type of this shape.

Accessors

  • get area(): number

    The area of this shape.

    Returns number

  • get bounds(): Rectangle

    The bounds of this Region.

    The value of this property must not be mutated.

    Returns Rectangle

  • get center(): Readonly<Point>

    The center point of this shape.

    Returns Readonly<Point>

  • get clipperPaths(): readonly (readonly DeepReadonly<types.ClipperPoint>[])[]

    The Clipper paths of this shape. The winding numbers are 1 or 0.

    The value of this property must not be mutated.

    Returns readonly (readonly DeepReadonly<types.ClipperPoint>[])[]

  • get clipperPolyTree(): PolyTree

    The Clipper polygon tree of this shape.

    The value of this property must not be mutated.

    Returns PolyTree

  • get controlHandles(): DeepReadonly<
        {
            [name: string]: { position: Point; rotation: number; visible: boolean };
        },
    >

    The control handles of this shape. Each handle has a position and a rotation in radians.

    Returns DeepReadonly<
        {
            [name: string]: { position: Point; rotation: number; visible: boolean };
        },
    >

  • get gridlessGrid(): GridlessGrid

    The gridless version of the grid that this shape is placed in.

    Returns GridlessGrid

  • get hasRotationalSymmetry(): boolean

    Whether the shape is identical to itself after a rotation around its origin.

    Returns boolean

  • get invalid(): boolean

    Is the current state of this DataModel invalid? The model is invalid if there is any unresolved failure.

    Returns boolean

  • get isAffectedByGrid(): boolean

    Is this shape currently affected by the grid?

    Returns boolean

  • get isEmpty(): boolean

    Returns boolean

  • get measuredSegments(): readonly DeepReadonly<
        { angle?: number; distance: number; ray: Ray; winding: -1
        | 0
        | 1 },
    >[]

    The measured segments of this shape. Each segment consist of a ray, winding order, distance in grid units, and the angle in degrees if it has one. The ray represents the measured segment. If the winding order is ...

    • 1, the segment is an edge in positive orientation.
    • -1, the segment is an edge in negative orientation.
    • 0, the segment is not an edge.

    The distance is the actual grid distance if the shape is grid-based. Otherwise the distance is the distance in pixels divided by of the ratio of grid distance and grid size.

    Returns readonly DeepReadonly<
        { angle?: number; distance: number; ray: Ray; winding: -1
        | 0
        | 1 },
    >[]

  • get origin(): Readonly<Point>

    The origin of this shape.

    Returns Readonly<Point>

  • get polygons(): readonly Polygon[]

    The polygons of this shape.

    The value of this property must not be mutated.

    Returns readonly Polygon[]

  • get polygonTree(): PolygonTree

    The polygon tree of this shape.

    The value of this property must not be mutated.

    Returns PolygonTree

  • get scene(): documents.Scene | null

    The scene that this shape is placed in, if any.

    Returns documents.Scene | null

  • get triangulation(): Readonly<
        { indices: Uint16Array
        | Uint32Array; vertices: Float32Array },
    >

    The triangulation of this shape.

    The value of this property must not be mutated.

    Returns Readonly<{ indices: Uint16Array | Uint32Array; vertices: Float32Array }>

Methods

  • Returns number

  • Internal

    Get the size for the given ray defined by a length and direction.

    Parameters

    • length: number

      The length of the ray in pixels.

    • direction: number

      The direction of the ray in radians.

    • Optionaloptions: { allowZero?: boolean; round?: boolean; snap?: boolean } = {}

      Additional options.

      • OptionalallowZero?: boolean

        Allow the size to be zero?

      • Optionalround?: boolean

        Round the size to integer?

      • Optionalsnap?: boolean

        Snap the size to with defined grid snapping precision?

    Returns number

    The snapped size in pixels.

  • Returns any[]

  • Returns {
        rotate: { position: Point; rotation: number; visible: boolean };
        scaleX: { position: Point; rotation: number; visible: boolean };
        scaleY: { position: Point; rotation: number; visible: boolean };
        translate: { position: Point; rotation: number; visible: boolean };
    }

  • Internal

    Create a measured segment.

    Parameters

    • x: number

      The x-coordinate of the origin of the ray.

    • y: number

      The y-coordinate of the origin of the ray.

    • direction: number

      The direction of the ray in degrees.

    • length: number

      The length of the ray in pixels.

    • alignment: number

      The alignment of the ray.

    • winding: -1 | 0 | 1

      The winding order.

    • Optionalangle: number

      The angle in degrees.

    Returns { angle?: number; distance: number; ray: Ray; winding: -1 | 0 | 1 }

  • Returns { distance: number; ray: Ray; winding: number }[]

  • Internal

    Create a ray.

    Parameters

    • x: number

      The x-coordinate of the origin of the ray.

    • y: number

      The y-coordinate of the origin of the ray.

    • direction: number

      The direction of the ray in degrees.

    • length: number

      The length of the ray in pixels.

    • Optionalalignment: number = 0

      The alignment to ray.

    Returns Ray

  • Internal

    Get the rays for both axes.

    Returns { axisX: Ray; axisY: Ray }

  • Internal

    Snap the given point.

    Parameters

    • point: Point

      The point that is to be snapped.

    Returns Point

    The snapped point.

  • Internal

    Snap the given rotation.

    Parameters

    • rotation: number

      The rotation to be snapped in degrees.

    Returns number

    The snapped rotation in degrees.

  • Internal

    Transform this shape by moving a rotation handle.

    Parameters

    • direction: number

      The direction of the rotation handle in degrees.

    • destination: Point

      The handle destination.

    • snap: boolean

      Snap?

    Returns void

  • Internal

    Transform this shape by moving a scale handle.

    Parameters

    • fieldName: string

      The field name of the axis that is scaled.

    • origin: Point

      The origin.

    • direction: number

      The direction of the axis in degrees.

    • alignment: number

      The alignment of the axis.

    • destination: Point

      The handle destination.

    • snap: boolean

      Snap?

    • OptionalallowZero: boolean

      Allow zero size?

    • Optionalmax: number

      The maximum value.

    Returns void

  • Internal

    Transform this shape by moving the sweep handle.

    Parameters

    • maxAngle: number

      The maximum angle possible.

    • destination: Point

      The handle destination.

    • snap: boolean

      Snap?

    Returns void

  • Parameters

    • event: any

    Returns void

  • Internal

    Handle the drag start event for the creation of this shape.

    Parameters

    • event: FederatedEvent<UIEvent | PixiTouch>

      The pointer event.

    Returns void

  • Returns void

  • Parameters

    • copy: any
    • diff: any
    • options: any
    • state: any

    Returns void

  • Draw reference lines of the shape into the Graphics element, if it has any.

    Parameters

    • graphics: Graphics

      The Graphics element

    Returns void

  • Parameters

    • graphics: any

    Returns void

  • Traverse the data model instance, obtaining the DataField definition for a field of a particular property.

    Parameters

    • key: string | string[]

      A property key like ["abilities", "strength"] or "abilities.strength"

    Returns DataField | undefined

    The corresponding DataField definition for that field, or undefined

  • Move the shape to the given origin.

    Parameters

    • origin: Point

      The (unsnapped) origin.

    • Optionaloptions: { snap?: boolean } = {}

      Additional options.

      • Optionalsnap?: boolean

        Snap the origin?

    Returns void

  • Parameters

    • name: any
    • destination: any
    • __namedParameters: { snap?: boolean } = {}

    Returns void

  • Reset the state of this data instance back to mirror the contained source data, erasing any changes.

    Returns void

  • Rotate the shape by the given angle in degrees around the origin (or pivot).

    Parameters

    • angle: number

      The angle in degrees.

    • Optionaloptions: { pivot?: Point } = {}

      Additional options.

      • Optionalpivot?: Point

        The pivot of rotation. Default: origin.

    Returns void

  • Sample a point from the shape boundary.

    Parameters

    • Optionalout: Point

      A point to write to.

    Returns Point

    The sampled point.

    If the shape is empty.

  • Parameters

    • out: any

    Returns any

  • Test whether given point is contained within this shape.

    Parameters

    Returns boolean

  • Extract the source data for the DataModel into a simple object format that can be serialized.

    Returns object

    The document source data expressed as a plain object

  • Copy and transform the DataModel into a plain object. Draw the values of the extracted object from the data source (by default) otherwise from its transformed values.

    Parameters

    • Optionalsource: boolean = true

      Draw values from the underlying data source rather than transformed values

    Returns object

    The extracted primitive object

  • Update the DataModel locally by applying an object of changes to its source data. The provided changes are expanded, cleaned, validated, and stored to the source data object for this model. The provided changes argument is mutated in this process. The source data is then re-initialized to apply those changes to the prepared data. The method returns an object of differential changes which modified the original data.

    Parameters

    • changes: object = {}

      New values which should be applied to the data model

    • options: DataModelUpdateOptions = {}

      Options which determine how the new data is merged

    Returns object

    An object containing differential keys and values that were changed

    An error if the requested data model changes were invalid

  • Validate the data contained in the document to check for type and content. This method is intended to validate complete model records, verifying both individual field validation as well as joint model validity.

    For validating sets of partial model changes, it is preferred to call DataModel#updateSource as a dryRun. This method provides a convenience alias for such a workflow if changes are provided.

    Warning: if fallback handling is allowed, this process will mutate provided changes or model source data.

    Parameters

    Returns boolean

    Whether the data source or proposed change is reported as valid. A boolean is always returned if validation is non-strict.

    An error thrown if validation is strict and a failure occurs.

  • Protected

    Configure the data model instance before validation and initialization workflows are performed.

    Parameters

    • Optionaloptions: object = {}

      Additional options modifying the configuration

    Returns void

  • Protected

    Create the center point of this shape.

    Returns Point

  • Protected

    Create the origin point of this shape.

    Returns Point

  • Protected

    Resolve a previously-initialized embedded DataModel that corresponds to an element being cleaned. Called during recursive data cleaning when a parent field contains EmbeddedDataField elements, or a single nested DataModel field (such as a TypeDataField), in order to propagate the inner DataModel into _state.model for the recursive clean operation. A single (non-collection) inner model resolves to itself; collection elements are matched by stable _id when one is present, otherwise by positional index.

    Subclasses may override when data preparation reshapes the field property in a way that the default cannot interpret, for example wrapping the container in a non-iterable type or replacing it with a derived view.

    Parameters

    • field: DataField

      The schema field being recursed into.

    • element: { index?: number; value: object } = {}
      • Optionalindex?: number

        The positional index of the element within a container, if applicable.

      • value: object

        The cleaned candidate value for the element being processed.

    • Optionaloptions: Readonly<DataModelCleaningOptions> = {}

      The cleaning options in effect for the operation.

    Returns DataModel<object, DataModelConstructionContext> | null

    The corresponding previously-initialized inner DataModel, or null.

  • Protected

    A generator that orders the DataFields in the DataSchema into an expected initialization order.

    Returns Generator<[string, DataField], any, any>

  • Protected

    Initialize the instance by copying data from the source object to instance attributes. This mirrors the workflow of SchemaField#initialize but with some added functionality.

    Parameters

    • Optionaloptions: object = {}

      Options provided to the model constructor

    Returns void

  • Protected

    Initialize the source data for a new DataModel instance. One-time migrations and initial cleaning operations are applied to the source data.

    Parameters

    Returns object

    Migrated and cleaned source data which will be stored to the model instance, which is the same object as the data argument

  • Protected

    Called when the grid this shape is placed in changes.

    Parameters

    • changed: object

      The changes to the grid.

    Returns void

  • Protected

    Prepare the state object that is transacted through an updateSource operation.

    Parameters

    Returns void

  • Protected

    Rotate the shape by the given angle in degrees around the origin.

    Parameters

    • angle: number

      The angle in degrees.

    Returns void

  • Protected

    Perform the first step of the DataModel#_updateSource workflow which applies changes to a copy of model source data and records the resulting diff.

    Parameters

    • copy: object

      A mutable copy of model source data

    • changes: object

      New values which should be applied to the data model

    • options: DataModelUpdateOptions

      Options which determine how the new data is merged

    • _state: data.types.DataModelUpdateState

      Data cleaning state

    Returns object

    The resulting difference applied to source data

    A failure if the proposed change is invalid

  • Clean a data source object to conform to a specific provided schema.

    Parameters

    • Optionaldata: object = {}

      Provided model data that requires cleaning

    • Optionaloptions: DataModelCleaningOptions = {}

      Options that configure how data cleaning is performed

    • Optional_state: Partial<data.types.DataModelUpdateState> = {}

      Internal options used during cleaning recursion

    Returns object

    Cleaned data which is suitable for validation and usage

  • Migrate candidate source data for this DataModel which may require initial cleaning or transformations.

    Parameters

    • source: object

      Candidate source data for the module, before further cleaning

    • Optionaloptions: Readonly<DataModelCleaningOptions>

      Additional options for how the field is cleaned

    Returns object

    Migrated source data, ready for further cleaning

  • Wrap data migration in a try/catch which attempts it safely.

    Parameters

    • source: object

      Candidate source data for the module, before further cleaning

    • Optionaloptions: Readonly<DataModelCleaningOptions> = {}

      Additional options for how the field is cleaned

    Returns object

    Migrated source data, ready for further cleaning

  • Take data which conforms to the current data schema and add backwards-compatible accessors to it in order to support older code which uses this data.

    Parameters

    • data: object

      Data which matches the current schema

    • Optionaloptions: { embedded?: boolean } = {}

      Additional shimming options

      • Optionalembedded?: boolean

        Apply shims to embedded models?

    Returns object

    Data with added backwards-compatible properties, which is the same object as the data argument

  • Evaluate joint validation rules which apply validation conditions across multiple fields of the model. Field-specific validation rules should be defined as part of the DataSchema for the model. This method allows for testing aggregate rules which impose requirements on the overall model.

    Parameters

    • data: object

      Candidate data for the model

    Returns void

    An error if a validation failure is detected

  • Protected

    Apply final custom model-specific cleaning rules after data schema fields are cleaned. Subclass models can implement this function as an ideal place to apply custom imputation or cleaning. Cleaning must be done in-place rather than returning a different object.

    Parameters

    Returns object

    The original data object, with cleaning performed inplace

  • Protected

    Apply preliminary model-specific cleaning rules or alter cleaning options or initial state. Subclass models may implement this function to configure the cleaning workflow. Any mutations to data, options, or _state parameters are performed inplace.

    Parameters

    Returns void