O1Library Docs
Fall 2023
Docs API

# HasEdges

o1.world.objects.HasEdges
trait HasEdges extends HasPos, HasAnchor

A supertype for objects that take up a rectangular area and have an anchoring point. The object’s `pos` indicates the position of the anchoring point; the locations of its edges are determined relative to the anchor.

## Attributes

Graph
Supertypes
  trait HasAnchor
  trait HasSize
  trait HasPos
  class Object
  trait Matchable
  class Any
  Show all
Known subtypes
  trait HasContainer
  trait ContainedObject
  trait MovingObjectInContainer

## Members list

### Value members

#### Concrete methods

def anchor: Anchor

Returns the object’s anchoring point, which is Anchor.Center unless overridden.

Returns the object’s anchoring point, which is Anchor.Center unless overridden.

## Attributes

def bottom: Double

Returns the y coordinate of the bottom edge.

Returns the y coordinate of the bottom edge.

## Attributes

def bottomLeft: Pos

Returns the coordinates of this object’s bottom left-hand corner.

Returns the coordinates of this object’s bottom left-hand corner.

## Attributes

def bottomRight: Pos

Returns the coordinates of this object’s bottom right-hand corner.

Returns the coordinates of this object’s bottom right-hand corner.

## Attributes

def center: Pos

Returns the average position between this object’s edges.

Returns the average position between this object’s edges.

## Attributes

def clampWhollyInside(container: HasEdges, desiredPosition: Pos): Pos

Looks for a position for this object that is as close to possible to a particular target position but keeps the object’s edges within the bounds of the given other object.

Looks for a position for this object that is as close to possible to a particular target position but keeps the object’s edges within the bounds of the given other object.

## Parameters

container

  another object that sets the boundaries for the return value

desiredPosition

  the ideal position for this object (defaults to the object’s current pos)

## Attributes

Returns

  the location closest to `desiredPosition` where this object’s anchor can be placed without its edges extending beyond `container`

def clampXWhollyInside(container: HasEdges, desiredPosition: Pos): Pos

Looks for a position for this object that is as close to possible to a particular target position but keeps the left and right edges of the object within the bounds of the given other object.

Looks for a position for this object that is as close to possible to a particular target position but keeps the left and right edges of the object within the bounds of the given other object.

## Parameters

container

  another object that sets the boundaries for the return value

desiredPosition

  the ideal position for this object (defaults to the object’s current pos)

## Attributes

Returns

  the location closest to `desiredPosition` where this object’s anchor can be placed without its left or right edge extending beyond `container`

def clampYWhollyInside(container: HasEdges, desiredPosition: Pos): Pos

Looks for a position for this object that is as close to possible to a particular target position but keeps the top and bottom edges of the object within the bounds of the given other object.

Looks for a position for this object that is as close to possible to a particular target position but keeps the top and bottom edges of the object within the bounds of the given other object.

## Parameters

container

  another object that sets the boundaries for the return value

desiredPosition

  the ideal position for this object (defaults to the object’s current pos)

## Attributes

Returns

  the location closest to `desiredPosition` where this object’s anchor can be placed without its top or bottom edge extending beyond `container`

def closestPosTo(target: Pos): Pos

Returns the position within this object’s edges that is as close as possible to the given position.

Returns the position within this object’s edges that is as close as possible to the given position.

## Attributes

def containsBetweenEdges(candidate: Pos): Boolean

Determines whether the given `Pos`’s x coordinate is between this object’s left edge (inclusive) and its right edge (exclusive) and if it’s y coordinate is similarly between the top and bottom edges.

Determines whether the given `Pos`’s x coordinate is between this object’s left edge (inclusive) and its right edge (exclusive) and if it’s y coordinate is similarly between the top and bottom edges.

## Attributes

def left: Double

Returns the x coordinate of this object’s left edge.

Returns the x coordinate of this object’s left edge.

## Attributes

def right: Double

Returns the x coordinate of the right edge.

Returns the x coordinate of the right edge.

## Attributes

def top: Double

Returns the y coordinate of the top edge.

Returns the y coordinate of the top edge.

## Attributes

def topLeft: Pos

Returns the coordinates of this object’s top left-hand corner.

Returns the coordinates of this object’s top left-hand corner.

## Attributes

def topRight: Pos

Returns the coordinates of this object’s top right-hand corner.

Returns the coordinates of this object’s top right-hand corner.

## Attributes

#### Inherited methods

def centerFromTopLeft: Pos

the location of this object’s center: the average point between its edges, expressed in coordinates relative to the object’s top left-hand corner

the location of this object’s center: the average point between its edges, expressed in coordinates relative to the object’s top left-hand corner

## Attributes

Inherited from:
  HasSize

def distance(another: HasPos): Double

Determines the distance (“as the crow flies”) between this object’s `pos` and that of the given object.

Determines the distance (“as the crow flies”) between this object’s `pos` and that of the given object.

## Attributes

Inherited from:
  HasPos

def height: Double

this object’s height: the distance from its top edge to its bottom edge

this object’s height: the distance from its top edge to its bottom edge

## Attributes

Inherited from:
  HasSize

def internalAnchorPos: Pos

Returns the Pos of the anchoring point within this object, expressed as coordinates relative to the object’s top left-hand corner.

Returns the Pos of the anchoring point within this object, expressed as coordinates relative to the object’s top left-hand corner.

## Attributes

Inherited from:
  HasAnchor

def internalAnchorX: Double

Returns the x coordinate of the anchoring point within this object, relative to the object’s left edge.

Returns the x coordinate of the anchoring point within this object, relative to the object’s left edge.

## Attributes

Inherited from:
  HasAnchor

def internalAnchorY: Double

Returns the y coordinate of the anchoring point within this object, relative to the object’s top edge.

Returns the y coordinate of the anchoring point within this object, relative to the object’s top edge.

## Attributes

Inherited from:
  HasAnchor

def pos: Pos

the object’s location

the object’s location

## Attributes

Inherited from:
  HasPos

def width: Double

this object’s width: the distance from its left edge to its right edge

this object’s width: the distance from its left edge to its right edge

## Attributes

Inherited from:
  HasSize