Hi all,
I'm going to write a generic bow-stencil.
Below you'll find a boiled down example.
The main problem: how to determine the correct extents.
Looks like I need to calculate the actual X/Y-extents of the resulting
bezier-curve.
Though, obviously my maths-skills are not sufficient.
Any hints?
\version "2.18.2"
%% `overlay' is in the source for 2.19.28
%% for lower versions use:
#(define-markup-command (overlay layout props args) (markup-list?)
(apply ly:stencil-add (interpret-markup-list layout props args)))
#(define (make-simple-bezier-stencil coords)
(let* ((command-list `(moveto
,(car (list-ref coords 3))
,(cdr (list-ref coords 3))
curveto
,(car (list-ref coords 0))
,(cdr (list-ref coords 0))
,(car (list-ref coords 1))
,(cdr (list-ref coords 1))
,(car (list-ref coords 2))
,(cdr (list-ref coords 2))
)))
(ly:make-stencil
`(path 0.1 `(,@' ,command-list) 'round 'round #f)
;;;; TODO
;;;; How to get correct extents?
;; xext:
(cons
(car (list-ref coords 2))
(car (list-ref coords 3)))
;;yext:
(cons
(cdr (list-ref coords 2))
(cdr (list-ref coords 1)))
)))
%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%
#(define pts-list
'((12 . 8)
(5 . 8)
(2 . 2)
(15 . 2)))
#(define (rotated-pts-list degree)
(map
(lambda (c)
;;;; TODO
;; coord-rotate rotates around '(0 . 0)
;; make it generic
(coord-rotate c (degrees->radians degree)))
pts-list))
\markup
\column {
\vspace #3
\fill-line {
\overlay {
\circle \null %% representing point '(0 . 0)
\override #'(box-padding . 0)
\box \with-color #red {
\stencil
#(make-simple-bezier-stencil pts-list)
\stencil
#(make-simple-bezier-stencil (rotated-pts-list 90))
\stencil
#(make-simple-bezier-stencil (rotated-pts-list 60))
}
}
}
}
Cheers,
Harm
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user