Skip to content
Browse files

Bug fixes

  • Loading branch information...
1 parent a40ce74 commit de84217b6efe75c928c3fe58a6e0c15a2a4180fb @vydd committed
Showing with 36 additions and 26 deletions.
  1. +1 −1 sketch.asd
  2. +4 −4 src/color.lisp
  3. +1 −0 src/environment.lisp
  4. +2 −1 src/figures.lisp
  5. +4 −1 src/package.lisp
  6. +24 −19 src/sketch.lisp
View
2 sketch.asd
@@ -28,8 +28,8 @@
(:file "drawing")
(:file "shapes")
(:file "transforms")
- (:file "figures")
(:file "resources")
(:file "color")
(:file "sketch")
+ (:file "figures")
(:file "controllers")))
View
8 src/color.lisp
@@ -167,10 +167,10 @@
(color-blue color)
(color-red color)))
-(defun color-filter-lighten (color &optional (amount 0.1))
- (let ((hue (color-hue color))
- (saturation (color-saturation color))
- (brightness (clamp-1 (+ amount (color-brightness color))))
+(defun color-filter-hsb (color &key (hue 0.0) (saturation 0.0) (brightness 0.0))
+ (let ((hue (clamp-1 (+ hue (color-hue color))))
+ (saturation (clamp-1 (+ saturation (color-brightness color))))
+ (brightness (clamp-1 (+ brightness (color-brightness color))))
(alpha (color-alpha color)))
(destructuring-bind (red green blue) (hsb-to-rgb hue saturation brightness)
(make-instance 'color
View
1 src/environment.lisp
@@ -71,6 +71,7 @@
(gl:enable :blend :line-smooth :polygon-smooth)
(gl:blend-func :src-alpha :one-minus-src-alpha)
(gl:hint :line-smooth-hint :nicest)
+ (gl:hint :polygon-smooth-hint :nicest)
(gl:clear-color 0.0 1.0 0.0 1.0)
(gl:clear :color-buffer :depth-buffer)
(gl:flush)))
View
3 src/figures.lisp
@@ -37,7 +37,8 @@
`(let ((*draw-sequence* nil))
(let ((*env* (make-env))
(*draw-mode* :figure))
- ,@body)
+ (with-pen (make-default-pen)
+ ,@body))
(setf *draw-sequence* (nreverse *draw-sequence*))
(let ((figure (make-instance 'figure :draws *draw-sequence*)))
(defun ,name (x y)
View
5 src/package.lisp
@@ -38,6 +38,9 @@
:radians
:degrees
+ ;; Utils
+ :relative-path
+
;; Colors
:color
:make-color
@@ -68,7 +71,7 @@
:color-filter-grayscale
:color-filter-invert
:color-filter-rotate
- :color-filter-lighten
+ :color-filter-hsb
:+red+
:+green+
:+blue+
View
43 src/sketch.lisp
@@ -62,8 +62,9 @@ used for drawing.")
(progn
(background ,error-color)
(with-font (make-default-font)
- (text "ERROR" 20 20)
- (text "For restarts, press the debug key." 20 40))
+ (with-identity-matrix
+ (text "ERROR" 20 20)
+ (text "For restarts, press the debug key." 20 40)))
(setf restart-sketch t
(env-red-screen *env*) t)))))
@@ -77,23 +78,24 @@ used for drawing.")
(with-environment env
(with-pen (make-default-pen)
(with-font (make-default-font)
- (unless copy-pixels
- (background (gray 0.4)))
- ;; Restart sketch on setup and when recovering from an error.
- (when restart-sketch
- (gl-catch (rgb 1 1 0)
- (setup sketch-window))
- (setf (slot-value sketch-window 'restart-sketch) nil))
- ;; If we're in the debug mode, we exit from it immediately,
- ;; so that the restarts are shown only once. Afterwards, we
- ;; continue presenting the user with the red screen, waiting for
- ;; the error to be fixed, or for the debug key to be pressed again.
- (if (debug-mode-p)
- (progn
- (exit-debug-mode)
- (draw-window sketch-window))
- (gl-catch (rgb 1 0 0)
- (draw-window sketch-window)))))))
+ (with-identity-matrix
+ (unless copy-pixels
+ (background (gray 0.4)))
+ ;; Restart sketch on setup and when recovering from an error.
+ (when restart-sketch
+ (gl-catch (rgb 1 1 0)
+ (setup sketch-window))
+ (setf (slot-value sketch-window 'restart-sketch) nil))
+ ;; If we're in the debug mode, we exit from it immediately,
+ ;; so that the restarts are shown only once. Afterwards, we
+ ;; continue presenting the user with the red screen, waiting for
+ ;; the error to be fixed, or for the debug key to be pressed again.
+ (if (debug-mode-p)
+ (progn
+ (exit-debug-mode)
+ (draw-window sketch-window))
+ (gl-catch (rgb 1 0 0)
+ (draw-window sketch-window))))))))
(handle-sketch-event sketch-window :frame-draw))
;;; Macros
@@ -151,6 +153,9 @@ all slot names."
(with-slots ,(gethash sketch-name *sketch-slot-hash-table*) sketch-window
,@body))
+ (defmethod setup :before ((sketch-window ,sketch-name))
+ (background (gray 0.4)))
+
(defmethod initialize-instance :after ((sketch-window ,sketch-name)
&key &allow-other-keys)
(let ((sdl-win (kit.sdl2:sdl-window sketch-window)))

0 comments on commit de84217

Please sign in to comment.
Something went wrong with that request. Please try again.