Sketching: Flying Lines

flying-lines

#lang sketching
; Line segments with start and end points on a Lissajous curve.

(define fr 30) ; frame rate

(define A 1)
(define B 1)
(define a 3.)        ; experiment with different 
(define b 2.)        ; values for a, b and δ
(define δ (* 0.5 π))  
  
(define (lissajous t)
  (define x (* A (sin (+ (* a t) δ))))
  (define y (* B (sin    (* b t))))
  (vector x y))

(define (setup)
  (size 600 600)
  (:= A (* 0.5 width))
  (:= B (* 0.5 height))
  ; fill and text color
  (fill "black")
  ; color mode
  (color-mode 'hsb 100) ; hsb = hue, saturation, brightness
  ; our expected frame rate (actual might be lower)
  (frame-rate fr))
  
(define (draw)
  (background "white")
  ; Put (0,0) in the middle
  (translate (* 0.5 width) (* 0.5 height))
  ; Time
  (define t frame-count)
  ; We are going to draw n line segments.
  (define n 20)
  ; A line segments begins at P and ends at Q.
  (define P (for/vector ([i n]) (lissajous (/ (+ t i  0.) fr))))
  (define Q (for/vector ([i n]) (lissajous (/ (+ t i 20.) fr))))
  (for ([i n])
    (define Pi P[i])
    (define Qi Q[i])
    (stroke (+ (* 2 t)   ; time shifts the hue
               (* 5 i))  ; each line get its own hue
            50 80)
    (stroke-weight 2)
    (line Pi[0] Pi[1]  Qi[0] Qi[1])))
4 Likes

I think you need to submit this as your entry!

1 Like

Very nice.

Where can I find #lang sketching ?

Jos

2 Likes

Hi @joskoot

More information about sketching can be found at the repo

https://github.com/soegaard/sketching

best

Stephen

The reference is here:
2 Reference

Thank you for letting me use noise. The noise functions are available as noise and simplex-noise.
I see that I forgot to add them to the documentation.

Can I persuade you to comment on this issue?

It will it easier to add you to the list of contributors.