The OpenD Programming Language

linearOffset

Calculates the linear offset of a point from the start (0/0) of a rectangle.

This assumes that (0/0) is equivalent to offset 0. Each step on the x-coordinate advances the resulting offset by 1. Each step on the y-coordinate advances the resulting offset by width.

This function is only defined for the 1st quadrant, i.e. both coordinates (x and y) of pos are positive.

  1. int linearOffset(Point pos, int width)
    @safe @safe pure nothrow @nogc
    int
    linearOffset
    (
    const Point pos
    ,
    const int width
    )
  2. int linearOffset(int width, Point pos)

Return Value

Type: int

y * width + x

Meta

History

Added December 19, 2023 (dub v11.4)