弧形笔划平滑度

时间:2018-01-11 12:24:25

标签: clojure processing clojurescript quil

我目前正在制作一个带有quil和Daniel Shiffman's video tutorial的时钟,但我在绘制arc时遇到的问题是弧线引起的冲击比line差。

Clock Image

我不知道问题是什么,或者我的代码错了或者创建了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)添加为this stackoverflow post,但它仍然相同。

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

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

左侧为网络,右侧为处理

更新

Sad Developer在github中创建一个问题,以关注the problem

Differences

1 个答案:

答案 0 :(得分:1)

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