App-Music-ChordPro

 view release on metacpan or  search on metacpan

lib/ChordPro/res/abc/abc2svg/gamelan-1.js  view on Meta::CPAN

	if (cmd == "gamelan") {
	    var	cfmt = this.cfmt()

		if (!this.get_bool(param))
			return
		cfmt.gamelan = true
		cfmt.staffsep = 20
		cfmt.sysstaffsep = 14
		this.set_v_param("stafflines", "...")
		cfmt.tuplets = [0, 1, 0, 1]	// [auto, slur, number, above]
		return
	}
	of(cmd, param)
    }, // set_fmt()

// adjust some values
    set_pitch: function(of, last_s) {
	of(last_s)
	if (!last_s
	 || !this.cfmt().gamelan)
		return			// first time

    var	C = abc2svg.C
	
	for (var s = this.get_tsfirst(); s; s = s.ts_next) {
		switch (s.type) {

		// adjust the vertical spacing above the note heads
		case C.NOTE:
			s.ymx = 20 * s.nhd + (s.nflags > 0 ? 30 : 24)
			if (s.notes[s.nhd].jo > 2) {
				s.ymx += 3
				if (s.notes[s.nhd].jo > 3)
					s.ymx += 2
			}
			s.ys = s.ymx		// (for tuplets)
			break
		}
	}
    }, // set_pitch()

// set the width of some symbols
    set_width: function(of, s) {
	of(s)
	if (!this.cfmt().gamelan)
		return

    var	w, m, note,
	C = abc2svg.C

	switch (s.type) {
	case C.CLEF:
	case C.KEY:
	case C.METER:
		s.wl = s.wr = .1		// (must not be null)
		break
	}
    }, // set_width()

    set_hooks: function(abc) {
	abc.do_pscom = abc2svg.gamelan.do_pscom.bind(abc, abc.do_pscom)
	abc.draw_symbols = abc2svg.gamelan.draw_symbols.bind(abc, abc.draw_symbols)
	abc.output_music = abc2svg.gamelan.output_music.bind(abc, abc.output_music)
	abc.set_format = abc2svg.gamelan.set_fmt.bind(abc, abc.set_format)
	abc.set_pitch = abc2svg.gamelan.set_pitch.bind(abc, abc.set_pitch)
	abc.set_width = abc2svg.gamelan.set_width.bind(abc, abc.set_width)

	// big staccato dot
	abc.get_glyphs().gstc = '<circle id="gstc" cx="0" cy="-3" r="2"/>'
	abc.get_decos().gstc = "0 gstc 5 1 1"

	abc.add_style("\n.bn {font-family:sans-serif; font-size:16px}")
    } // set_hooks()
} // gamelan

if (!abc2svg.mhooks)
	abc2svg.mhooks = {}
abc2svg.mhooks.gamelan = abc2svg.gamelan.set_hooks



( run in 0.893 second using v1.01-cache-2.11-cpan-2398b32b56e )