Skip to content

Instantly share code, notes, and snippets.

@honix
Created June 9, 2016 19:30
Show Gist options
  • Save honix/e94f42eb24e62a2ade8cbb45ab8b9df1 to your computer and use it in GitHub Desktop.
Save honix/e94f42eb24e62a2ade8cbb45ab8b9df1 to your computer and use it in GitHub Desktop.
Playing with Sketch
(ql:quickload :sketch)
(in-package :sketch)
(defstruct point
(x 0.0 :type short-float)
(y 0.0 :type short-float))
(defparameter *pen* (make-pen :fill +black+
:stroke +black+
:weight 5))
(defun angle-vector (angle mag)
(make-point :x (* (cos angle) mag)
:y (* (sin angle) mag)))
(defun point+ (a b)
(make-point :x (+ (point-x a) (point-x b))
:y (+ (point-y a) (point-y b))))
(defun line-cur (start angle mag)
(declare (short-float angle mag))
(when (> mag 27)
(let* ((p1x (point-x start))
(p1y (point-y start))
(dir (angle-vector angle mag))
(next (point+ start dir))
(p2x (point-x next))
(p2y (point-y next)))
(line p1x p1y p2x p2y)
(line-cur next (+ angle (/ 10 mag)) (* mag 0.99)))))
(defsketch recur1 ((time 0.0))
(incf time 0.01)
(with-pen *pen*
(dotimes (i 6)
(line-cur (make-point :x 200.0
:y 200.0)
(- i (/ time 2))
(* (+ (* (sin time) 0.6) 2.5) 15.0)))))
(make-instance 'recur1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment