Skip to content

Compass.md

cfloutier edited this page Apr 27, 2024 · 12 revisions

K2Compass

The Compass is used to gives and set the heading direction

image

Attributes

  • value : float angle. the heading value in degrees [0-360]

  • angle-range : float angle, default is 90°. the visible angle range. We see from center andle +/- angle-range ex : with 200° : image it could be useful for larger windows

  • interactive : boolean. if true the user can drag the compass to choose the direction.

uss classes

  • the buttons uses the ..k2compas class. The whole list of subclasses are located into K2Compas.uss

you can change the lines rendering using this set of privates options :

    --center-line-width: 1;
    --center-line-color: rgb(255, 255, 255);
    --line-width: 2;
    --line-color-1: rgb(145, 145, 145);
    --line-color-2: rgb(104, 104, 104);
    --line-color-3: rgb(46, 46, 46);
    --line-y1: 30;
    --line-y5: 25;
    --line-y10: 20;
    --line-y45: 25;

The "center line" is the control center There are 3 levels of lines : 1°, 5°, 10° and 45°. The y value is compued from the bottom of the control.

others uss classes are used for inner labels and main control frame

Binding

Binding

It can be bound with a Setting<float> or ClampSetting<float>

ex :

   public ClampSetting<float> heading = new ClampSetting<float>("my_settings.heading ", 90, 0, 360);

   public void init(VisualElement panel)
   {
        panel.Q<K2Compas>("compas").Bind(heading );
   }

Clone this wiki locally