Skip to content

Qi in the Wild

Siddhartha Kasivajhula edited this page Feb 6, 2025 · 1 revision

Weird, cool, and clever uses of Qi in the wild.

Thinking Outside the Box (by @TrueQueenBee)

(require qi)
(~> ((box #f)) (-< _ _) (effect set-box!) 1> (feedback 1000000 unbox))

The gift that keeps on giving?

Know Thyself (by @jagen31)

#lang racket

(require qi 2htdp/image)

(define OUTER-RADIUS 120)
(define INNER-RADIUS 105)
(define-values (EYE-WIDTH EYE-HEIGHT EYE-X-OFF) (values 25 25 40))

(define PRIMARY 'cornflowerblue)
(define ACCENT 'white)
(define (PEN color) (pen color 13 "solid" "round" "bevel"))

(~> [PRIMARY ACCENT]
    (-<
     (~>
      (-< (~> (select 1 2) ▽) (~> (select 2 1) ▽)) ; duality
      (-< (>< 
           (-<
            (~> △
                (-< (gen (curry wedge INNER-RADIUS 180 'solid)) _)
                (-< (~> (block 2) apply (scale 1/2 _)) (~> (block 3) apply) 2> 3>) ; 2 circles
                (-< 3> 4> (~> (select 1 2) (overlay/align 'left 'bottom _ _))) ; compose
                (-< (gen EYE-WIDTH EYE-HEIGHT) _)
                (-< 5>
                    (~> (block 4 5) (== _ + (PEN _)) line) (gen (- EYE-X-OFF))
                    (~> (block 3 5) (== _ - (PEN _)) line) (gen (+ (* -2 INNER-RADIUS) EYE-X-OFF EYE-WIDTH)))
                (-< (~> 1> (as image)) (~> (select 2 3) ▽) (~> (select 4 5) ▽)) ; eyes with x positions
                (<< (~> (== △ _) (-< (gen 'left 'bottom) 1> 2> (gen 0) 3>) overlay/align/offset) ; teeny fold
                    ;; FIXME jagen trouble with the init arg- why cant it receive the inputs?
                    (esc (λ () image)))))))))
    ;; the punchline
    (== _ (rotate 180 _)) above
    (overlay _ (circle OUTER-RADIUS 'solid PRIMARY)))

So Near, Yet So Far (by @damien-mattei)

This plots the trajectory of BepiColombo as it flies by Mercury, one of several flybys spanning years until it finally settles into Mercury orbit in 2026. It uses a dataset that isn't included here, but you can see the output in the original Discourse thread. It also uses a modified form of SRFI 105's curly infix syntax.

#lang reader SRFI-105

{Lplot := (src) ~> read-lines ~> list->vector ~> _[5 :] ~> vector->list ~> (△ (string-split ~> rest ~> (△ string->number) ~> vector)) ~> ▽}
Clone this wiki locally