# Rotary that has central position and draws arc to the left or right of center

**URL:** <https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819>\
**Category:** General JUCE discussion\
**Created:** [November 1, 2015, 9:58pm UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819 "2015-11-01T21:58:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [November 1, 2015, 9:58pm UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/1 "2015-11-01T21:58:50Z")

</div>

Hi, is there a standard version of this kind of rotary or do I need to draw this myself?

thx

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [November 1, 2015, 10:22pm UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/2 "2015-11-01T22:22:27Z")

</div>

Just derive a class from Slider and override getValue()

Rail

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [November 2, 2015, 7:46am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/3 "2015-11-02T07:46:32Z")

</div>

Hi, this is more a drawing thing than a value issue. Encoders with a center value draw from the center outwards in both directions...

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [November 2, 2015, 8:18am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/4 "2015-11-02T08:18:00Z")

</div>

You set the min and max values… say 0 through 100 and make 50 your center value… in getValue you calculate the value based on the your min and max and the position of the fader.

If you want a different look then you can use a LookAndFeel to draw the changes (see drawRotarySlider) or use Knobman to create other options.

[http://www.g200kg.com/en/software/knobman.html](http://www.g200kg.com/en/software/knobman.html)

Rail

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [November 2, 2015, 2:00pm UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/5 "2015-11-02T14:00:14Z")

</div>

Hi, I understand that. I think I know the answer, just I'm not being clear.

See attached file. The center value here is 64 and the knob is shown at 45. It is drawing from the center of the dial, not from the start of the arc. I wondered if there was any default setting to enable knobs to draw like this or whether I need to draw them myself, and I think it's the latter...

https://www.dropbox.com/s/no7ayl4w3dk3lj8/tune-1.jpg?dl=0

https://www.dropbox.com/s/ihl1lujjulvrjpy/tune-2.jpg?dl=0

&nbsp;

cheers

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [November 3, 2015, 9:31am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/6 "2015-11-03T09:31:06Z")

</div>

So you are actually missing tickmarks if I understand that right. I didn't see there any, but I would love the possibility to add default tickmarks (and for your case to emphasize the center position e.g.).

It's probably left to do in our own Look and Feel classes. But I'm happy if somebody corrects me :-)

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [November 3, 2015, 10:42am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/7 "2015-11-03T10:42:01Z")

</div>

He needs to create his own LookAndFeel derived from LookAndFeel\_V2 and override drawRotarySlider and duplicate the LookAndFeel\_V2:: drawRotarySlider() code and replace the code where it creates the filledArc Path…

```auto
            Path filledArc;
            filledArc.addPieSegment (rx, ry, rw, rw, rotaryStartAngle, angle, thickness);
            g.fillPath (filledArc);
```

Of course, it may be just as easy to use a Knobman LookAndFeel and have your own custom knob.

Rail

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [November 3, 2015, 11:24am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/8 "2015-11-03T11:24:59Z")

</div>

...yes I got that. But looking at the OP's images, I guess he wants rather the tickmarks than different knobs.

I was proposing, if one could enhance the standard look and feel so you can simply say

```
Slider::setTickmarksEnabled( bool showTickmarks );
```

And have the default Slider class (respectively the default LookAndFeel classes) paint tickmarks according to Slider::getMaximum(), getMinimum(), getInterval() and last but not least getSkewFactor().

Up to now I simply left tickmarks aside, but often wished to show some in one line of code. I just thought the OP and I are not the only ones who wish simple default tickmarks...

---

<div class="post-metadata">

**Author:** ![leehu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/leehu/32/3280_2.png) [@leehu](https://forum.juce.com/u/leehu)\
**Post date:** [November 3, 2015, 11:46am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/9 "2015-11-03T11:46:18Z")

</div>

Hi guys.. thanks for the replies - I was referring to the drawing, not the tickmarks, but they're good as well...

Will check out the knobman stuff, but I think I have my answer, which is, these options are not provided by default which is what I was after...

&nbsp;

thanks again!

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [November 3, 2015, 11:59am UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/10 "2015-11-03T11:59:37Z")

</div>

ok, sorry for confusing...

---

<div class="post-metadata">

**Author:** ![MattChowski](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MattChowski](https://forum.juce.com/u/MattChowski)\
**Post date:** [February 18, 2019, 6:48pm UTC](https://forum.juce.com/t/rotary-that-has-central-position-and-draws-arc-to-the-left-or-right-of-center/15819/11 "2019-02-18T18:48:09Z")

</div>

If anyone is looking for this still (like I did), I managed to get it working by simply starting the draw from 0 to the end angle which the default number from 0 is “2.51327” here is how the code looks like in my case to make it work like intended by OP:

```
//draw the value arcs
        if (slider.isEnabled() && slider.getValue() > 0) {
            Path valueArc;
            valueArc.addCentredArc(centerX, centerY, knobRadius, knobRadius, 0.0f, 0, map(sliderPos, 0.5, 1.0, 0, 2.51327), true);
            std::cout << sliderPos << std::endl;
            g.setColour(valueFill);
            g.strokePath(valueArc, PathStrokeType(lineThickness));
        } else if (slider.isEnabled() && slider.getValue() < 0) {
            Path valueArc2;
            valueArc2.addCentredArc(centerX, centerY, knobRadius, knobRadius, 0.0f, 0, map(sliderPos, 0.5, 0.0, 0, -2.51327), true);
            std::cout << sliderPos << std::endl;
            g.setColour(valueFill);
            g.strokePath(valueArc2, PathStrokeType(lineThickness));
        }

```

Pay attention to this:

`valueArc.addCentredArc(centerX, centerY, knobRadius, knobRadius, 0.0f, 0, map(sliderPos, 0.5, 1.0, 0, 2.51327), true);`

this draws from centre to the right, whereas this:

`valueArc2.addCentredArc(centerX, centerY, knobRadius, knobRadius, 0.0f, 0, map(sliderPos, 0.5, 0.0, 0, -2.51327), true);`

draws from centre to left. It only has inverted end angle, just put a minus before it.

Hope this helps people!
