Search in sources :

Example 11 with Symbol

use of com.xenoage.zong.symbols.Symbol in project Zong by Xenoage.

the class KeySignatureRenderer method draw.

/**
 * Draws the given {@link KeySignatureStamping} on the given {@link Canvas},
 * using the given {@link RendererArgs}.
 */
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
    KeySignatureStamping s = (KeySignatureStamping) stamping;
    int fifths = s.key.element.getFifths();
    if (fifths == 0)
        return;
    boolean useSharps = (fifths > 0);
    float distance = s.distanceMm;
    Symbol symbol = args.symbolPool.getSymbol(useSharps ? CommonSymbol.AccidentalSharp : CommonSymbol.AccidentalFlat);
    // paint sharps/flats
    fifths = Math.abs(fifths);
    float interlineSpace = s.parentStaff.is;
    for (int i = 0; i < fifths; i++) {
        int linePosition = TraditionalKey.Companion.getLinePosition(i, useSharps, s.key.c4Lp, s.key.minLp);
        StaffSymbolRenderer.drawWith(symbol, null, sp(s.xMm + i * distance * interlineSpace, linePosition), 1, s.parentStaff, false, canvas, args);
    }
}
Also used : KeySignatureStamping(com.xenoage.zong.musiclayout.stampings.KeySignatureStamping) Symbol(com.xenoage.zong.symbols.Symbol) CommonSymbol(com.xenoage.zong.symbols.common.CommonSymbol)

Example 12 with Symbol

use of com.xenoage.zong.symbols.Symbol in project Zong by Xenoage.

the class BracketRenderer method paintBrace.

/**
 * Draws a brace, using the given bracket stamping and rendering parameters.
 */
private static void paintBrace(BracketStamping bracket, Canvas canvas, RendererArgs args) {
    float interlineSpace = bracket.firstStaff.is;
    float y1 = getStaffTopY(bracket.firstStaff, canvas, args);
    float y2 = getStaffBottomY(bracket.lastStaff, canvas, args);
    Point2f pCenter = new Point2f(bracket.xMm, (y1 + y2) / 2);
    Symbol braceSymbol = args.symbolPool.getSymbol(CommonSymbol.BracketBrace);
    float symbolScaling = (y2 - y1) / braceSymbol.getBoundingRect().size.height;
    SymbolsRenderer.draw(braceSymbol, canvas, Color.Companion.getBlack(), pCenter, new Point2f(interlineSpace * 1.2f, symbolScaling));
}
Also used : Point2f(com.xenoage.utils.math.geom.Point2f) CommonSymbol(com.xenoage.zong.symbols.common.CommonSymbol) Symbol(com.xenoage.zong.symbols.Symbol)

Example 13 with Symbol

use of com.xenoage.zong.symbols.Symbol in project Zong by Xenoage.

the class BracketRenderer method paintBracket.

/**
 * Draws a bracket, using the given bracket stamping and rendering parameters.
 */
private static void paintBracket(BracketStamping bracket, Canvas canvas, RendererArgs args) {
    float interlineSpace = bracket.firstStaff.is;
    float y1 = getStaffTopY(bracket.firstStaff, canvas, args);
    float y2 = getStaffBottomY(bracket.lastStaff, canvas, args);
    Point2f p1Mm = new Point2f(bracket.xMm, y1);
    Symbol bracketLineSymbol = args.symbolPool.getSymbol(CommonSymbol.BracketBracketLine);
    Symbol bracketEndSymbol = args.symbolPool.getSymbol(CommonSymbol.BracketBracketEnd);
    // to avoid gaps
    float lineYCorrection = bracketEndSymbol.getBoundingRect().size.height / 2;
    float lineYScaling = (y2 - y1 + lineYCorrection) / bracketLineSymbol.getBoundingRect().size.height;
    SymbolsRenderer.draw(bracketLineSymbol, canvas, Color.Companion.getBlack(), p(p1Mm.x, p1Mm.y - lineYCorrection / 2), new Point2f(interlineSpace, lineYScaling));
    SymbolsRenderer.draw(bracketEndSymbol, canvas, Color.Companion.getBlack(), p1Mm, new Point2f(interlineSpace, -interlineSpace));
    p1Mm = new Point2f(p1Mm.x, y2);
    SymbolsRenderer.draw(bracketEndSymbol, canvas, Color.Companion.getBlack(), p1Mm, new Point2f(interlineSpace, interlineSpace));
}
Also used : Point2f(com.xenoage.utils.math.geom.Point2f) CommonSymbol(com.xenoage.zong.symbols.common.CommonSymbol) Symbol(com.xenoage.zong.symbols.Symbol)

Aggregations

Symbol (com.xenoage.zong.symbols.Symbol)13 CommonSymbol (com.xenoage.zong.symbols.common.CommonSymbol)12 lombok.val (lombok.val)5 SP (com.xenoage.zong.core.music.format.SP)4 Point2f (com.xenoage.utils.math.geom.Point2f)2 KeySignatureStamping (com.xenoage.zong.musiclayout.stampings.KeySignatureStamping)2 StaffSymbolStamping (com.xenoage.zong.musiclayout.stampings.StaffSymbolStamping)2 StaffTextStamping (com.xenoage.zong.musiclayout.stampings.StaffTextStamping)2 Beam (com.xenoage.zong.core.music.beam.Beam)1 Chord (com.xenoage.zong.core.music.chord.Chord)1 StemDirection (com.xenoage.zong.core.music.chord.StemDirection)1 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)1 Duration (com.xenoage.zong.core.music.util.Duration)1 ChordStampings (com.xenoage.zong.musiclayout.layouter.scoreframelayout.util.ChordStampings)1 ChordWidths (com.xenoage.zong.musiclayout.settings.ChordWidths)1 LayoutSettings (com.xenoage.zong.musiclayout.settings.LayoutSettings)1 Spacings (com.xenoage.zong.musiclayout.settings.Spacings)1 FlagsStamping (com.xenoage.zong.musiclayout.stampings.FlagsStamping)1 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)1 TimeStamping (com.xenoage.zong.musiclayout.stampings.TimeStamping)1