Search in sources :

Example 11 with SP

use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.

the class SlurStamper method createStopForLastSystem.

/**
 * Creates a {@link SlurStamping} for a last part of a slur or tie
 * that spans at least two systems.
 */
SlurStamping createStopForLastSystem(StaffStamping staff, SP defaultSp, Slur slur) {
    SlurWaypoint wp2 = slur.getStop();
    // end points of the bezier curve
    SP p2 = computeEndPoint(slur, defaultSp, wp2.getBezierPoint());
    SP p1 = sp(staff.positionMm.x + staff.system.getMeasureStartAfterLeadingMm(staff.system.getStartMeasure()) - 5, // TODO
    p2.lp);
    // control points of the bezier curve
    BezierPoint b2 = wp2.getBezierPoint();
    // default formatting
    SP c1 = computeLeftControlPoint(slur, p1, p2, staff);
    SP c2 = (// custom formatting
    b2 != null && b2.getControl() != null ? // custom formatting
    b2.getControl() : // default formatting
    computeRightControlPoint(slur, p1, p2, staff));
    return new SlurStamping(slur, p1, p2, c1, c2, staff, staff);
}
Also used : BezierPoint(com.xenoage.zong.core.music.format.BezierPoint) SlurStamping(com.xenoage.zong.musiclayout.stampings.SlurStamping) SP(com.xenoage.zong.core.music.format.SP) SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint)

Example 12 with SP

use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.

the class SlurStamper method createForSingleSystem.

/**
 * Creates a {@link SlurStamping} for a curved line that
 * uses only a single system. The slur may span over multiple staves.
 */
SlurStamping createForSingleSystem(SlurCache slurCache) {
    Slur slur = slurCache.getSlur();
    SlurWaypoint wp1 = slur.getStart();
    SlurWaypoint wp2 = slur.getStop();
    // end points of the bezier curve
    VSide side = slurCache.getSide();
    SP p1 = computeEndPoint(slur, slurCache.getDefaultStartSp(), wp1.getBezierPoint());
    SP p2 = computeEndPoint(slur, slurCache.getDefaultStopSp(), wp2.getBezierPoint());
    // control points of the bezier curve
    BezierPoint b1 = wp1.getBezierPoint();
    BezierPoint b2 = wp2.getBezierPoint();
    SP c1 = (// custom formatting
    b1 != null && b1.getControl() != null ? // custom formatting
    b1.getControl() : // default formatting
    computeLeftControlPoint(slur, p1, p2, slurCache.getStartStaff()));
    SP c2 = (// custom formatting
    b2 != null && b2.getControl() != null ? // custom formatting
    b2.getControl() : // default formatting
    computeRightControlPoint(slur, p1, p2, slurCache.getStopStaff()));
    return new SlurStamping(slur, p1, p2, c1, c2, slurCache.getStartStaff(), slurCache.getStopStaff());
}
Also used : BezierPoint(com.xenoage.zong.core.music.format.BezierPoint) Slur(com.xenoage.zong.core.music.slur.Slur) ContinuedSlur(com.xenoage.zong.musiclayout.continued.ContinuedSlur) SlurStamping(com.xenoage.zong.musiclayout.stampings.SlurStamping) SP(com.xenoage.zong.core.music.format.SP) SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint) VSide(com.xenoage.utils.math.VSide)

Example 13 with SP

use of com.xenoage.zong.core.music.format.SP in project Zong by Xenoage.

the class OtherReader method readBezierPoint.

@MaybeNull
public static BezierPoint readBezierPoint(MxlPosition mxlPosition, MxlBezier mxlBezier, float tenthsMm, int staffLinesCount, float noteLP, Fraction chordDuration) {
    Float px = mxlPosition.getDefaultX();
    Float py = mxlPosition.getDefaultY();
    Float cx = (mxlBezier != null ? mxlBezier.getBezierX() : null);
    Float cy = (mxlBezier != null ? mxlBezier.getBezierY() : null);
    SP point = null;
    SP control = null;
    float halfNoteWidth = getNoteheadWidth(chordDuration) / 2;
    if (px != null && py != null) {
        float fpx = notNull(px, 0).floatValue();
        float fpy = notNull(py, 0).floatValue();
        // default-x is relative to left side of note. thus, substract the half width
        // of a note (TODO: note type. e.g., whole note is wider)
        point = sp((fpx / 10 - halfNoteWidth) * tenthsMm, (staffLinesCount - 1) * 2 + fpy / 10 * 2 - noteLP);
    }
    if (cx != null && cy != null) {
        float fcx = notNull(cx, 0).floatValue();
        float fcy = notNull(cy, 0).floatValue();
        control = sp((fcx / 10 - halfNoteWidth) * tenthsMm, fcy / 10 * 2);
    }
    if (point != null || control != null)
        return new BezierPoint(point, control);
    else
        return null;
}
Also used : BezierPoint(com.xenoage.zong.core.music.format.BezierPoint) SP(com.xenoage.zong.core.music.format.SP) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Aggregations

SP (com.xenoage.zong.core.music.format.SP)13 lombok.val (lombok.val)7 BezierPoint (com.xenoage.zong.core.music.format.BezierPoint)4 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)4 SlurStamping (com.xenoage.zong.musiclayout.stampings.SlurStamping)4 StaffTextStamping (com.xenoage.zong.musiclayout.stampings.StaffTextStamping)4 Symbol (com.xenoage.zong.symbols.Symbol)4 CommonSymbol (com.xenoage.zong.symbols.common.CommonSymbol)4 VSide (com.xenoage.utils.math.VSide)2 Slur (com.xenoage.zong.core.music.slur.Slur)2 StaffSymbolStamping (com.xenoage.zong.musiclayout.stampings.StaffSymbolStamping)2 MaybeNull (com.xenoage.utils.annotations.MaybeNull)1 LinearInterpolationPoints (com.xenoage.utils.math.MathUtils.LinearInterpolationPoints)1 WaypointPosition (com.xenoage.zong.core.music.WaypointPosition)1 Beam (com.xenoage.zong.core.music.beam.Beam)1 Chord (com.xenoage.zong.core.music.chord.Chord)1 Lyric (com.xenoage.zong.core.music.lyric.Lyric)1 SyllableType (com.xenoage.zong.core.music.lyric.SyllableType)1 Tuplet (com.xenoage.zong.core.music.tuplet.Tuplet)1 ContinuedSlur (com.xenoage.zong.musiclayout.continued.ContinuedSlur)1