can you draw an elliptical arc? Pretty much just a section of an ellipse

Former Member
Former Member

the cd.drawArc only draws a part of a circle. Any way to draw a part of an ellipse?

  • Not directly.  You can draw an ellipse, and then hide a part by drawing something else over it.

  • Nice idea. With a bit of maths, you might be able to use dc.setClip() and then dc.drawEllipse() to do that.

  • Not sure a clip region would do much here, as that limits you to a rectangle Being able to use a polygon to obscure a part might be handy.

    I'd probably just stick with an arc and not bother with an ellipse.

  • Former Member
    0 Former Member over 5 years ago in reply to 9635560

    I've thought about it but setClip is a fairly new feature (v2.3) and I'd like my watchface to be able to run on my own watch, which runs v1.3

  • Former Member
    0 Former Member over 5 years ago in reply to jim_m_58

    I have made a watchface that has a round arc going around the edge to indicate the seconds. So far it only supports round and semi-round watches and I'd like for it to also support rectangular ones, which is why I thought of the eclipse.

  • I recally can't see  where clip regions buy you anything here.  Like the  multi-color font thing, you  can just use rectangles.  In this case, to obscure part of the eclipse, you may find that a line or a polygon would be a bit easier.

    That said, for rectangular devices, in some of mine I just use  arcs.   The ones you're looking  at are the Epix, va, vahr and fr920.  The epix, to be  honest, I won't really even  worry about for a few reasons.  The sim has a couple issues with that, and I really doubt many people use it.  It has pretty munch been dropped as of about 4 years ago.

    the vahr is an odd one, even though the screen is just the va screen turned on it's end, but it can be interesting to make things fit with a different font and orientation.  The 920 and va have definitely started to fade too and are 2-4 generations old.  

  • Jim, to explain the clip region;

    1. An ellipse segment is simply part of an ellipse. 

    2. Setting clip to have top as y-r2, bottom as centre y of ellipse, left as x-r1 and w to match ellipse r1*2 gives a perfect half ellipse. 

    3. Adjusting sideways (keeping y the same) can give any segment between a perfect half and a segment up to pi radians or 180 degrees. 

    4. Same logic applies to vertical. 

    You can’t get some arcs 3/4 ellipse, for example, but you can draw a large range of arcs. 

    Or you could... but the OP says they cannot use setClip as targeting older CIQ, so...

    A useful theoretical one for another project. 

  • You're missing that you can do the same thing with a rectangle and there's no need for a clip region.

    Clip regions are needed for 1hz, but most times, not needed.  (so older devices can be supported)

    Draw the full ellipse, and using other things like a circle/rectangle/line/polygon. overlay what you want hidden with the background color.  Some depends on where you want the arc to begin and end.

  • Agreed that it’s just an alternative route to the same end, but are you saying there’s a disadvantage to setClip and clearClip?

    They seem almost purpose built to do in a single line what would otherwise take several. 

    Eg:

    With clip to draw an elliptic arc from 1.1*pi to 1.9*pi:

    setClip, drawEllipse, clearClip

    With rect instead:

    drawEllipse, fillRect (lhs), fillRect (rhs), fillRect (base).

    Plus, with clip, I can do it in any order where with rect, I need to draw the arc first and overlay. 

    So is there an additional cost to clip?

  • The power of clip regions is really 1hz WFs.  You need to use them to stay under the 30ms power budget.  While they can be used for other things, as is seen here, aren't compatible with all devices.

    Using an example of something like an ellipse where you want to show the normal 5 segment move bar, you'll still have to overlay parts.