O1Library Docs
Fall 2026
Docs API

# Anchor

o1.world.objects.Anchor
See the Anchor companion object
trait Anchor

An `Anchor` is a point where a two-dimensional object, such as a Pic, attaches to other such objects; you can also think of it as a “pin” that attaches a `Pic` to a background.

For instance, a `Pic` may have its `Anchor` at its center; the `Pic` may then be attached to a larger image at that image’s `TopLeft` (another anchor), so that the center of the first `Pic` is located at the top left-hand corner of the second `Pic`.

The companion object of this class provides several standard `Anchor`s and a class `Anchor.Absolute` for creating new ones.

`Anchor` objects are immutable.

This trait has an alias in the top-level package o1, so it’s accessible to students simply via `import o1.*`.

## Attributes

See also

  HasAnchor

Companion
  object
Graph
Supertypes
  class Object
  trait Matchable
  class Any
Known subtypes
  class Absolute
  object BottomCenter
  object BottomLeft
  object BottomRight
  object Center
  object CenterLeft
  object CenterRight
  object TopCenter
  object TopLeft
  object TopRight
  Show all

## Members list

### Value members

#### Abstract methods

def internalXWithin(anchored: HasAnchor): Double

Returns the x coordinate of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s left edge.

Returns the x coordinate of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s left edge.

## Attributes

def internalYWithin(anchored: HasAnchor): Double

Returns the y coordinate of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s top edge.

Returns the y coordinate of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s top edge.

## Attributes

#### Concrete methods

def internalPosWithin(anchored: HasAnchor): Pos

Returns the Pos of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s top left-hand corner.

Returns the Pos of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s top left-hand corner.

## Attributes

def toAbsoluteWithin(anchored: HasAnchor): Absolute

Returns an absolute anchor the Pos of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s top left-hand corner.

Returns an absolute anchor the Pos of the anchoring point within the given `Pic` or other anchorable object, relative to the object’s top left-hand corner.

## Attributes