Back to godoc.org

Package geom

v0.0.0 (973feb4)
Latest Go to latest
Published: Aug 1, 2020 | License: BSD-3-Clause | Module: golang.org/x/mobile

Overview

Package geom defines a two-dimensional coordinate system.

The coordinate system is based on an left-handed Cartesian plane. That is, X increases to the right and Y increases down. For (x,y),

(0,0) → (1,0)
  ↓   ↘
(0,1)   (1,1)

The display window places the origin (0, 0) in the upper-left corner of the screen. Positions on the plane are measured in typographic points, 1/72 of an inch, which is represented by the Pt type.

Any interface that draws to the screen using types from the geom package scales the number of pixels to maintain a Pt as 1/72 of an inch.

Index

Package Files

type Point

type Point struct {
	X, Y Pt
}

Point is a point in a two-dimensional plane.

func (Point) String

func (p Point) String() string

String returns a string representation of p like "(1.2,3.4)".

type Pt

type Pt float32

Pt is a length.

The unit Pt is a typographical point, 1/72 of an inch (0.3527 mm).

It can be be converted to a length in current device pixels by multiplying with PixelsPerPt after app initialization is complete.

func (Pt) Px

func (p Pt) Px(pixelsPerPt float32) float32

Px converts the length to current device pixels.

func (Pt) String

func (p Pt) String() string

String returns a string representation of p like "3.2pt".

type Rectangle

type Rectangle struct {
	Min, Max Point
}

A Rectangle is region of points. The top-left point is Min, and the bottom-right point is Max.

func (Rectangle) String

func (r Rectangle) String() string

String returns a string representation of r like "(3,4)-(6,5)".

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier