Search in sources :

Example 6 with BitmapLine

use of com.xenoage.zong.musiclayout.stampings.bitmap.BitmapLine in project Zong by Xenoage.

the class WedgeRenderer method draw.

/**
 * Draws the given {@link WedgeStamping} on the given {@link Canvas},
 * using the given {@link RendererArgs}.
 */
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
    WedgeStamping wedge = (WedgeStamping) stamping;
    StaffStamping parentStaff = wedge.parentStaff;
    float scaling = args.scaling;
    // horizontal position
    float x1Mm = wedge.leftXMm + parentStaff.positionMm.x;
    float x2Mm = wedge.rightXMm + parentStaff.positionMm.x;
    // compute vertical distances at the start and end point
    float d1Mm = wedge.leftDistanceIs * parentStaff.is;
    float d2Mm = wedge.rightDistanceIs * parentStaff.is;
    // width and color of the line
    Color color = Color.Companion.getBlack();
    // like staff line
    float width = parentStaff.getLineWidthMm();
    float paintWidth;
    // compute the horizontal line and color
    float yMm;
    Color paintColor;
    if (canvas.getFormat() == CanvasFormat.Raster) {
        BitmapStaff ss = parentStaff.getBitmapInfo().getBitmapStaff(scaling);
        yMm = parentStaff.positionMm.y + ss.getYMm(wedge.lp);
        BitmapLine screenLine = parentStaff.getBitmapInfo().getBitmapLine(scaling, width, color);
        paintColor = screenLine.color;
        paintWidth = screenLine.widthMm;
    } else {
        yMm = parentStaff.computeYMm(wedge.lp);
        paintColor = color;
        paintWidth = width;
    }
    // draw lines
    canvas.drawLine(new Point2f(x1Mm, yMm - d1Mm / 2), new Point2f(x2Mm, yMm - d2Mm / 2), paintColor, paintWidth);
    canvas.drawLine(new Point2f(x1Mm, yMm + d1Mm / 2), new Point2f(x2Mm, yMm + d2Mm / 2), paintColor, paintWidth);
}
Also used : Point2f(com.xenoage.utils.math.geom.Point2f) StaffStamping(com.xenoage.zong.musiclayout.stampings.StaffStamping) Color(com.xenoage.utils.color.Color) BitmapLine(com.xenoage.zong.musiclayout.stampings.bitmap.BitmapLine) BitmapStaff(com.xenoage.zong.musiclayout.stampings.bitmap.BitmapStaff) WedgeStamping(com.xenoage.zong.musiclayout.stampings.WedgeStamping)

Aggregations

Color (com.xenoage.utils.color.Color)6 BitmapLine (com.xenoage.zong.musiclayout.stampings.bitmap.BitmapLine)6 BitmapStaff (com.xenoage.zong.musiclayout.stampings.bitmap.BitmapStaff)6 Point2f (com.xenoage.utils.math.geom.Point2f)5 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)5 FormattedText (com.xenoage.zong.core.text.FormattedText)2 Rectangle2f (com.xenoage.utils.math.geom.Rectangle2f)1 LegerLineStamping (com.xenoage.zong.musiclayout.stampings.LegerLineStamping)1 StemStamping (com.xenoage.zong.musiclayout.stampings.StemStamping)1 TupletStamping (com.xenoage.zong.musiclayout.stampings.TupletStamping)1 VoltaStamping (com.xenoage.zong.musiclayout.stampings.VoltaStamping)1 WedgeStamping (com.xenoage.zong.musiclayout.stampings.WedgeStamping)1