cls_Position - almarklein/visvis GitHub Wiki

Inherits from object.

The position class stores and manages the position of wibjects. Each wibject has one Position instance associated with it, which can be obtained (and updated) using its position property.

The position is represented using four values: x, y, w, h. The Position object can also be indexed to get or set these four values.

Each element (x,y,w,h) can be either:

  • The integer amount of pixels relative to the wibjects parent's position.
  • The fractional amount (float value between 0.0 and 1.0) of the parent's width or height.

Each value can be negative. For x and y this simply means a negative offset from the parent's left and top. For the width and height the difference from the parent's full width/height is taken.

An example: a position (-10, 0.5, 150,-100), with a parent's size of (500,500) is equal to (-10, 250, 150, 400) in pixels.

Remarks:

  • fractional, integer and negative values may be mixed.
  • x and y are considered fractional on <-1, 1>
  • w and h are considered fractional on [-1, 1]
  • the value 0 can always be considered to be in pixels

The position class also implements several "long-named" properties that express the position in pixel coordinates. Internally a version in pixel coordinates is buffered, which is kept up to date. These long-named (read-only) properties are: left, top, right, bottom, width, height,

Further, there are a set of properties which express the position in absolute coordinates (not relative to the wibject's parent): absLeft, absTop, absRight, absBottom

Finally, there are properties that return a two-element tuple: topLeft, bottomRight, absTopLeft, absBottomRight, size

The method InPixels() returns a (copy) Position object which represents the position in pixels.

The Position class implements the following properties:
absBottom, absBottomRight, absLeft, absRight, absTop, absTopLeft, bottom, bottomRight, h, height, left, right, size, top, topLeft, w, width, x, y

The Position class implements the following methods:
Copy, Correct, InPixels, Set

Properties

Get absTop+height.

Get a tuple (right, bottom).

Get the x-element of the position, expressed in absolute pixels instead of relative to the parent.

Get absLeft+width.

Get the y-element of the position, expressed in absolute pixels instead of relative to the parent.

Get a tuple (absLeft, absTop).

Get top+height.

Get a tuple (right, bottom).

Get/Set the h-element of the position. This value can be an integer value or a float expressing the height as a fraction of the parent's height. The value can also be negative, in which case it's subtracted from the parent's height.

Get the h-element of the position, expressed in pixels.

Get the x-element of the position, expressed in pixels.

Get left+width.

Get a tuple (width, height).

Get the y-element of the position, expressed in pixels.

Get a tuple (left, top).

Get/Set the w-element of the position. This value can be an integer value or a float expressing the width as a fraction of the parent's width. The value can also be negative, in which case it's subtracted from the parent's width.

Get the w-element of the position, expressed in pixels.

Get/Set the x-element of the position. This value can be an integer value or a float expressing the x-position as a fraction of the parent's width. The value can also be negative.

Get/Set the y-element of the position. This value can be an integer value or a float expressing the y-position as a fraction of the parent's height. The value can also be negative.

Methods

Make a copy of this position instance.

Correct the position by suplying a delta amount of pixels. The correction is only applied if the attribute is in pixels.

Return a copy, but in pixel coordinates.

Set(x, y, w, h) or Set(x, y).

⚠️ **GitHub.com Fallback** ⚠️