CompositionView.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:MusicScratchpad 作者:
@Override
@TargetApi(21)
public void onDraw(Canvas c){
    paint.setStrokeWidth(10);
    for (int i = 2; i < 7; i++){
        c.drawLine(20, DensityMetrics.getSpaceHeight() * i + DensityMetrics.Companion.getToolbarHeight(),STAFF_WIDTH, DensityMetrics.getSpaceHeight() * i + DensityMetrics.Companion.getToolbarHeight(), paint);
    }
    float drawX = 320;
    for (ArrayList<Note> chord : MusicStore.sheet){
        for (Note note : chord){
            int noteHeadID = 0;
            if (note.getRhythm() == 2){
                noteHeadID = R.drawable.half_note_head;

            }else{
                noteHeadID = R.drawable.quarter_note_head;
            }

            VectorDrawable noteHead = (VectorDrawable) getResources().getDrawable(noteHeadID);
            Bitmap nh = NoteBitmap.getBitmap(noteHead);
            c.drawBitmap(Bitmap.createScaledBitmap(nh, (int) (DensityMetrics.getSpaceHeight() * 1.697), (int) DensityMetrics.getSpaceHeight(), true), (int) drawX , note.getY() - DensityMetrics.getSpaceHeight() / 2, paint);

        }
        drawX += 600;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号