Skip to content

vtf video geocalc

srccircumflex edited this page Apr 24, 2023 · 2 revisions

↑ vtf-video

geocalc

class geocalc.GeoCalculator

The object is passed per axis to Cell's for calculation of their size.

The basic calculation can be defined in different ways:

  • base_spec: int

    If an integer is passed, it will be returned unchanged when the calculation is retrieved.

  • base_spec: float

    A calculation of the size as a percentage of the total size passed in the calculation can be specified via floating numbers (0.325 == 32,5 %; 1.0 == 100 %).

    Additional parameterization of the percentage calculation are:
    • perc_spec_range_rule: range
      This can be used to adjust the calculated result to a specific range. If the calculated value is greater than or equal to the stop value, the (stop value - 1) is returned; if a start value is defined and the calculated value is smaller, the start value is returned; if a step value is defined, the value is rounded down to the next lower step if the step value is negative, otherwise to the next higher step. If the rule is combined with perc_spec_adjustment, the order of the parameterization represents the order of the working steps.
    • perc_spec_adjustment: int
      This adjustment is added to the calculated result. If the rule is combined with perc_spec_range_rule, the order of the parameterization represents the order of the working steps.
    • perc_spec_round: bool
      Specifies whether the calculated fraction is to be rounded true or rounded down.
  • base_spec: None

    If None is passed, the total size passed is returned during the calculation.

  • base_spec: Callable[ [int], int]

    Own functions for the calculation can be passed as executable object, this receives the total size during the call and must return the calculated size.

After the basic calculation is completed, the result is compared with the value of the remaining space. The algorithm can be optionally created by conditions and actions in a string or strings in a tuple.

Available conditions/statements are:
  • "if val > remain"
  • "if val < remain"
  • "if val == remain"
  • "if remain <= 0"
  • "always"
Available actions are:
  • "use remain"
  • "set 0"
  • "use val"

If the code is passed summarized in a string, condition-action pairs must be written separated by colon, condition and action are also separated by colon.

A more extensive algorithm can be passed through a callable object. The object receives the calculated size and the size of the remaining space when called and must return a numerical value.

The order of querying GeoCalculator's of an axis is defined by the priority list in the grid.

Tip: Instead of trying to divide the entire size in percentages, parameterize the last GeoCalculator in the priority list as follows:

>>> GeoCalculator(None, comp_remain="always:use remain")

__axis_index__: int

__grid_char_range__: tuple[int, int]

comp_remain: tuple[Callable[ [int, int], int | None], ...]

size: int

sizing: Callable[ [int], int]

spec: int | tuple[float, float] | tuple[float, float, range, int] | tuple[float, float, int, range] | tuple[float, float, int] | tuple[float, float, range] | Callable[ [int], int] | None

__call__(_size, _remain) -> int

overload __init__(base_spec, /, *, comp_remain=None)

overload __init__(base_spec, /, *, perc_spec_round=False, comp_remain=None)

overload __init__(base_spec, perc_spec_range_rule, perc_spec_adjustment, /, *, perc_spec_round=False, comp_remain=None)

overload __init__(base_spec, perc_spec_adjustment, perc_spec_range_rule, /, *, perc_spec_round=False, comp_remain=None)

overload __init__(base_spec, perc_spec_range_rule, /, *, perc_spec_round=False, comp_remain=None)

overload __init__(base_spec, perc_spec_adjustment, /, *, perc_spec_round=False, comp_remain=None)

__init__(*args, **kwargs)

__int__() -> int

overload settings(/, *, perc_spec_round=False, comp_remain=...)

overload settings(base_spec, /, *, perc_spec_round=False, comp_remain=...)

overload settings(base_spec, perc_spec_range_rule, perc_spec_adjustment, /, *, perc_spec_round=False, comp_remain=...)

overload settings(base_spec, perc_spec_adjustment, perc_spec_range_rule, /, *, perc_spec_round=False, comp_remain=...)

overload settings(base_spec, perc_spec_range_rule, /, *, perc_spec_round=False, comp_remain=...)

overload settings(base_spec, perc_spec_adjustment, /, *, perc_spec_round=False, comp_remain=...)

settings(*args, **kwargs) -> None

Change the parameterization of the GeoCalculator.

Date: 23 Apr 2023
Version: 0.1
Author: Adrian Hoefflin [srccircumflex]
Doc-Generator: "pyiStructure-RSTGenerator" <prototype>
Clone this wiki locally