Skip to content

Instantly share code, notes, and snippets.

@scymtym
Created July 22, 2019 18:32
Show Gist options
  • Save scymtym/3dafd1166b0b2e7d1338b2c314718e64 to your computer and use it in GitHub Desktop.
Save scymtym/3dafd1166b0b2e7d1338b2c314718e64 to your computer and use it in GitHub Desktop.
Array Visualization
(cl:in-package #:clouseau)
(defmethod inspect-object-using-state ((object array)
(state inspected-array)
(style (eql :expanded-body))
(stream t))
(destructuring-bind (height width) (array-dimensions object)
(loop :for y :from 0 :below height
:do (loop :for x :from 0 :below width
:do (draw-rectangle* stream (* 10 x) (* 10 y) (* 10 (1+ x)) (* 10 (1+ y))
:ink (make-rgb-color (+ (aref object y x) .5) 0 0))
(draw-rectangle* stream (* 10 x) (* 10 y) (* 10 (1+ x)) (* 10 (1+ y))
:ink +white+ :filled nil)))))
(cl:in-package #:cl-user)
;; init
(defvar *inspector*
(nth-value 1 (clouseau:inspect (make-array '(10 10)) :new-process t) ))
;; update
(setf (clouseau:root-object *inspector* :run-hook-p t) (make-array '(10 10) :initial-element .1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment