Skip to content

Coordinate System Tutorial

Benedict Allen edited this page Nov 15, 2015 · 3 revisions

Coordinate System

The coordinate system in Sheets is 0-based. That means, to make an element be at the top-left of its parent, its coordinates should be 0, 0, unlike what you'd use in CC (1, 1).

This makes for some interesting possibilities with positioning:

Horizontal

  • Left: x = 0
  • Out of bounds left: x = -self.width
  • Left with margin: x = margin
  • Right: x = parent.width - self.width
  • Out of bounds right: x = parent.width
  • Right with margin: x = parent.width - self.width - margin
  • Horizontal centre: x = math.floor( ( parent.width - self.width ) / 2 )

Vertical

  • Top: y = 0
  • Out of bounds top: y = -self.height
  • Top with margin: y = margin
  • Bottom: y = parent.height - self.height
  • Out of bounds bottom: y = parent.height
  • Bottom with margin: y = parent.height - self.height - margin
  • Vertical centre: y = math.floor( ( parent.height - self.height ) / 2 )

Clone this wiki locally