geom

package
v0.0.0-...-2cb2d44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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)".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL