Skip to content

Measure

Measure

A Measure transform allows to convert a measure expressed in some units (Pixel, Point, Inch, etc.) to normalized device coordinates ([-1,+1] x [-1,+1]). This conversion is always relative to a given Viewport whose width and height dictates the conversion.

Notes

The normalization of a measure (conversion to NDC) migth be different on the x or y axis depending on the size of the related viewport. This means, for example, that the expression 10*pixel is translated differently along x (1st component) and y axis (second component). The z coordinate is not changed during conversion since measures are targeting 2D coordinates.

Examples:

canvas = core.Canvas(512, 512, 100.0)
viewport = core.Viewport(canvas, color=(1,1,0,1))

# 10 pixels from bottom left corner
pixel = transform.Pixel()
P = [-1,-1,0] + 10*pixel

# 10 points from left, 20 points from bottom
point = transform.Point()
P = [-1,-1,0] + (10,20,0)*point

Pixel

Conversion of a measure to pixel.

Point

Conversion of a measure to point

Inch

Conversion of a measure to inch.

Millimeter

Conversion of a measure to millimeter

Centimeter

Conversion of a measure to centimeter

Meter

Conversion of a measure to meter

Kilometer

Conversion of a measure to kilometer