App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/lib/SVGPDF/Contrib/Bogen.pm view on Meta::CPAN
343536373839404142434445464748495051525354drew a segment (arc) of a circle, which was adapted here by Phil Perry to draw
an elliptical arc.
(German
for
I<bow>, as in a segment (arc) of an ellipse), this is a
segment of an ellipse
defined
by the intersection of two ellipses of
given
x
and y radii,
with
the two intersection points as inputs. There are four
possible resulting arcs, which can be selected
with
opts C<large> and C<dir>.
This
extends
the path along an arc of an ellipse of the specified x and y radii
between C<[
$x1
,
$y1
]> to C<[
$x2
,
$y2
]>. The current position is then set
to the endpoint of the arc (C<[
$x2
,
$y2
]>).
Options (C<
@opts
>)
=over
=item 'move' => move_flag
Set C<move> to a I<true> value if this arc is the beginning of a new
path instead of the continuation of an existing path. Note that the default
(C<move> => I<false>) is
lib/ChordPro/lib/SVGPDF/Contrib/Bogen.pm view on Meta::CPAN
338339340341342343344345346347348349350351352353354355356357358
shift
@points
;
}
return
$self
;
}
# input: x and y axis radii
# sweep start and end angles (degrees)
# sweep direction (0=CCW (default), or 1=CW)
# axis rotation (radians, + = CCW, default = 0)
# output: two endpoints and two control points for
# the Bezier curve describing the arc
# maximum 30 degrees of sweep: is broken up into smaller
# arc segments if necessary
# if crosses 0 degree angle in either sweep direction, split there at 0
# if alpha=beta (0 degree sweep) or either radius <= 0, fatal error
sub
_arctocurve {
my
(
$rx
,
$ry
,
$alpha
,
$beta
,
$dir
,
$rot
) =
@_
;
if
(!
defined
$rot
) {
$rot
= 0; }
# default is no rotation
if
(!
defined
$dir
) {
$dir
= 0; }
# default is CCW sweep
lib/ChordPro/lib/SVGPDF/Contrib/Bogen.pm view on Meta::CPAN
449450451452453454455456457458459460461462463464465466467468469=item $content->bogen($x1,$y1, $x2,$y2, $radius)
(I<bogen> is German for I<bow>, as in a segment (arc) of a circle. This is a
segment of a circle defined by the intersection of two circles of a given
radius, with the two intersection points as inputs. There are B<four> possible
resulting arcs, which can be selected with C<$larger> and C<$reverse>.)
This extends the path along an arc of a circle of the specified radius
between C<[$x1,$y1]> to C<[$x2,$y2]>. The current position is then set
to the endpoint of the arc (C<[$x2,$y2]>).
Set C<$move> to a I<true> value if this arc is the beginning of a new
path instead of the continuation of an existing path. Note that the default
(C<$move> = I<false>) is
I<not> a straight line to I<P1> and then the arc, but a blending into the curve
from the current point. It will often I<not> pass through I<P1>!
Set C<$larger> to a I<true> value to draw the larger ("outer") arc between the
two points, instead of the smaller one. Both arcs are drawn I<clockwise> from
I<P1> to I<P2>. The default value of I<false> draws the smaller arc.
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
463946404641464246434644464546464647464846494650465146524653465446554656465746584659
ty += dir > 0 ?
'+'
:
'-'
// type = .+ or .-
var savout = output
output =
""
draw_slur(path, sl, 1 /
*true
*/)
gene.a_sl.
push
([k1, s_st2, ty, output])
output = savout
return
}
/* fix endpoints */
x1 = k1.x
if
(k1.notes && k1.notes[0].shhd)
x1 += k1.notes[0].shhd;
x2 = k2.x
if
(k2.notes)
x2 += k2.notes[0].shhd
if
(not1) { // start on a note
y1 = 3 * (not1.pit - 18) + 2 * dir
x1 += 3
lib/ChordPro/res/abc/abc2svg/abc2svg-1.js view on Meta::CPAN
478647874788478947904791479247934794479547964797479847994800480148024803480448054806a = (y2 - y1) / (x2 - x1) /* slur steepness */
if
(a > SLUR_SLOPE || a < -SLUR_SLOPE) {
a = a > SLUR_SLOPE ? SLUR_SLOPE : -SLUR_SLOPE
if
(a * dir > 0)
y1 = y2 - a * (x2 - x1)
else
y2 = y1 + a * (x2 - x1)
}
/*
for
big vertical jump,
shift
endpoints */
y = y2 - y1
if
(y > 8)
y = 8
else
if
(y < -8)
y = -8
z = y
if
(z < 0)
z = -z;
dx = .5 * z;
dy = .3 * y
( run in 0.814 second using v1.01-cache-2.11-cpan-49f99fa48dc )