3

我目前正在用 quil 和Daniel Shiffman 的视频教程制作时钟,但我在绘制arc弧线时画得比line.

时钟图像

我不知道问题出在哪里,或者我的代码有问题,或者要创建一个arc,所以,这是我的代码。

(defn draw-state [state]
  ; Clear the sketch by filling it with light-grey color.
  (q/background 150)

  (let [max-scale-h (- 1 (/ 1 12))
        max-scale-m (- 1 (/ 1 60))
        max-scale-s (- 1 (/ 1 60))]
    (let
      [
        h (q/map-range
           (if (> (q/hour) 12) (- (q/hour) 12) (q/hour)) 0 11 0 max-scale-h)
        m (q/map-range (q/minute) 0 59 0 max-scale-m)
        s (q/map-range (q/seconds) 0 59 0 max-scale-s)

        half-width (/ (q/width) 2)
        half-height (/ (q/height) 2)
        ]

      ;; let body
      (q/translate half-width half-height)
      (q/rotate (* -1 q/HALF-PI))

      (q/stroke-weight 8)
      (q/no-fill)

      (let [angle (* q/TWO-PI h)]
        (q/stroke 255 100 150)
        (q/arc 0 0 300 300 0 angle)

        (q/push-style)
        (q/rotate angle)
        (q/line 0 0 60 0)
        (q/pop-style))

      (let [angle (* q/TWO-PI m)]
        (q/stroke 150 100 255)
        (q/arc 0 0 280 280 0 angle)

        (q/push-style)
        (q/rotate angle)
        (q/line 0 0 70 0)
        (q/pop-style))

      (let [angle (* q/TWO-PI s)]
        (q/stroke 150 255 100)
        (q/arc 0 0 260 260 0 angle)

        (q/push-style)
        (q/rotate angle)
        (q/line 0 0 128 0)
        (q/pop-style)
        ))))

更新

(q/smooth)在设置中添加了这个 stackoverflow 帖子,但它仍然相同。

(defn setup []
  (q/smooth)
  (q/frame-rate 30)
  (q/color-mode :rgb)
  )

更新 我尝试使用平滑,processing它可以工作,但网络版本没有变化。

左侧用于网络,右侧用于处理

更新

Sad Developer在github中创建一个问题以跟踪问题

差异

4

1 回答 1

2

升级到 quil 3.0.0 将解决此问题。Quil 现在使用 p5js 而不是 processing.js,它没有锯齿线的问题。见http://quil.info/sketches/show/snippet_arc

于 2019-04-07T09:43:11.057 回答