Skip to content

Instantly share code, notes, and snippets.

@fouric
Last active August 28, 2019 18:41
Show Gist options
  • Save fouric/c01f28d327705f51d97651b133c0e961 to your computer and use it in GitHub Desktop.
Save fouric/c01f28d327705f51d97651b133c0e961 to your computer and use it in GitHub Desktop.
what if we had a graphical print function?
(defclass graph ()
((num :initarg :num :accessor num)))
(defmethod print-object ((object graph) stream)
(sdl2:with-init (:everything)
(sdl2:with-window (win :title "graphical print test" :flags '(:shown))
(sdl2:with-renderer (renderer win :flags '())
(sdl2:with-event-loop (:method :poll)
(:keydown (:keysym keysym)
(when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape)
(sdl2:push-event :quit)))
(:idle ()
(sdl2:set-render-draw-color renderer 200 0 200 255)
(sdl2:render-clear renderer)
(sdl2:render-present renderer))
(:quit ()
t)))))
(format nil "#<GRAPH :NUM ~a>" (num object)))
@fouric
Copy link
Author

fouric commented Aug 28, 2019

...this obviously doesn't actually do anything right now, of course - i just wanted to see if it was viable for use in the print-object method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment