2020-11-09

等级不够无法自定义标签  VexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlowVexFlow

心血来潮学了点新东西,用了点时间学会初步使用,但是后续需要的专业知识不太懂,这里留个纪念

vexflow, 一个可以灵活编辑五线谱的好东西(除了index.js是我自己新建的,其余js都可以找到)

html

<!DOCTYPE html>
<html>
<head>
	<meta charset="ISO-8859-1">
	<title>wu</title>
</head>
<script type="text/javascript" src="js/vexflow-min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/qunit.js"></script>
<script type="text/javascript" src="js/raphael.js"></script>
<script type="text/javascript" src="js/vexflow-debug.js"></script>
<body>
	<div id="boo">
		
	</div>
</body>

</html>

 

index.js


function demo(){
	var div1 = document.getElementById("boo");
	var VF = Vex.Flow;
	var renderer = new VF.Renderer(div1, VF.Renderer.Backends.SVG);

	renderer.resize(500, 500);

	var context = renderer.getContext();

	var stave = new VF.Stave(10, 40, 400);
	stave.addClef("treble").addTimeSignature("4/4");
	stave.setContext(context).draw();
	var notes = [
		new VF.StaveNote({clef: "treble", keys: ["c/4"], duration: "q"}),
		new VF.StaveNote({clef: "treble", keys: ["d/4"], duration: "q"}),
		new VF.StaveNote({clef: "treble", keys: ["b/4"], duration: "qr"}),
		new VF.StaveNote({clef: "treble", keys: ["c/4", "e/4", "g/4"], duration: "q"})
	];
	var notes2 = [
		new VF.StaveNote({clef: "treble", keys: ["c/4"], duration: "w" })
	];
	var voices = [
		new VF.Voice({num_beats: 4,  beat_value: 4}).addTickables(notes),
		new VF.Voice({num_beats: 4,  beat_value: 4}).addTickables(notes2)]

	var formatter = new VF.Formatter().joinVoices(voices).format(voices, 400);

	// Render voices
	voices.forEach(function(v) { v.draw(context, stave); })
}
window.onload = demo;

效果

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值