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);
}
}
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));
}
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));
}
Aggregations