soegaard / sketching

A Racket library for creative drawings and animations. Inspired by Processing.
110 stars 10 forks source link

rough lines in loops #82

Closed ericcervin closed 2 years ago

ericcervin commented 2 years ago

Working on another simple example when I noticed roughness in some lines that were drawn. The lines are perfectly smooth when they aren't being looped.

(define (setup)
  (size 240 120)
  (smoothing 'smoothed)
  (background 200)
  (set-frame-rate! 60)
  (stroke-weight 30)
  )

(define (draw)
 (stroke 102)
 (line 40 0 70 height)
 (if mouse-pressed (stroke 0) (stroke 102))
 (line 0 70 width 50)
)

image

ericcervin commented 2 years ago

image

ericcervin commented 2 years ago

the java I'm working from

image

soegaard commented 2 years ago

Hi Eric.

I can confirm the error.

I'll investigate the issue further.

Thanks for the precise example.

/Jens Axel

soegaard commented 2 years ago

Hi Eric,

I have investigated the issue. In the draw-line function I inserted lines that print the smooting settings and the background color. They are the same for the first frame and the following frames.

Now if I move the call (background 200) from setup to the beginning of draw then I see smooth lines. And now I notice your Processing example also has (background 200) in draw :-)

The background command not only sets the background color, it also clears the screen. So it sort of makes sense that drawing a line on a blank background and on top of an existing line doesn't give the same result.

What happens if you move the background call from draw to setup in the Processing example?

/Jens Axel

ericcervin commented 2 years ago

[sad trombone]

Thanks.

I mean to go get my eyes checked. Haven't been to the eye doctor since before covid.

soegaard commented 2 years ago

It fooled me too. :-)