Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Arcs not drawn correctly when start angle less than end angle

オープン
#960 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
c, numpy, python

調査の方向性

enable.gcbench.suite の再現を実行し、特に π/2 と 0 を使い、clockwise の両方の設定で行う gc.arc 呼び出しを実行して、issue に示されている Agg と Quartz の出力を比較する。まず、意図された角度と winding のセマンティクスを確認する。これらのケースで選択した動作に一貫性があり、説明されている不連続性や誤った clockwise の結果を導入しなければ完了とする。

索引モデルが issue の本文から書いたものです。

説明

Observed behaviour

Drawing from π/2 to 0 (it might be arguable that Agg is correct here):
Agg
image

Quartz
image

Drawing from π/2 to 0 with clockwise True (Agg is clearly not right, Quartz is at least consistent):
Agg
image

Quartz
image

To reproduce

Add these to enable.gcbench.suite and run:

class draw_arc_backwards:
    def __init__(self, gc, module):
        self.gc = gc
    
    def __call__(self):
        with self.gc:
            self.gc.begin_path()
            self.gc.arc(100.0, 100.0, 30.0, np.pi / 2, 0.0)
            self.gc.set_fill_color((0.33, 0.66, 0.99, 1.0))
            self.gc.fill_path()


class draw_arc_backwards_clockwise:
    def __init__(self, gc, module):
        self.gc = gc
    
    def __call__(self):
        with self.gc:
            self.gc.begin_path()
            self.gc.arc(100.0, 100.0, 30.0, np.pi / 2, 0.0, True)
            self.gc.set_fill_color((0.33, 0.66, 0.99, 1.0))
            self.gc.fill_path()

Expected behaviour

Not entirely sure.

Quartz is consistent, but has a significant discontinuity when the end angle sweeps over start angle, which may be problematic for plotting sectors and arcs (need to adjust cw flag appropriately when drawing). Agg avoids this, but the result when drawing "clockwise" doesn't make any sense at all. I suspect that the way that Quartz does it will be similar in other 2D libraries, since the Quartz call is a straight-through call to the underlying CoreGraphics routines.

A different possible interpretation is that an arc from one angle to another should be the path swept out between the angles, including windings (with associated effects on EOF vs. winding number fill, so 0 to 4π would be EOF empty), but then the purpose of the cw flag is unclear (one interpretation would be that it means angles are treated as clockwise from the x-axis).

In the end, I would be happy with being consistent with Quartz or HTML Canvas behaviour.

Whatever fix is put in place, it may impact rendering in downstream libraries.

主要言語
C
スター
97
フォーク
45
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

enthought/enable のほかの issue

enthought/enable の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。