notations 0.0.45 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/beats.js +5 -1
- package/lib/cjs/beats.js.map +1 -1
- package/lib/cjs/carnatic/LineView.js +5 -1
- package/lib/cjs/carnatic/LineView.js.map +1 -1
- package/lib/cjs/carnatic/NotationView.js +11 -4
- package/lib/cjs/carnatic/NotationView.js.map +1 -1
- package/lib/cjs/carnatic/atomviews.js +5 -1
- package/lib/cjs/carnatic/atomviews.js.map +1 -1
- package/lib/cjs/carnatic/beatviews.js +5 -1
- package/lib/cjs/carnatic/beatviews.js.map +1 -1
- package/lib/cjs/carnatic/embelishments.js +5 -1
- package/lib/cjs/carnatic/embelishments.js.map +1 -1
- package/lib/cjs/carnatic/index.js +5 -1
- package/lib/cjs/carnatic/index.js.map +1 -1
- package/lib/cjs/commands.js +5 -1
- package/lib/cjs/commands.js.map +1 -1
- package/lib/cjs/core.d.ts +9 -1
- package/lib/cjs/core.js +25 -2
- package/lib/cjs/core.js.map +1 -1
- package/lib/cjs/cycle.js +5 -1
- package/lib/cjs/cycle.js.map +1 -1
- package/lib/cjs/grids.d.ts +2 -0
- package/lib/cjs/grids.js +10 -0
- package/lib/cjs/grids.js.map +1 -0
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/iterators.js +5 -1
- package/lib/cjs/iterators.js.map +1 -1
- package/lib/cjs/layouts.js +5 -1
- package/lib/cjs/layouts.js.map +1 -1
- package/lib/cjs/loader.js +5 -1
- package/lib/cjs/loader.js.map +1 -1
- package/lib/cjs/parser.js +19 -2
- package/lib/cjs/parser.js.map +1 -1
- package/lib/cjs/shapes.js +5 -1
- package/lib/cjs/shapes.js.map +1 -1
- package/lib/cjs/utils.js +5 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/carnatic/NotationView.js +6 -3
- package/lib/esm/carnatic/NotationView.js.map +1 -1
- package/lib/esm/core.d.ts +9 -1
- package/lib/esm/core.js +19 -0
- package/lib/esm/core.js.map +1 -1
- package/lib/esm/grids.d.ts +2 -0
- package/lib/esm/grids.js +7 -0
- package/lib/esm/grids.js.map +1 -0
- package/lib/esm/parser.js +15 -2
- package/lib/esm/parser.js.map +1 -1
- package/package.json +22 -22
package/lib/cjs/beats.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/cjs/beats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beats.js","sourceRoot":"","sources":["../../src/beats.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,uBAA8D;AAE9D,yCAAuD;AAIvD,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnC,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;AAoBjC;IASE,cACkB,KAAa,EACb,IAAU,EACV,MAAgB,EAChB,QAAkB,EAClB,QAAgB,EAChB,SAAiB,EACjB,QAAgB,EAChB,QAAqB,EAC9B,QAAqB;QARZ,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CA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AQ,CAAC,CAAC;iBACxD;;;;;;;;;YACD,IAAI,QAAQ,CAAC,MAAM,EAAE;gBACnB,IAAI,IAAI,CAAC,YAAY;oBAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aACpD;SACF;IACH,CAAC;IACH,mBAAC;AAAD,CAAC,AA1FD,IA0FC;AA1FY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { FlatAtom, WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\ninterface BeatViewDelegate {\n // A way to create all beats for an entire Line in one go (instead of one by one)\n viewForBeat(beat: Beat): BeatView;\n}\n\nexport interface BeatView {\n readonly beat: Beat;\n readonly needsLayout: boolean;\n readonly minSize: TSU.Geom.Size;\n readonly bbox: TSU.Geom.Rect;\n x: number;\n y: number;\n width: number;\n height: number;\n refreshLayout(): void;\n setStyles(config: any): void;\n}\n\nexport class Beat {\n private static idCounter = 0;\n layoutLine = -1;\n layoutColumn = -1;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n ensureUniformSpaces(atoms: FlatAtom[], slotsPerBeat = 1): void {\n let lcm = 1;\n let gcd = 0;\n atoms.forEach((a, index) => {\n a.duration = a.duration.factorized;\n const currDen = a.duration.den;\n if (currDen != 1) {\n lcm *= currDen;\n if (gcd == 0) {\n gcd = a.duration.den;\n } else {\n gcd = TSU.Num.gcdof(gcd, currDen);\n lcm /= gcd;\n }\n }\n });\n\n // Easiest option is (without worrying about depths)\n // just adding this N number 1 / LCM sized spaces for\n // each note where N = (LCM / note.frac.den) - 1\n\n // eg in the case of something like (a beat with) the notes\n // A: 1/2, B: 1/4, C: 1/6\n // LCM (of dens) = 24\n // 12 (1/24) spaces, 6 (1/24)\n // A = (24 / 2) - 1 = 11 spaces after A\n // B = (24 / 4) - 1 = 5 spaces after B\n // C = (24 / 6) - 1 = 3 spaces after C\n // Total = 11 + 5 + 3 + 3 (for A + B + C) = 22 notes in the beat\n\n const baseDur = new TSU.Num.Fraction(1, lcm);\n let currOffset = this.offset;\n for (let i = 0; i < atoms.length; ) {\n const fa = atoms[i];\n const numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;\n // reset its duration to 1 / LCM so we can add numSpaces after it\n fa.duration = baseDur;\n currOffset = currOffset.plus(baseDur);\n i++;\n for (let j = 0; j < numSpaces; j++, i++) {\n const space = new Space(baseDur);\n space.isContinuation = true;\n atoms.splice(i, 0, new FlatAtom(space));\n atoms.splice(i, 0, new FlatAtom(space));\n currOffset = currOffset.plus(baseDur);\n }\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatLayout {\n // beatColumns[i][j] returns all beats in a particular layoutLine and\n // layoutColumn the purpose of beatColumns is to ensure horizontal alignment\n // of beats in a single column\n bcolNextList = new Map<string, Set<string>>();\n beatColumns = new Map<string, BeatColumn>();\n // bcolsStartingAt = new Map<string, BeatColumn[]>();\n // bcolsEndingAt = new Map<string, BeatColumn[]>();\n startingColumns: BeatColumn[] = [];\n\n // Mapping from beat -> BeatColumn where it resides\n columnForBeat = new Map<number, BeatColumn>();\n\n constructor(public readonly layoutParams: LayoutParams) {}\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, duration: Fraction): BeatColumn {\n const key = BeatLayout.keyFor(offset, duration);\n let bcol = this.beatColumns.get(key) || null;\n if (!bcol) {\n bcol = new BeatColumn(offset, duration);\n this.beatColumns.set(key, bcol);\n if (bcol.offset.isZero) {\n // this is a \"starting\" column\n this.startingColumns.push(bcol);\n } else {\n const endOffset = offset.plus(duration);\n // Find all columns \"before\" this and add this as a neighbour to those\n // columsn before are such that their prev.offset + prev.duration == bcol.offset\n for (const other of this.beatColumns.values()) {\n if (other.offset.plus(other.duration).equals(offset)) {\n // mark us as a successor of other\n this.addSuccessor(other, bcol);\n } else if (other.offset.equals(endOffset)) {\n // mark other as a successor of us\n this.addSuccessor(bcol, other);\n }\n }\n\n // Similary find all columns who could \"next\" sets and add us to them\n }\n }\n return bcol;\n }\n\n protected static keyFor(offset: Fraction, duration: Fraction): string {\n return offset.factorized.toString() + \":\" + duration.factorized.toString();\n }\n\n protected addSuccessor(prev: BeatColumn, next: BeatColumn): void {\n TSU.assert(prev.offset.plus(prev.duration).equals(next.offset), \"BeatColumns are not adjacent to each other\");\n const prevKey = BeatLayout.keyFor(prev.offset, prev.duration);\n const nextKey = BeatLayout.keyFor(next.offset, next.duration);\n let nextset = this.bcolNextList.get(prevKey) || null;\n if (!nextset) {\n nextset = new Set<string>();\n this.bcolNextList.set(prevKey, nextset);\n }\n nextset.add(nextKey);\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which this beat was added.\n */\n addBeat(beat: Beat): BeatColumn {\n // Get the beat column at this index (and line) and add to it.\n const lp = this.layoutParams;\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const bcol = this.getBeatColumn(rowOffset, beat.duration);\n\n bcol.add(beat);\n\n // TODO: see if beat exists in another column\n this.columnForBeat.set(beat.uuid, bcol);\n beat.layoutLine = layoutLine;\n beat.layoutColumn = layoutColumn;\n return bcol;\n }\n\n /**\n * Return all beat columns that start immediately after the given beat column.\n */\n neighborsOf(beatColumn: BeatColumn): BeatColumn[] {\n const out: BeatColumn[] = [];\n const endOffset = beatColumn.offset.plus(beatColumn.duration);\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n out.push(other);\n }\n }\n return out;\n }\n\n readonly DEBUG = false;\n evalColumnSizes(beatViewDelegate: BeatViewDelegate): void {\n // Do a bread first traversal of the beat columns so those with earlier offsets\n // will be laid out and nudged so that later ones' offsets can be set only once.\n // TODO - should this be a priority queue - ie is there a need to sort these by\n // \"larger\" widths first?\n let queue: BeatColumn[] = [...this.startingColumns];\n const xForOffsets: TSU.StringMap<number> = {};\n while (queue.length > 0) {\n const nextQueue: BeatColumn[] = [];\n for (const bcol of queue) {\n const offset = bcol.offset.factorized;\n const colWidth = bcol.evalMaxWidth(beatViewDelegate);\n let currX = 0;\n if (!bcol.offset.isZero) {\n // this *must* be in xForOffsets as it would have been calculated by a previous bcol\n TSU.assert(offset.toString() in xForOffsets, \"Cannot find x for given offset\");\n currX = xForOffsets[offset.toString()];\n }\n bcol.setX(currX, beatViewDelegate);\n const endOffset = offset.plus(bcol.duration, true);\n xForOffsets[endOffset.toString()] = Math.max(\n xForOffsets[endOffset.toString()] || 0,\n currX + colWidth + bcol.paddingLeft + bcol.paddingRight,\n );\n // add all neighbours here\n // TODO - Use better lists of going through all beat cols\n // Also ensure we are adding in sorted order and avoiding duplicates\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n nextQueue.push(other);\n }\n }\n }\n queue = nextQueue;\n }\n }\n\n // Spacing between each role in a single row\n roleSpacing = 10;\n\n // Spacing between each row (a row can consist of multiple roles).\n rowSpacing = 15;\n layoutBeatsForLine(line: Line, allRoleBeats: Beat[][], beatViewDelegate: BeatViewDelegate): void {\n // Instead of starting currLayoutLine at 0 - it should start at the line of the\n // first beat being rendered\n const lp = this.layoutParams;\n const currBeats = line.roles.map((l, index) => allRoleBeats[index][0]) as (Beat | null)[];\n let currY = this.roleSpacing;\n let numDone = 0;\n do {\n numDone = 0;\n // Lay one role at a time upto numBeatsInLine number of beats\n for (let currRole = 0; currRole < currBeats.length; currRole++) {\n let currBeat: Beat | null = currBeats[currRole];\n if (currBeat) {\n const temp = currBeat;\n const numBeatsInRow = lp.lineBreaks[currBeat.layoutLine];\n let maxHeight = 0;\n let currX = 15;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.y = currY;\n if (this.DEBUG) {\n beatView.x = currX;\n beatView.refreshLayout();\n currX += beatView.width;\n }\n maxHeight = Math.max(maxHeight, beatView.minSize.height);\n }\n\n currBeat = temp;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.height = maxHeight;\n }\n // Should line heights be \"fixed\"?\n // Set height of all views in this row to same height and Y\n currY += maxHeight;\n currY += this.roleSpacing;\n }\n currBeats[currRole] = currBeat;\n }\n\n // currLayoutLine = (currLayoutLine + 1) % lp.lineBreaks.length;\n currY += this.rowSpacing;\n } while (numDone > 0);\n }\n}\n\nexport class BeatRow {\n protected _y = 0;\n protected _maxHeight = 0;\n needsLayout = false;\n rowSpacing = 5;\n beats: Beat[] = [];\n constructor(public readonly layoutLine: number, public rowIndex: number) {}\n\n get y(): number {\n return this._y;\n }\n\n set y(val: number) {\n this._y = val;\n this.needsLayout = true;\n }\n\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added to either this row or another row?\n this.beats.push(beat);\n this.needsLayout = true;\n }\n}\n\nexport class BeatColumn {\n protected _x = 0;\n protected _maxWidth = 0;\n needsLayout = false;\n atomSpacing = 5;\n paddingLeft = 15;\n paddingRight = 15;\n beats: Beat[] = [];\n constructor(public readonly offset: Fraction, public readonly duration: Fraction) {\n offset = offset.factorized;\n duration = duration.factorized;\n }\n\n get x(): number {\n return this._x;\n }\n\n setX(val: number, beatViewDelegate: BeatViewDelegate): void {\n this._x = val;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n beatView.x = val + this.paddingLeft;\n beatView.width = this._maxWidth;\n // console.log(\"ID, Setting x, width: \", beatView.beat.index, (beatView as any).x, (beatView as any).width);\n }\n }\n\n get maxWidth(): number {\n return this._maxWidth + this.paddingLeft + this.paddingRight;\n }\n\n setPadding(left: number, right: number): void {\n if (left >= 0) {\n this.paddingLeft = left;\n }\n if (right >= 0) {\n this.paddingRight = right;\n }\n }\n\n evalMaxWidth(beatViewDelegate: BeatViewDelegate): number {\n this._maxWidth = 0;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n // console.log( \"index, _minSize, refreshMinSize = \", beatView.beat.index, (beatView as any)._minSize, (beatView as any).refreshMinSize(),);\n const minSize = beatView.minSize;\n if (minSize.width > this._maxWidth) {\n this._maxWidth = minSize.width;\n }\n }\n return this._maxWidth;\n }\n\n /**\n * Adds a new beat to this column.\n * Returns true if the column's width has increased. This is an indicator\n * to the caller that a layout of all other views in this column is needed\n * so the refresh can be scheduled at some time.\n */\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added?\n this.beats.push(beat);\n this.needsLayout = true;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start at beginning\n // of a cycle. Butif the start offset is < 0 then the startIndex should also shift\n // accordingly\n this.startIndex = index;\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBe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C,IAAI,QAAQ,CAAC,MAAM,EAAE;gBAE7C,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;aAC3B;YAGK,IAAA,KAAA,OAAqB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAA,EAA3D,QAAQ,QAAA,EAAE,MAAM,QAA2C,CAAC;YACnE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,qDAAqD,CAAC,CAAC;;gBAEvF,KAAmB,IAAA,4BAAA,SAAA,QAAQ,CAAA,CAAA,kCAAA,wDAAE;oBAAxB,IAAM,IAAI,qBAAA;oBAEb,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,qEAAqE,CAAC,CAAC;oBACtG,IAAI,IAAI,CAAC,WAAW;wBAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;iBACxD;;;;;;;;;YACD,IAAI,QAAQ,CAAC,MAAM,EAAE;gBACnB,IAAI,IAAI,CAAC,YAAY;oBAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aACpD;SACF;IACH,CAAC;IACH,mBAAC;AAAD,CAAC,AA1FD,IA0FC;AA1FY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType, Group, Line, Atom, Space, Role } from \"./\";\nimport { CycleIterator, CyclePosition } from \"./cycle\";\nimport { FlatAtom, WindowIterator } from \"./iterators\";\nimport { LayoutParams } from \"./layouts\";\n\ntype Fraction = TSU.Num.Fraction;\nconst ZERO = TSU.Num.Fraction.ZERO;\nconst ONE = TSU.Num.Fraction.ONE;\n\ninterface BeatViewDelegate {\n // A way to create all beats for an entire Line in one go (instead of one by one)\n viewForBeat(beat: Beat): BeatView;\n}\n\nexport interface BeatView {\n readonly beat: Beat;\n readonly needsLayout: boolean;\n readonly minSize: TSU.Geom.Size;\n readonly bbox: TSU.Geom.Rect;\n x: number;\n y: number;\n width: number;\n height: number;\n refreshLayout(): void;\n setStyles(config: any): void;\n}\n\nexport class Beat {\n private static idCounter = 0;\n layoutLine = -1;\n layoutColumn = -1;\n readonly uuid = Beat.idCounter++;\n // Should this be as flat Atoms or should we keep it as atoms and breakdown\n // later?\n atom: Atom;\n protected atomIsPlaceholder = false;\n constructor(\n public readonly index: number,\n public readonly role: Role,\n public readonly offset: Fraction,\n public readonly duration: Fraction,\n public readonly barIndex: number,\n public readonly beatIndex: number,\n public readonly instance: number,\n public readonly prevBeat: null | Beat,\n public nextBeat: null | Beat,\n ) {}\n\n debugValue(): any {\n return {\n index: this.index,\n role: this.role.name,\n offset: this.offset.toString(),\n duration: this.duration.toString(),\n barIndex: this.barIndex,\n beatIndex: this.beatIndex,\n instance: this.instance,\n atom: this.atom.debugValue(),\n };\n }\n\n get endOffset(): Fraction {\n return this.offset.plus(this.duration);\n }\n\n get filled(): boolean {\n return this.remaining.isZero;\n }\n\n get remaining(): Fraction {\n return this.atom ? this.duration.minus(this.atom.duration, true) : this.duration;\n }\n\n add(atom: Atom): boolean {\n if (this.remaining.cmp(atom.duration) < 0) {\n return false;\n }\n if (!this.atom) {\n this.atom = atom;\n } else {\n if (!this.atomIsPlaceholder) {\n this.atomIsPlaceholder = true;\n this.atom = new Group(this.atom).setDuration(ONE, true);\n }\n (this.atom as Group).addAtoms(true, atom);\n }\n return true;\n }\n\n ensureUniformSpaces(atoms: FlatAtom[], slotsPerBeat = 1): void {\n let lcm = 1;\n let gcd = 0;\n atoms.forEach((a, index) => {\n a.duration = a.duration.factorized;\n const currDen = a.duration.den;\n if (currDen != 1) {\n lcm *= currDen;\n if (gcd == 0) {\n gcd = a.duration.den;\n } else {\n gcd = TSU.Num.gcdof(gcd, currDen);\n lcm /= gcd;\n }\n }\n });\n\n // Easiest option is (without worrying about depths)\n // just adding this N number 1 / LCM sized spaces for\n // each note where N = (LCM / note.frac.den) - 1\n\n // eg in the case of something like (a beat with) the notes\n // A: 1/2, B: 1/4, C: 1/6\n // LCM (of dens) = 24\n // 12 (1/24) spaces, 6 (1/24)\n // A = (24 / 2) - 1 = 11 spaces after A\n // B = (24 / 4) - 1 = 5 spaces after B\n // C = (24 / 6) - 1 = 3 spaces after C\n // Total = 11 + 5 + 3 + 3 (for A + B + C) = 22 notes in the beat\n\n const baseDur = new TSU.Num.Fraction(1, lcm);\n let currOffset = this.offset;\n for (let i = 0; i < atoms.length; ) {\n const fa = atoms[i];\n const numSpaces = lcm == 1 ? fa.duration.num - 1 : lcm / fa.duration.den - 1;\n // reset its duration to 1 / LCM so we can add numSpaces after it\n fa.duration = baseDur;\n currOffset = currOffset.plus(baseDur);\n i++;\n for (let j = 0; j < numSpaces; j++, i++) {\n const space = new Space(baseDur);\n space.isContinuation = true;\n atoms.splice(i, 0, new FlatAtom(space));\n atoms.splice(i, 0, new FlatAtom(space));\n currOffset = currOffset.plus(baseDur);\n }\n }\n }\n}\n\n/**\n * Grouping of beats by their column based on the layout params.\n * The confusion is we have beats broken up and saved in columns\n * but we are loosing how a line is supposed to access it in its own way\n * we have beatsByRole for getting all beats for a role (in a line)\n * sequentially we have beatColumns for getting all beats in a particular\n * column across all lines and roles globally.\n *\n * What we want here is for a given line get all roles, their beats\n * in zipped way. eg for a Line with 3 roles and say 10 beats each\n * (with the breaks of 4, 1) we need:\n *\n * R1 B1 R1 B2 R1 B3 R1 B4\n * R2 B1 R2 B2 R2 B3 R2 B4\n * R3 B1 R3 B2 R3 B3 R3 B4\n *\n * R1 B5\n * R2 B5\n * R3 B5\n *\n * R1 B6 R1 B7 R1 B8 R1 B9\n * R2 B6 R2 B7 R2 B8 R2 B9\n * R3 B6 R3 B7 R3 B8 R3 B9\n *\n * R1 B10\n * R2 B10\n * R3 B10\n *\n *\n * Here we have 5 distinct beat columns:\n *\n * 1: R1B1, R2B1, R3B1, R1B6, R2B6, R3B6,\n * 2: R1B2, R2B2, R3B2, R1B7, R2B7, R3B7,\n * 3: R1B3, R2B3, R3B3, R1B8, R2B8, R3B8,\n * 4: R1B4, R2B4, R3B4, R1B9, R2B9, R3B9,\n * 5: R1B5, R2B5, R3B5, R1B10, R2B10, R3B10,\n *\n */\nexport class BeatLayout {\n // beatColumns[i][j] returns all beats in a particular layoutLine and\n // layoutColumn the purpose of beatColumns is to ensure horizontal alignment\n // of beats in a single column\n bcolNextList = new Map<string, Set<string>>();\n beatColumns = new Map<string, BeatColumn>();\n // bcolsStartingAt = new Map<string, BeatColumn[]>();\n // bcolsEndingAt = new Map<string, BeatColumn[]>();\n startingColumns: BeatColumn[] = [];\n\n // Mapping from beat -> BeatColumn where it resides\n columnForBeat = new Map<number, BeatColumn>();\n\n constructor(public readonly layoutParams: LayoutParams) {}\n\n /**\n * Gets the beat column of a given duration at the given offset.\n */\n getBeatColumn(offset: Fraction, duration: Fraction): BeatColumn {\n const key = BeatLayout.keyFor(offset, duration);\n let bcol = this.beatColumns.get(key) || null;\n if (!bcol) {\n bcol = new BeatColumn(offset, duration);\n this.beatColumns.set(key, bcol);\n if (bcol.offset.isZero) {\n // this is a \"starting\" column\n this.startingColumns.push(bcol);\n } else {\n const endOffset = offset.plus(duration);\n // Find all columns \"before\" this and add this as a neighbour to those\n // columsn before are such that their prev.offset + prev.duration == bcol.offset\n for (const other of this.beatColumns.values()) {\n if (other.offset.plus(other.duration).equals(offset)) {\n // mark us as a successor of other\n this.addSuccessor(other, bcol);\n } else if (other.offset.equals(endOffset)) {\n // mark other as a successor of us\n this.addSuccessor(bcol, other);\n }\n }\n\n // Similary find all columns who could \"next\" sets and add us to them\n }\n }\n return bcol;\n }\n\n protected static keyFor(offset: Fraction, duration: Fraction): string {\n return offset.factorized.toString() + \":\" + duration.factorized.toString();\n }\n\n protected addSuccessor(prev: BeatColumn, next: BeatColumn): void {\n TSU.assert(prev.offset.plus(prev.duration).equals(next.offset), \"BeatColumns are not adjacent to each other\");\n const prevKey = BeatLayout.keyFor(prev.offset, prev.duration);\n const nextKey = BeatLayout.keyFor(next.offset, next.duration);\n let nextset = this.bcolNextList.get(prevKey) || null;\n if (!nextset) {\n nextset = new Set<string>();\n this.bcolNextList.set(prevKey, nextset);\n }\n nextset.add(nextKey);\n }\n\n /**\n * Adds the beat to this layout and returns the BeatColumn to which this beat was added.\n */\n addBeat(beat: Beat): BeatColumn {\n // Get the beat column at this index (and line) and add to it.\n const lp = this.layoutParams;\n const [layoutLine, layoutColumn, rowOffset] = lp.getBeatLocation(beat);\n const bcol = this.getBeatColumn(rowOffset, beat.duration);\n\n bcol.add(beat);\n\n // TODO: see if beat exists in another column\n this.columnForBeat.set(beat.uuid, bcol);\n beat.layoutLine = layoutLine;\n beat.layoutColumn = layoutColumn;\n return bcol;\n }\n\n /**\n * Return all beat columns that start immediately after the given beat column.\n */\n neighborsOf(beatColumn: BeatColumn): BeatColumn[] {\n const out: BeatColumn[] = [];\n const endOffset = beatColumn.offset.plus(beatColumn.duration);\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n out.push(other);\n }\n }\n return out;\n }\n\n readonly DEBUG = false;\n evalColumnSizes(beatViewDelegate: BeatViewDelegate): void {\n // Do a bread first traversal of the beat columns so those with earlier offsets\n // will be laid out and nudged so that later ones' offsets can be set only once.\n // TODO - should this be a priority queue - ie is there a need to sort these by\n // \"larger\" widths first?\n let queue: BeatColumn[] = [...this.startingColumns];\n const xForOffsets: TSU.StringMap<number> = {};\n while (queue.length > 0) {\n const nextQueue: BeatColumn[] = [];\n for (const bcol of queue) {\n const offset = bcol.offset.factorized;\n const colWidth = bcol.evalMaxWidth(beatViewDelegate);\n let currX = 0;\n if (!bcol.offset.isZero) {\n // this *must* be in xForOffsets as it would have been calculated by a previous bcol\n TSU.assert(offset.toString() in xForOffsets, \"Cannot find x for given offset\");\n currX = xForOffsets[offset.toString()];\n }\n bcol.setX(currX, beatViewDelegate);\n const endOffset = offset.plus(bcol.duration, true);\n xForOffsets[endOffset.toString()] = Math.max(\n xForOffsets[endOffset.toString()] || 0,\n currX + colWidth + bcol.paddingLeft + bcol.paddingRight,\n );\n // add all neighbours here\n // TODO - Use better lists of going through all beat cols\n // Also ensure we are adding in sorted order and avoiding duplicates\n for (const other of this.beatColumns.values()) {\n if (endOffset.equals(other.offset)) {\n nextQueue.push(other);\n }\n }\n }\n queue = nextQueue;\n }\n }\n\n // Spacing between each role in a single row\n roleSpacing = 10;\n\n // Spacing between each row (a row can consist of multiple roles).\n rowSpacing = 15;\n layoutBeatsForLine(line: Line, allRoleBeats: Beat[][], beatViewDelegate: BeatViewDelegate): void {\n // Instead of starting currLayoutLine at 0 - it should start at the line of the\n // first beat being rendered\n const lp = this.layoutParams;\n const currBeats = line.roles.map((l, index) => allRoleBeats[index][0]) as (Beat | null)[];\n let currY = this.roleSpacing;\n let numDone = 0;\n do {\n numDone = 0;\n // Lay one role at a time upto numBeatsInLine number of beats\n for (let currRole = 0; currRole < currBeats.length; currRole++) {\n let currBeat: Beat | null = currBeats[currRole];\n if (currBeat) {\n const temp = currBeat;\n const numBeatsInRow = lp.lineBreaks[currBeat.layoutLine];\n let maxHeight = 0;\n let currX = 15;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.y = currY;\n if (this.DEBUG) {\n beatView.x = currX;\n beatView.refreshLayout();\n currX += beatView.width;\n }\n maxHeight = Math.max(maxHeight, beatView.minSize.height);\n }\n\n currBeat = temp;\n for (\n let i = currBeat.layoutColumn;\n i < numBeatsInRow && currBeat;\n i++, currBeat = currBeat.nextBeat, numDone++\n ) {\n const beatView = beatViewDelegate.viewForBeat(currBeat);\n beatView.height = maxHeight;\n }\n // Should line heights be \"fixed\"?\n // Set height of all views in this row to same height and Y\n currY += maxHeight;\n currY += this.roleSpacing;\n }\n currBeats[currRole] = currBeat;\n }\n\n // currLayoutLine = (currLayoutLine + 1) % lp.lineBreaks.length;\n currY += this.rowSpacing;\n } while (numDone > 0);\n }\n}\n\nexport class BeatRow {\n protected _y = 0;\n protected _maxHeight = 0;\n needsLayout = false;\n rowSpacing = 5;\n beats: Beat[] = [];\n constructor(public readonly layoutLine: number, public rowIndex: number) {}\n\n get y(): number {\n return this._y;\n }\n\n set y(val: number) {\n this._y = val;\n this.needsLayout = true;\n }\n\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added to either this row or another row?\n this.beats.push(beat);\n this.needsLayout = true;\n }\n}\n\nexport class BeatColumn {\n protected _x = 0;\n protected _maxWidth = 0;\n needsLayout = false;\n atomSpacing = 5;\n paddingLeft = 15;\n paddingRight = 15;\n beats: Beat[] = [];\n constructor(public readonly offset: Fraction, public readonly duration: Fraction) {\n offset = offset.factorized;\n duration = duration.factorized;\n }\n\n get x(): number {\n return this._x;\n }\n\n setX(val: number, beatViewDelegate: BeatViewDelegate): void {\n this._x = val;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n beatView.x = val + this.paddingLeft;\n beatView.width = this._maxWidth;\n // console.log(\"ID, Setting x, width: \", beatView.beat.index, (beatView as any).x, (beatView as any).width);\n }\n }\n\n get maxWidth(): number {\n return this._maxWidth + this.paddingLeft + this.paddingRight;\n }\n\n setPadding(left: number, right: number): void {\n if (left >= 0) {\n this.paddingLeft = left;\n }\n if (right >= 0) {\n this.paddingRight = right;\n }\n }\n\n evalMaxWidth(beatViewDelegate: BeatViewDelegate): number {\n this._maxWidth = 0;\n for (const beat of this.beats) {\n const beatView = beatViewDelegate.viewForBeat(beat);\n // console.log( \"index, _minSize, refreshMinSize = \", beatView.beat.index, (beatView as any)._minSize, (beatView as any).refreshMinSize(),);\n const minSize = beatView.minSize;\n if (minSize.width > this._maxWidth) {\n this._maxWidth = minSize.width;\n }\n }\n return this._maxWidth;\n }\n\n /**\n * Adds a new beat to this column.\n * Returns true if the column's width has increased. This is an indicator\n * to the caller that a layout of all other views in this column is needed\n * so the refresh can be scheduled at some time.\n */\n add(beat: Beat): void {\n // Find line this view should be added to.\n // TODO - Should we check if this beat was already added?\n this.beats.push(beat);\n this.needsLayout = true;\n }\n}\n\nexport class BeatsBuilder {\n // All atoms divided into beats\n readonly beats: Beat[] = [];\n readonly startIndex: number;\n readonly beatOffset: Fraction;\n cycleIter: CycleIterator;\n windowIter: WindowIterator;\n\n // Callback for when an atom is added to this role.\n onAtomAdded: (atom: Atom, beat: Beat) => void;\n\n // Callback for when a new beat is added\n onBeatAdded: (beat: Beat) => void;\n // Callback for when a beat has been filled\n onBeatFilled: (beat: Beat) => void;\n\n constructor(\n public readonly role: Role,\n public readonly layoutParams: LayoutParams,\n public readonly startOffset: Fraction = ZERO,\n ) {\n const [, [bar, beat, instance], beatOffset, index] = layoutParams.cycle.getPosition(startOffset);\n this.cycleIter = layoutParams.cycle.iterateBeats(bar, beat, instance);\n this.windowIter = new WindowIterator();\n this.beatOffset = beatOffset;\n\n // evaluate the start beatindex - typically it would be 0 if things start at beginning\n // of a cycle. Butif the start offset is < 0 then the startIndex should also shift\n // accordingly\n this.startIndex = index;\n }\n\n protected addBeat(): Beat {\n const numBeats = this.beats.length;\n const lastBeat = numBeats == 0 ? null : this.beats[numBeats - 1];\n const nextCP: [CyclePosition, Fraction] = this.cycleIter.next().value;\n const apb = this.layoutParams.beatDuration;\n const newBeat = new Beat(\n lastBeat == null ? this.startIndex : lastBeat.index + 1,\n this.role,\n lastBeat == null ? this.startOffset.minus(this.beatOffset).timesNum(apb, true) : lastBeat.endOffset,\n nextCP[1].timesNum(apb),\n nextCP[0][0],\n nextCP[0][1],\n nextCP[0][2],\n lastBeat,\n null,\n );\n if (lastBeat == null && this.beatOffset.isGT(ZERO)) {\n // Add spaces to fill up empty beats\n newBeat.add(new Space(this.beatOffset.timesNum(apb)));\n }\n if (lastBeat) lastBeat.nextBeat = newBeat;\n this.beats.push(newBeat);\n if (this.onBeatAdded) this.onBeatAdded(newBeat);\n return newBeat;\n }\n\n addAtoms(...atoms: Atom[]): void {\n // First add all atoms to the atom Iterator so we can\n // fetch them as FlatAtoms. This is needed because atoms\n // passed here could be unflatted (via groups) or much larger\n // than what can fit in the given role/bar etc. So this\n // flattening and windowing is needed before we add them\n // to the views - and this is done by the durationIterators.\n this.windowIter.push(...atoms);\n while (this.windowIter.hasMore) {\n // get the last/current row and add a new one if it is full\n let currBeat = this.beats[this.beats.length - 1];\n\n // First add a row if last row is filled\n if (this.beats.length == 0 || currBeat.filled) {\n // what should be the beatlengths be here?\n currBeat = this.addBeat();\n }\n\n // For this beat get symbols in all roles\n const [remAtoms, filled] = this.windowIter.get(currBeat.remaining);\n TSU.assert(remAtoms.length > 0, \"Atleast one element should have been available here\");\n // render the atoms now\n for (const atom of remAtoms) {\n // console.log(\"Adding FA: \", flatAtom.debugValue(), flatAtom.atom);\n TSU.assert(currBeat.add(atom), \"Should return true as we are already using a duration iterator here\");\n if (this.onAtomAdded) this.onAtomAdded(atom, currBeat);\n }\n if (currBeat.filled) {\n if (this.onBeatFilled) this.onBeatFilled(currBeat);\n }\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineView.js","sourceRoot":"","sources":["../../../src/carnatic/LineView.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LineView.js","sourceRo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,WAAW,CAAC,OAAO,EAAE,CAAC;YAExC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC;;;OAAA;IAGD,8BAAW,GAAX,UAAY,IAAU;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAElC,IAAM,CAAC,GAAG,IAAI,oBAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAE7E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACjC,OAAO,CAAC,CAAC;SACV;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC;IACxC,CAAC;IACH,eAAC;AAAD,CAAC,AAvDD,IAuDC;AAvDY,4BAAQ","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Beat, BeatLayout } from \"../beats\";\nimport { BeatView } from \"./beatviews\";\nimport { Line } from \"../core\";\n\nexport class LineView {\n // roleStates: RoleState[];\n // For each line a mapping of its Atoms in each role grouped by Beat for layout\n beatsByLineRole: Beat[][];\n // The beat layout associated with the layout params of this Line\n // at this point beats have already been added to the right columns\n beatLayout: BeatLayout;\n gElem: SVGGElement;\n\n // Space between two roles (within the same row)\n roleSpacing = 20;\n\n // Vertical space between two rows (of multiple roles)\n rowSpacing = 10;\n\n constructor(public readonly rootElement: SVGSVGElement, public line: Line, public readonly config?: any) {\n this.loadChildViews();\n }\n\n protected loadChildViews(): void {\n // create the gElem for wrapping and adjusting to size\n this.gElem = TSU.DOM.createSVGNode(\"g\", {\n parent: this.rootElement,\n attrs: {\n class: \"lineRoot\",\n id: \"lineRoot\" + this.line.uuid,\n },\n }) as SVGGElement;\n }\n\n wrapToSize(): void {\n const bbox = (this.gElem as SVGSVGElement).getBBox();\n // set the size of the svg\n this.rootElement.setAttribute(\"width\", \"\" + (4 + bbox.width));\n this.rootElement.setAttribute(\"height\", \"\" + (15 + bbox.height));\n this.gElem.setAttribute(\"transform\", `translate(${4 - bbox.x}, ${4 - bbox.y})`);\n }\n\n get prefSize(): TSU.Geom.Size {\n const bbox = this.rootElement.getBBox();\n // return new TSU.Geom.Size(4 + bbox.width + bbox.x, 4 + bbox.y + bbox.height);\n return new TSU.Geom.Size(4 + bbox.width, 4 + bbox.height);\n }\n\n beatViews = new Map<number, BeatView>();\n viewForBeat(beat: Beat): BeatView {\n if (!this.beatViews.has(beat.uuid)) {\n // how to get the bar and beat index for a given beat in a given row?\n const b = new BeatView(beat, this.gElem, this.beatLayout.layoutParams.cycle);\n // Check if this needs bar start/end lines?\n this.beatViews.set(beat.uuid, b);\n return b;\n }\n return this.beatViews.get(beat.uuid)!;\n }\n}\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -231,15 +235,18 @@ var NotationView = (function () {
|
|
|
231
235
|
};
|
|
232
236
|
NotationView.prototype.renderBlock = function (raw) {
|
|
233
237
|
var _a = __read(this.addNewRow(raw.uuid + "", "rawBlock", false), 2), td2 = _a[1];
|
|
234
|
-
var div = td2.appendChild(TSU.DOM.createNode("div"));
|
|
235
238
|
if (raw.contentType == "metadata") {
|
|
236
239
|
var meta = this.notation.metadata.get(raw.content);
|
|
237
240
|
if (meta) {
|
|
238
|
-
|
|
239
|
-
|
|
241
|
+
if (meta.key.toLowerCase().indexOf(":") < 0) {
|
|
242
|
+
var div = td2.appendChild(TSU.DOM.createNode("div"));
|
|
243
|
+
var html = "<span class = \"".concat(meta.key.toLowerCase(), "\"><strong>").concat(meta.key, "</strong>: ").concat(meta.value, "</span>");
|
|
244
|
+
div.innerHTML = html;
|
|
245
|
+
}
|
|
240
246
|
}
|
|
241
247
|
}
|
|
242
248
|
else {
|
|
249
|
+
var div = td2.appendChild(TSU.DOM.createNode("div"));
|
|
243
250
|
div.innerHTML = this.markdownParser(raw.content.trim());
|
|
244
251
|
}
|
|
245
252
|
this.currentSVGElement = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,uCAAsC;AAKtC;IAYE,sBAA4B,WAAwB,EAAkB,MAAY;QAAtD,gBAAW,GAAX,WAAW,CAAa;QAAkB,WAAM,GAAN,MAAM,CAAM;QATlF,cAAS,GAAe,EAAE,CAAC;QAE3B,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;QAC9C,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC5C,sBAAiB,GAAyB,IAAI,CAAC;QAE/C,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QAItC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,8BAAO,GAAP;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,CAAC;IAED,kCAAW,GAAX,UAAY,IAAU;QACpB,IAAI,IA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AY,GAAa;QACjB,IAAA,KAAA,OAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,IAAA,EAAvD,GAAG,QAAoD,CAAC;QACjE,IAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACvD,IAAI,GAAG,CAAC,WAAW,IAAI,UAAU,EAAE;YAEjC,IAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,IAAI,EAAE;gBACR,IAAM,IAAI,GAAG,0BAAkB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,IAAI,CAAC,GAAG,wBAAc,IAAI,CAAC,KAAK,YAAS,CAAC;gBAC5G,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;aACtB;SACF;aAAM;YACL,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;SACzD;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;IACH,mBAAC;AAAD,CAAC,AAtLD,IAsLC;AAtLY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { Beat, BeatLayout, BeatView } from \"../beats\";\nimport { Line } from \"../core\";\n\nexport class NotationView {\n headerElement: HTMLDivElement;\n notation: Notation;\n lineViews: LineView[] = [];\n // Mapping from line id -> list of beats in each of its roles\n beatsByLineRole = new Map<number, Beat[][]>();\n beatLayouts = new Map<number, BeatLayout>();\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n beatViews = new Map<number, BeatView>();\n markdownParser: (contents: string) => string;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n refresh(): void {\n this.beatViews = new Map<number, BeatView>();\n }\n\n viewForBeat(beat: Beat): BeatView {\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(beat.role.line);\n curr = lineView.viewForBeat(beat);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\n }\n\n loadChildViews(): void {\n this.tableElement = TSU.DOM.createNode(\"table\", {\n parent: this.rootElement,\n attrs: {\n class: \"notationsContentRootTable\",\n },\n }) as HTMLTableElement;\n }\n\n public addNewRow(id: string, prefix: string, withAnnotation = true): [HTMLElement, HTMLElement] {\n const tr = TSU.DOM.createNode(\"tr\", {\n parent: this.tableElement, // parent,\n attrs: {\n class: prefix + \"Row\",\n id: prefix + \"Row\" + id,\n },\n });\n let td1: HTMLElement | null = null;\n if (withAnnotation) {\n td1 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"AnnotationCell\",\n id: prefix + \"Annotation\" + id,\n },\n }) as HTMLElement;\n }\n const td2 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"ContentCell\",\n id: prefix + \"Content\" + id,\n colspan: withAnnotation ? 1 : 2,\n },\n }) as HTMLElement;\n return [td1!, td2];\n }\n\n public newLineRoot(parent: Element, line: Line): SVGSVGElement {\n const [td1, td2] = this.addNewRow(line.uuid + \"\", \"line\");\n // Hacky solution to \"line headings\"\n if (line.marginText) {\n td1.innerHTML = line.marginText;\n }\n return TSU.DOM.createSVGNode(\"svg\", {\n parent: td2, // parent\n attrs: {\n style: \"margin-bottom: 10px\",\n class: \"lineRootSVG\",\n },\n }) as SVGSVGElement;\n }\n\n ensureLineView(line: Line): LineView {\n let lineView = this.getLineView(line);\n if (lineView == null) {\n const layoutParams = this.notation.layoutParamsForLine(line) || null;\n const svgElem = this.newLineRoot(this.tableElement, line);\n lineView = new LineView(svgElem, line, {\n layoutParams: layoutParams,\n } as any);\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n const beatLayout = this.beatLayouts.get(layoutParams.uuid)!;\n lineView.beatLayout = beatLayout;\n }\n lineView.beatsByLineRole = this.beatsByLineRole.get(line.uuid)!;\n this.lineViews.push(lineView);\n }\n return lineView;\n }\n\n getLineView(line: Line): TSU.Nullable<LineView> {\n return this.lineViews.find((l) => l.line == line) || null;\n }\n\n get currentLineView(): LineView {\n return this.lineViews[this.lineViews.length - 1];\n }\n\n clear(): void {\n this.lineViews = [];\n // Mapping from line id -> list of beats in each of its roles\n this.beatsByLineRole = new Map<number, Beat[][]>();\n this.beatLayouts = new Map<number, BeatLayout>();\n this.currentSVGElement = null;\n this.tableElement.innerHTML = \"\";\n this.beatViews = new Map<number, BeatView>();\n }\n\n /**\n * Layout all the blocks in the Notation along with their corresponding blocks.\n * Key thing is here is an opportunity to perform any batch rendering as needed.\n */\n refreshLayout(): void {\n const lines = [] as Line[];\n const lineViews = [] as LineView[];\n for (const block of this.notation.blocks) {\n if (block.type == \"RawBlock\") {\n // Add the markdown here\n this.renderBlock(block as RawBlock);\n } else {\n lines.push(block as Line);\n const lineView = this.renderLine(block as Line);\n lineViews.push(lineView);\n }\n }\n\n // Eval column sizes all beat layouts\n for (const bl of this.beatLayouts.values()) {\n bl.evalColumnSizes(this);\n }\n\n // now that all spacing has been calculated\n // go through all\n for (const beatView of this.beatViews.values()) {\n beatView.refreshLayout();\n }\n\n // Set line view preferred sizes\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n }\n\n renderLine(line: Line): LineView {\n const lineView = this.ensureLineView(line);\n // Layout the \"rows\" for this line - x has already been set by the\n // previous column spacing step\n if (!line.isEmpty) {\n lineView.beatLayout.layoutBeatsForLine(line, lineView.beatsByLineRole, this);\n }\n return lineView;\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n } else {\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NotationView.js","sourceRoot":"","sources":["../../../src/carnatic/NotationView.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,uCAAsC;AAKtC;IAYE,sBAA4B,WAAwB,EAAkB,MAAY;QAAtD,gBAAW,GAAX,WAAW,CAAa;QAAkB,WAAM,GAAN,MAAM,CAAM;QATlF,cAAS,GAAe,EAAE,CAAC;QAE3B,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;QAC9C,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC5C,sBAAiB,GAAyB,IAAI,CAAC;QAE/C,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;QAItC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,8BAAO,GAAP;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,CAAC;IAED,kCAAW,GAAX,UAAY,IAAU;QACpB,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACjD,IAAI,IAAI,IAAI,IAAI,EAAE;YAEhB,IAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,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C,GAAG,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,IAAI,EAAE;gBAER,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBAC3C,IAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;oBACvD,IAAM,IAAI,GAAG,0BAAkB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,wBAAa,IAAI,CAAC,GAAG,wBAAc,IAAI,CAAC,KAAK,YAAS,CAAC;oBAC5G,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;iBACtB;aACF;SACF;aAAM;YACL,IAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;YACvD,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;SACzD;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAChC,CAAC;IACH,mBAAC;AAAD,CAAC,AA1LD,IA0LC;AA1LY,oCAAY","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { LineView } from \"./LineView\";\nimport { Notation, RawBlock } from \"../notation\";\nimport { Beat, BeatLayout, BeatView } from \"../beats\";\nimport { Line } from \"../core\";\n\nexport class NotationView {\n headerElement: HTMLDivElement;\n notation: Notation;\n lineViews: LineView[] = [];\n // Mapping from line id -> list of beats in each of its roles\n beatsByLineRole = new Map<number, Beat[][]>();\n beatLayouts = new Map<number, BeatLayout>();\n currentSVGElement: SVGSVGElement | null = null;\n tableElement: HTMLTableElement;\n beatViews = new Map<number, BeatView>();\n markdownParser: (contents: string) => string;\n\n constructor(public readonly rootElement: HTMLElement, public readonly config?: any) {\n this.loadChildViews();\n }\n\n refresh(): void {\n this.beatViews = new Map<number, BeatView>();\n }\n\n viewForBeat(beat: Beat): BeatView {\n let curr = this.beatViews.get(beat.uuid) || null;\n if (curr == null) {\n // how to get the bar and beat index for a given beat in a given row?\n const lineView = this.ensureLineView(beat.role.line);\n curr = lineView.viewForBeat(beat);\n this.beatViews.set(beat.uuid, curr);\n }\n return curr;\n }\n\n loadChildViews(): void {\n this.tableElement = TSU.DOM.createNode(\"table\", {\n parent: this.rootElement,\n attrs: {\n class: \"notationsContentRootTable\",\n },\n }) as HTMLTableElement;\n }\n\n public addNewRow(id: string, prefix: string, withAnnotation = true): [HTMLElement, HTMLElement] {\n const tr = TSU.DOM.createNode(\"tr\", {\n parent: this.tableElement, // parent,\n attrs: {\n class: prefix + \"Row\",\n id: prefix + \"Row\" + id,\n },\n });\n let td1: HTMLElement | null = null;\n if (withAnnotation) {\n td1 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"AnnotationCell\",\n id: prefix + \"Annotation\" + id,\n },\n }) as HTMLElement;\n }\n const td2 = TSU.DOM.createNode(\"td\", {\n parent: tr,\n attrs: {\n class: prefix + \"ContentCell\",\n id: prefix + \"Content\" + id,\n colspan: withAnnotation ? 1 : 2,\n },\n }) as HTMLElement;\n return [td1!, td2];\n }\n\n public newLineRoot(parent: Element, line: Line): SVGSVGElement {\n const [td1, td2] = this.addNewRow(line.uuid + \"\", \"line\");\n // Hacky solution to \"line headings\"\n if (line.marginText) {\n td1.innerHTML = line.marginText;\n }\n return TSU.DOM.createSVGNode(\"svg\", {\n parent: td2, // parent\n attrs: {\n style: \"margin-bottom: 10px\",\n class: \"lineRootSVG\",\n },\n }) as SVGSVGElement;\n }\n\n ensureLineView(line: Line): LineView {\n let lineView = this.getLineView(line);\n if (lineView == null) {\n const layoutParams = this.notation.layoutParamsForLine(line) || null;\n const svgElem = this.newLineRoot(this.tableElement, line);\n lineView = new LineView(svgElem, line, {\n layoutParams: layoutParams,\n } as any);\n if (!line.isEmpty) {\n // Probably because this is an empty line and AddAtoms was not called\n TSU.assert(layoutParams != null, \"Layout params for a non empty line *should* exist\");\n const beatLayout = this.beatLayouts.get(layoutParams.uuid)!;\n lineView.beatLayout = beatLayout;\n }\n lineView.beatsByLineRole = this.beatsByLineRole.get(line.uuid)!;\n this.lineViews.push(lineView);\n }\n return lineView;\n }\n\n getLineView(line: Line): TSU.Nullable<LineView> {\n return this.lineViews.find((l) => l.line == line) || null;\n }\n\n get currentLineView(): LineView {\n return this.lineViews[this.lineViews.length - 1];\n }\n\n clear(): void {\n this.lineViews = [];\n // Mapping from line id -> list of beats in each of its roles\n this.beatsByLineRole = new Map<number, Beat[][]>();\n this.beatLayouts = new Map<number, BeatLayout>();\n this.currentSVGElement = null;\n this.tableElement.innerHTML = \"\";\n this.beatViews = new Map<number, BeatView>();\n }\n\n /**\n * Layout all the blocks in the Notation along with their corresponding blocks.\n * Key thing is here is an opportunity to perform any batch rendering as needed.\n */\n refreshLayout(): void {\n const lines = [] as Line[];\n const lineViews = [] as LineView[];\n for (const block of this.notation.blocks) {\n if (block.type == \"RawBlock\") {\n // Add the markdown here\n this.renderBlock(block as RawBlock);\n } else {\n lines.push(block as Line);\n const lineView = this.renderLine(block as Line);\n lineViews.push(lineView);\n }\n }\n\n // Eval column sizes all beat layouts\n for (const bl of this.beatLayouts.values()) {\n bl.evalColumnSizes(this);\n }\n\n // now that all spacing has been calculated\n // go through all\n for (const beatView of this.beatViews.values()) {\n beatView.refreshLayout();\n }\n\n // Set line view preferred sizes\n for (const lineView of lineViews) {\n lineView.wrapToSize();\n }\n }\n\n renderLine(line: Line): LineView {\n const lineView = this.ensureLineView(line);\n // Layout the \"rows\" for this line - x has already been set by the\n // previous column spacing step\n if (!line.isEmpty) {\n lineView.beatLayout.layoutBeatsForLine(line, lineView.beatsByLineRole, this);\n }\n return lineView;\n }\n\n renderBlock(raw: RawBlock): void {\n const [, td2] = this.addNewRow(raw.uuid + \"\", \"rawBlock\", false);\n if (raw.contentType == \"metadata\") {\n // we have a metadata block\n const meta = this.notation.metadata.get(raw.content);\n if (meta) {\n // For now ignore metadata with \":\" in the key\n if (meta.key.toLowerCase().indexOf(\":\") < 0) {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n const html = `<span class = \"${meta.key.toLowerCase()}\"><strong>${meta.key}</strong>: ${meta.value}</span>`;\n div.innerHTML = html;\n }\n }\n } else {\n const div = td2.appendChild(TSU.DOM.createNode(\"div\"));\n div.innerHTML = this.markdownParser(raw.content.trim());\n }\n this.currentSVGElement = null;\n }\n}\n"]}
|
|
@@ -27,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
};
|
|
28
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
29
|
if (k2 === undefined) k2 = k;
|
|
30
|
-
Object.
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
31
35
|
}) : (function(o, m, k, k2) {
|
|
32
36
|
if (k2 === undefined) k2 = k;
|
|
33
37
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,gCAAgF;AAChF,oCAMmB;AACnB,iDAYyB;AACzB,qCAAuC;AAEvC;IAA+B,6BAAa;IAA5C;;IAIA,CAAC;IAHC,kCAAc,GAAd,UAAe,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAA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,CAAC;aACzB;iBAAM;gBACL,IAAM,GAAG,GAAG,eAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;YACD,MAAM;QACR,KAAK,eAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC;AAvCD,wCAuCC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n\n protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.type);\n }\n out.createElements(parent);\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AACvC,gCAAgF;AAChF,oCAMmB;AACnB,iDAYyB;AACzB,qCAAuC;AAEvC;IAA+B,6BAAa;IAA5C;;IAIA,CAAC;IAHC,kCAAc,GAAd,UAAe,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;IACH,gBAAC;AAAD,CAAC,AAJD,CAA+B,kBAAa,GAI3C;AAJY,8BAAS;AAMtB;IAA2C,gCAAgB;IAA3D;QAAA,qEAmOC;QAlOC,cAAQ,GAAmB,EAAE,CAAC;QAC9B,aAAO,GAAmB,EAAE,CAAC;QAC7B,eAAS,GAAmB,EAAE,CAAC;QAC/B,gBAAU,GAAmB,EAAE,CAAC;;IA+NlC,CAAC;IAnNW,kCAAW,GAArB;QACE,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAES,qCAAc,GAAxB;QACE,IAAM,GAAG,gBAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAE,CAAC;QACzC,IAAM,UAAU,GACd,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAnB,CAAmB,EAAE,CAAC,CAAC;YACtD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OA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GAAa,CAAC;IAClB,QAAQ,IAAI,CAAC,IAAI,EAAE;QAEjB,KAAK,eAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YACnC,MAAM;QACR,KAAK,eAAQ,CAAC,QAAQ;YACpB,GAAG,GAAG,IAAI,YAAY,CAAC,IAAgB,CAAC,CAAC;YACzC,MAAM;QACR,KAAK,eAAQ,CAAC,IAAI;YAChB,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAY,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,eAAQ,CAAC,OAAO;YACnB,IAAI,iBAAiB,EAAE;gBACrB,IAAM,GAAG,GAAG,WAAI,CAAC,OAAO,CAAC,IAAY,CAAC,CAAC;gBACvC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;aACzB;iBAAM;gBACL,IAAM,GAAG,GAAG,eAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;YACD,MAAM;QACR,KAAK,eAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;KACtD;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC;AAvCD,wCAuCC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n\n protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.type != AtomType.SYLLABLE && atom.type != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.type) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.type);\n }\n out.createElements(parent);\n return out;\n}\n"]}
|
|
@@ -16,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
18
|
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
20
24
|
}) : (function(o, m, k, k2) {
|
|
21
25
|
if (k2 === undefined) k2 = k;
|
|
22
26
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../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,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;oBAC1D,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;wBAE1C,IAAM,GAAG,GAAG,IAAI,4BAAY,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;wBACnD,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;qBACvB;yBAAM;wBAEL,IAAM,GAAG,GAAG,IAAI,4BAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;wBAChD,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;qBACvB;iBACF;aACF;SACF;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,4BAAS,GAAT,UAAU,MAAW;QACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IACH,eAAC;AAAD,CAAC,AA/ED,CAA8B,qBAAY,GA+EzC;AA/EY,4BAAQ","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { AtomType } from \"../core\";\nimport { Cycle } from \"../cycle\";\nimport { BeatView as BeatViewBase, Beat } from \"../beats\";\nimport { AtomView, GroupView, Embelishment, ElementShape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class BeatView extends ElementShape<SVGGElement> implements BeatViewBase {\n private _embelishments: Embelishment[];\n atomView: AtomView;\n needsLayout = true;\n constructor(\n public readonly beat: Beat,\n public readonly rootElement: SVGGraphicsElement,\n public readonly cycle: Cycle,\n config?: any,\n ) {\n super(\n TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: \"beatView\",\n beatId: \"\" + beat.uuid,\n id: \"\" + beat.uuid,\n roleName: beat.role.name,\n layoutLine: \"\" + beat.layoutLine,\n layoutColumn: \"\" + beat.layoutColumn,\n beatIndex: \"\" + beat.index,\n },\n }),\n );\n this.atomView = createAtomView(this.element, beat.atom, beat.role.defaultToNotes);\n this.atomView.refreshLayout();\n }\n\n refreshLayout(): void {\n const newX = this.hasX ? this._x : 0;\n const newY = this.hasY ? this._y : 0;\n this.element.setAttribute(\"transform\", \"translate(\" + newX + \",\" + newY + \")\");\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n protected createEmbelishments(): Embelishment[] {\n let embelishments: Embelishment[] = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.rootElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n if (beat.beatIndex == bar.beatCount - 1) {\n // It is important that we are not just looking at the last beat of the bar\n // but also in the last \"instance\" of the beat in this bar to account for\n // kalais\n if (beat.instance == bar.instanceCount(beat.beatIndex) - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n embelishments = [emb];\n }\n }\n }\n }\n return embelishments;\n }\n\n setStyles(config: any): void {\n this.needsLayout = true;\n }\n}\n"]}
|
|
@@ -16,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
18
|
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
20
24
|
}) : (function(o, m, k, k2) {
|
|
21
25
|
if (k2 === undefined) k2 = k;
|
|
22
26
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embelishments.js","sourceRoot":"","sources":["../../../src/carnatic/embelishments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAGvC,oCAAyC;AAOzC;IAAuD,4CAAY;IACjE,kCAA4B,QAAsB;QAAlD,YACE,iBAAO,SACR;QAF2B,cAAQ,GAAR,QAAQ,CAAc;;IAElD,CAAC;IACH,+BAAC;AAAD,CAAC,AAJD,CAAuD,qBAAY,GAIlE;AAJqB,4DAAwB;AAM9C;IAAqC,mCAAwB;IAK3D,yBAA4B,QAAsB,EAAkB,IAAU;QAA9E,YACE,kBAAM,QAAQ,CAAC,SA2BhB;QA5B2B,cAAQ,GAAR,QAAQ,CAAc;QAAkB,UAAI,GAAJ,IAAI,CAAM;QAJ9E,eAAS,GAAG,CAAC,CAAC;QACd,gBAAU,GAAG,GAAG,CAAC;QAKf,IAAM,QAAQ,GAAG,KAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,KAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE;YACzC,GAAG,EAAE,QAAQ;YACb,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE;gBACL,KAAK,EAAE,KAAI,CAAC,SAAS,GAAG,CAAC,GAAG,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,KAAI,CAAC,UAAU;gBACrE,MAAM,EAAE,KAAI,CAAC,SAAS,GAAG,CAA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ACE,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,2BAAW,GAArB;QACE,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,4BAAY,GAAtB,UACE,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB;QAEhB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,6BAAa,GAAb;QACE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IACH,YAAC;AAAD,CAAC,AAvDD,CAA2B,wBAAwB,GAuDlD;AAvDY,sBAAK","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../beats\";\nimport { Embelishment } from \"../shapes\";\nimport { LeafAtomView } from \"./atomviews\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class LeafAtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends LeafAtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(public readonly noteView: LeafAtomView, public readonly note: Note) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.leafAtom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n stroke: \"black\",\n \"stroke-width\": \"1\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.dotsElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends LeafAtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(public readonly label: string, public readonly atomView: LeafAtomView) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = this.source.x - this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement, nLines = 1) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 15;\n\n refreshLayout(): void {\n // const x = this.source.width + this.barSpacing;\n // const y = 0;\n // const h = this.source.height;\n const x = this.source.x + this.source.width + this.barSpacing;\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends LeafAtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(public readonly jaaru: JaaruGamaka, public readonly atomView: LeafAtomView) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n stroke: \"black\",\n fill: \"transparent\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.glyph.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"embelishments.js","sourceRoot":"","sources":["../../../src/carnatic/embelishments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAuC;AAGvC,oCAAyC;AAOzC;IAAuD,4CAAY;IACjE,kCAA4B,QAAsB;QAAlD,YACE,iBAAO,SACR;QAF2B,cAAQ,GAAR,QAAQ,CAAc;;IAElD,CAAC;IACH,+BAAC;AAAD,CAAC,AAJD,CAAuD,qBAAY,GAIlE;AAJqB,4DAAwB;AAM9C;IAAqC,mCAAwB;IAK3D,yBAA4B,QAAsB,EAAkB,IAAU;QAA9E,YACE,kBAAM,QAAQ,CAAC,SA2BhB;QA5B2B,cAAQ,GAAR,QAAQ,C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,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7B,IAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YACxB,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC;YACnB,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;aAAM;YACL,CAAC,IAAI,EAAE,CAAC;YACR,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;QACD,OAAO,CAAC,YAAK,CAAC,cAAI,CAAC,CAAE,EAAE,YAAK,EAAE,cAAI,CAAC,cAAI,EAAE,cAAI,EAAE,CAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC;IAES,8BAAc,GAAxB;QACE,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,2BAAW,GAArB;QACE,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,4BAAY,GAAtB,UACE,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB;QAEhB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,6BAAa,GAAb;QACE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IACH,YAAC;AAAD,CAAC,AAvDD,CAA2B,wBAAwB,GAuDlD;AAvDY,sBAAK","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../beats\";\nimport { Embelishment } from \"../shapes\";\nimport { LeafAtomView } from \"./atomviews\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class LeafAtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends LeafAtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(public readonly noteView: LeafAtomView, public readonly note: Note) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.leafAtom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n stroke: \"black\",\n \"stroke-width\": \"1\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.dotsElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends LeafAtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(public readonly label: string, public readonly atomView: LeafAtomView) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = this.source.x - this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(public readonly source: BeatView, public readonly rootElement: SVGGraphicsElement, nLines = 1) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n stroke: \"black\",\n \"stroke-width\": \"1\",\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 15;\n\n refreshLayout(): void {\n // const x = this.source.width + this.barSpacing;\n // const y = 0;\n // const h = this.source.height;\n const x = this.source.x + this.source.width + this.barSpacing;\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends LeafAtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(public readonly jaaru: JaaruGamaka, public readonly atomView: LeafAtomView) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n stroke: \"black\",\n fill: \"transparent\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.glyph.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
|