[gsharp-cvs] CVS update: gsharp/packages.lisp gsharp/sdl.lisp

Robert Strandh rstrandh at common-lisp.net
Wed Jan 4 17:35:52 UTC 2006


Update of /project/gsharp/cvsroot/gsharp
In directory common-lisp.net:/tmp/cvs-serv4829

Modified Files:
	packages.lisp sdl.lisp 
Log Message:
Added new generic functions to the SDL package to deal with beam offsets
for a particular font. 

The plan is to modify the beam-drawing functions so that they use these
new generic functions, and so that they draw beams relative to the 
vertical reference point, just like other drawing functions.


Date: Wed Jan  4 18:35:51 2006
Author: rstrandh

Index: gsharp/packages.lisp
diff -u gsharp/packages.lisp:1.38 gsharp/packages.lisp:1.39
--- gsharp/packages.lisp:1.38	Tue Jan  3 04:10:14 2006
+++ gsharp/packages.lisp	Wed Jan  4 18:35:51 2006
@@ -33,6 +33,7 @@
 	   #:ledger-line-x-offsets #:ledger-line-y-offsets
 	   #:notehead-right-offsets #:notehead-left-offsets
 	   #:load-font #:glyph-offsets #:suspended-note-offset
+	   #:beam-offsets #:beam-hang-sit-offset
 	   #:+glyph-whole+ #:+glyph-whole-upper+ #:+glyph-whole-lower+ #:+glyph-whole-two+
 	   #:+glyph-half+ #:+glyph-half-upper+ #:+glyph-half-lower+ #:+glyph-half-two+
 	   #:+glyph-filled+ #:+glyph-filled-upper+ #:+glyph-filled-lower+ #:+glyph-filled-two+


Index: gsharp/sdl.lisp
diff -u gsharp/sdl.lisp:1.12 gsharp/sdl.lisp:1.13
--- gsharp/sdl.lisp:1.12	Tue Nov 15 19:49:52 2005
+++ gsharp/sdl.lisp	Wed Jan  4 18:35:51 2006
@@ -22,6 +22,15 @@
 (defgeneric suspended-note-offset (font)
   (:documentation "the x offset of a suspended note compared to that
 of a normal note.  This function always returns a positive value"))
+(defgeneric beam-offsets (font)
+  (:documentation "return two values, both to be added to the 
+		   vertical reference point in order to obtain the 
+		   bottom and top of the beam (in that order)"))
+(defgeneric beam-hang-sit-offset (font)
+  (:documentation "return a positive value to be added to (hang) or 
+		   subtracted from (sit) the vertical reference point
+		   of a staff line, in order to obtain the reference 
+		   point of a hanging or sitting beam respectively"))
 
 (defclass font ()
   ((gf-font :initarg :gf-font :reader gf-font)
@@ -40,6 +49,9 @@
    (notehead-right-y-offset)
    (notehead-left-x-offset)
    (notehead-left-y-offset)
+   (beam-offset-down)
+   (beam-offset-up)
+   (beam-hang-sit-offset :reader beam-hang-sit-offset)
    (glyphs :initarg :glyphs :reader glyphs)))
   
 (defmethod initialize-instance :after ((font font) &rest initargs &key &allow-other-keys)
@@ -58,7 +70,10 @@
 	       notehead-right-x-offset
 	       notehead-right-y-offset
 	       notehead-left-x-offset
-	       notehead-left-y-offset) font
+	       notehead-left-y-offset
+               beam-offset-down
+	       beam-offset-up
+	       beam-hang-sit-offset) font
     (let ((staff-line-thickness (round (/ (staff-line-distance font) 10))))
       (setf staff-line-offset-down
 	    (floor (/ staff-line-thickness 2))
@@ -94,7 +109,13 @@
       (setf notehead-right-y-offset
 	    (round (+ (* 0.25 staff-line-distance) yoffset)))
       (setf notehead-left-y-offset
-	    (- (round (- (* 0.25 staff-line-distance) yoffset)))))))
+	    (- (round (- (* 0.25 staff-line-distance) yoffset))))
+      (setf beam-offset-down
+	    (floor (/ staff-line-distance 2) 2))
+      (setf beam-offset-up
+	    (- (ceiling (/ staff-line-distance 2) 2)))
+      (setf beam-hang-sit-offset
+	    (/ (- (+ beam-offset-down beam-offset-up) staff-line-thickness) 2)))))
 
 (defgeneric gf-char (glyph))
 (defgeneric pixmap (glyph))
@@ -185,6 +206,10 @@
 (defmethod suspended-note-offset ((font font))
   (with-slots (notehead-left-x-offset notehead-right-x-offset) font
     (- notehead-right-x-offset notehead-left-x-offset)))
+
+(defmethod beam-offsets ((font font))
+  (with-slots (beam-offset-down beam-offset-up) font
+    (values beam-offset-down beam-offset-up)))
 
 (defun load-font (staff-line-distance)
   (let* ((gf-font (parse-gf-file (merge-pathnames




More information about the Gsharp-cvs mailing list