EngravingRules.ts 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681
  1. import { PagePlacementEnum } from "./GraphicalMusicPage";
  2. //import {MusicSymbol} from "./MusicSymbol";
  3. import * as log from "loglevel";
  4. import { TextAlignmentEnum } from "../../Common/Enums/TextAlignment";
  5. import { PlacementEnum } from "../VoiceData/Expressions/AbstractExpression";
  6. import { AutoBeamOptions, AlignRestOption, FillEmptyMeasuresWithWholeRests } from "../../OpenSheetMusicDisplay/OSMDOptions";
  7. import { ColoringModes as ColoringMode } from "./DrawingParameters";
  8. import { Dictionary } from "typescript-collections";
  9. import { NoteEnum } from "../..";
  10. export class EngravingRules {
  11. private static rules: EngravingRules;
  12. /** A unit of distance. 1.0 is the distance between lines of a stave for OSMD, which is 10 pixels in Vexflow. */
  13. private static unit: number = 1.0;
  14. private samplingUnit: number;
  15. private staccatoShorteningFactor: number;
  16. /** Height (size) of the sheet title. */
  17. private sheetTitleHeight: number;
  18. private sheetSubtitleHeight: number;
  19. private sheetMinimumDistanceBetweenTitleAndSubtitle: number;
  20. private sheetComposerHeight: number;
  21. private sheetAuthorHeight: number;
  22. private compactMode: boolean;
  23. private pagePlacementEnum: PagePlacementEnum;
  24. private pageHeight: number;
  25. private pageTopMargin: number;
  26. private pageTopMarginNarrow: number;
  27. private pageBottomMargin: number;
  28. private pageLeftMargin: number;
  29. private pageRightMargin: number;
  30. private titleTopDistance: number;
  31. private titleBottomDistance: number;
  32. private systemLeftMargin: number;
  33. private systemRightMargin: number;
  34. private firstSystemMargin: number;
  35. private systemLabelsRightMargin: number;
  36. private systemComposerDistance: number;
  37. private instrumentLabelTextHeight: number;
  38. private minimumDistanceBetweenSystems: number;
  39. private lastSystemMaxScalingFactor: number;
  40. private staffDistance: number;
  41. private betweenStaffDistance: number;
  42. private staffHeight: number;
  43. private tabStaffHeight: number;
  44. private betweenStaffLinesDistance: number;
  45. /** Whether to automatically beam notes that don't already have beams in XML. */
  46. private autoBeamNotes: boolean;
  47. /** Options for autoBeaming like whether to beam over rests. See AutoBeamOptions interface. */
  48. private autoBeamOptions: AutoBeamOptions;
  49. private beamWidth: number;
  50. private beamSpaceWidth: number;
  51. private beamForwardLength: number;
  52. private clefLeftMargin: number;
  53. private clefRightMargin: number;
  54. private betweenKeySymbolsDistance: number;
  55. private keyRightMargin: number;
  56. private rhythmRightMargin: number;
  57. private inStaffClefScalingFactor: number;
  58. private distanceBetweenNaturalAndSymbolWhenCancelling: number;
  59. private noteHelperLinesOffset: number;
  60. private measureLeftMargin: number;
  61. private measureRightMargin: number;
  62. private distanceBetweenLastInstructionAndRepetitionBarline: number;
  63. private arpeggioDistance: number;
  64. private idealStemLength: number;
  65. private stemNoteHeadBorderYOffset: number;
  66. private stemWidth: number;
  67. private stemMargin: number;
  68. private stemMinLength: number;
  69. private stemMaxLength: number;
  70. private beamSlopeMaxAngle: number;
  71. private stemMinAllowedDistanceBetweenNoteHeadAndBeamLine: number;
  72. private setWantedStemDirectionByXml: boolean;
  73. private graceNoteScalingFactor: number;
  74. private graceNoteXOffset: number;
  75. private wedgeOpeningLength: number;
  76. private wedgeMeasureEndOpeningLength: number;
  77. private wedgeMeasureBeginOpeningLength: number;
  78. private wedgePlacementAboveY: number;
  79. private wedgePlacementBelowY: number;
  80. private wedgeHorizontalMargin: number;
  81. private wedgeVerticalMargin: number;
  82. private distanceOffsetBetweenTwoHorizontallyCrossedWedges: number;
  83. private wedgeMinLength: number;
  84. private distanceBetweenAdjacentDynamics: number;
  85. private tempoChangeMeasureValidity: number;
  86. private tempoContinousFactor: number;
  87. private staccatoScalingFactor: number;
  88. private betweenDotsDistance: number;
  89. private ornamentAccidentalScalingFactor: number;
  90. private chordSymbolTextHeight: number;
  91. private chordSymbolXSpacing: number;
  92. private chordSymbolYOffset: number;
  93. private fingeringLabelFontHeight: number;
  94. private measureNumberLabelHeight: number;
  95. private measureNumberLabelOffset: number;
  96. /** Whether tuplets should display ratio (3:2 instead of 3 for triplet). Default false. */
  97. private tupletsRatioed: boolean;
  98. /** Whether all tuplets should be bracketed (e.g. |--5--| instead of 5). Default false.
  99. * If false, only tuplets given as bracketed in XML (bracket="yes") will be bracketed.
  100. * (If not given in XML, bracketing is implementation-dependent according to standard)
  101. */
  102. private tupletsBracketed: boolean;
  103. /** Whether all triplets should be bracketed. Overrides tupletsBracketed for triplets.
  104. * If false, only triplets given as bracketed in XML (bracket="yes") will be bracketed.
  105. * (Bracketing all triplets can be cluttering)
  106. */
  107. private tripletsBracketed: boolean;
  108. private tupletNumberLabelHeight: number;
  109. private tupletNumberYOffset: number;
  110. private labelMarginBorderFactor: number;
  111. private tupletVerticalLineLength: number;
  112. private repetitionEndingLabelHeight: number;
  113. private repetitionEndingLabelXOffset: number;
  114. private repetitionEndingLabelYOffset: number;
  115. private repetitionEndingLineYLowerOffset: number;
  116. private repetitionEndingLineYUpperOffset: number;
  117. /** Default alignment of lyrics.
  118. * Left alignments will extend text to the right of the bounding box,
  119. * which facilitates spacing by extending measure width.
  120. */
  121. private lyricsAlignmentStandard: TextAlignmentEnum;
  122. private lyricsHeight: number;
  123. private lyricsYOffsetToStaffHeight: number;
  124. private verticalBetweenLyricsDistance: number;
  125. private horizontalBetweenLyricsDistance: number;
  126. private betweenSyllableMaximumDistance: number;
  127. private betweenSyllableMinimumDistance: number;
  128. private lyricOverlapAllowedIntoNextMeasure: number;
  129. private minimumDistanceBetweenDashes: number;
  130. private bezierCurveStepSize: number;
  131. private tPower3: number[];
  132. private oneMinusTPower3: number[];
  133. private factorOne: number[];
  134. private factorTwo: number[];
  135. private tieGhostObjectWidth: number;
  136. private tieYPositionOffsetFactor: number;
  137. private minimumNeededXspaceForTieGhostObject: number;
  138. private tieHeightMinimum: number;
  139. private tieHeightMaximum: number;
  140. private tieHeightInterpolationK: number;
  141. private tieHeightInterpolationD: number;
  142. private slurNoteHeadYOffset: number;
  143. private slurStemXOffset: number;
  144. private slurSlopeMaxAngle: number;
  145. private slurTangentMinAngle: number;
  146. private slurTangentMaxAngle: number;
  147. private slursStartingAtSameStaffEntryYOffset: number;
  148. private instantaneousTempoTextHeight: number;
  149. private continuousDynamicTextHeight: number;
  150. private moodTextHeight: number;
  151. private unknownTextHeight: number;
  152. private continuousTempoTextHeight: number;
  153. private staffLineWidth: number;
  154. private ledgerLineWidth: number;
  155. private wedgeLineWidth: number;
  156. private tupletLineWidth: number;
  157. private lyricUnderscoreLineWidth: number;
  158. private systemThinLineWidth: number;
  159. private systemBoldLineWidth: number;
  160. private systemRepetitionEndingLineWidth: number;
  161. private systemDotWidth: number;
  162. private distanceBetweenVerticalSystemLines: number;
  163. private distanceBetweenDotAndLine: number;
  164. private octaveShiftLineWidth: number;
  165. private octaveShiftVerticalLineLength: number;
  166. private graceLineWidth: number;
  167. private minimumStaffLineDistance: number;
  168. private minimumCrossedBeamDifferenceMargin: number;
  169. private displacedNoteMargin: number;
  170. private minNoteDistance: number;
  171. private subMeasureXSpacingThreshold: number;
  172. private measureDynamicsMaxScalingFactor: number;
  173. private wholeRestXShiftVexflow: number;
  174. private metronomeMarkXShift: number;
  175. private metronomeMarkYShift: number;
  176. private maxInstructionsConstValue: number;
  177. private noteDistances: number[] = [1.0, 1.0, 1.3, 1.6, 2.0, 2.5, 3.0, 4.0];
  178. private noteDistancesScalingFactors: number[] = [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0];
  179. private durationDistanceDict: {[_: number]: number; } = {};
  180. private durationScalingDistanceDict: {[_: number]: number; } = {};
  181. private alignRests: number; // 0 = false, 1 = true, 2 = auto
  182. private fillEmptyMeasuresWithWholeRest: FillEmptyMeasuresWithWholeRests | number;
  183. private arpeggiosGoAcrossVoices: boolean;
  184. private renderArpeggios: boolean;
  185. private renderSlurs: boolean;
  186. private coloringMode: ColoringMode;
  187. private coloringEnabled: boolean;
  188. private colorStemsLikeNoteheads: boolean;
  189. private colorFlags: boolean;
  190. private colorBeams: boolean;
  191. private coloringSetCustom: Dictionary<NoteEnum|number, string>;
  192. private defaultColorNotehead: string;
  193. private defaultColorRest: string;
  194. private defaultColorStem: string;
  195. private defaultColorLabel: string;
  196. private defaultColorTitle: string;
  197. private defaultFontFamily: string;
  198. private maxMeasureToDrawIndex: number;
  199. private minMeasureToDrawIndex: number;
  200. /** Whether to render a label for the composer of the piece at the top of the sheet. */
  201. private renderComposer: boolean;
  202. private renderTitle: boolean;
  203. private renderSubtitle: boolean;
  204. private renderLyricist: boolean;
  205. private renderPartNames: boolean;
  206. private renderPartAbbreviations: boolean;
  207. private renderFingerings: boolean;
  208. private renderMeasureNumbers: boolean;
  209. private renderLyrics: boolean;
  210. private dynamicExpressionMaxDistance: number;
  211. private dynamicExpressionSpacer: number;
  212. /** Position of fingering label in relation to corresponding note (left, right supported, above, below experimental) */
  213. private fingeringPosition: PlacementEnum;
  214. private fingeringInsideStafflines: boolean;
  215. private pageFormat: PageFormat;
  216. private pageBackgroundColor: string; // vexflow-color-string (#FFFFFF). Default undefined/transparent.
  217. private renderSingleHorizontalStaffline: boolean;
  218. private fixStafflineBoundingBox: boolean; // TODO temporary workaround
  219. constructor() {
  220. // global variables
  221. this.samplingUnit = EngravingRules.unit * 3;
  222. // Page Label Variables
  223. this.sheetTitleHeight = 4.0;
  224. this.sheetSubtitleHeight = 2.0;
  225. this.sheetMinimumDistanceBetweenTitleAndSubtitle = 1.0;
  226. this.sheetComposerHeight = 2.0;
  227. this.sheetAuthorHeight = 2.0;
  228. // Staff sizing Variables
  229. this.compactMode = false;
  230. this.pagePlacementEnum = PagePlacementEnum.Down;
  231. this.pageHeight = 100001.0;
  232. this.pageTopMargin = 5.0;
  233. this.pageTopMarginNarrow = 0.0; // for compact mode
  234. this.pageBottomMargin = 5.0;
  235. this.pageLeftMargin = 5.0;
  236. this.pageRightMargin = 5.0;
  237. this.titleTopDistance = 9.0;
  238. this.titleBottomDistance = 1.0;
  239. this.staffDistance = 7.0;
  240. this.betweenStaffDistance = 5.0;
  241. // System Sizing and Label Variables
  242. this.staffHeight = 4.0;
  243. this.tabStaffHeight = 6.67;
  244. this.betweenStaffLinesDistance = EngravingRules.unit;
  245. this.systemLeftMargin = 0.0;
  246. this.systemRightMargin = 0.0;
  247. this.firstSystemMargin = 15.0;
  248. this.systemLabelsRightMargin = 2.0;
  249. this.systemComposerDistance = 2.0;
  250. this.instrumentLabelTextHeight = 2;
  251. this.minimumDistanceBetweenSystems = 4.0;
  252. this.lastSystemMaxScalingFactor = 1.4;
  253. // autoBeam options
  254. this.autoBeamNotes = false;
  255. this.autoBeamOptions = {
  256. beam_middle_rests_only: false,
  257. beam_rests: false,
  258. maintain_stem_directions: false
  259. };
  260. // Beam Sizing Variables
  261. this.beamWidth = EngravingRules.unit / 2.0;
  262. this.beamSpaceWidth = EngravingRules.unit / 3.0;
  263. this.beamForwardLength = 1.25 * EngravingRules.unit;
  264. // Beam Sizing Variables
  265. this.clefLeftMargin = 0.5;
  266. this.clefRightMargin = 0.75;
  267. this.betweenKeySymbolsDistance = 0.2;
  268. this.keyRightMargin = 0.75;
  269. this.rhythmRightMargin = 1.25;
  270. this.inStaffClefScalingFactor = 0.8;
  271. this.distanceBetweenNaturalAndSymbolWhenCancelling = 0.4;
  272. // Beam Sizing Variables
  273. this.noteHelperLinesOffset = 0.25;
  274. this.measureLeftMargin = 0.7;
  275. this.measureRightMargin = 0.0;
  276. this.distanceBetweenLastInstructionAndRepetitionBarline = 1.0;
  277. this.arpeggioDistance = 0.6;
  278. // Stems Variables
  279. this.staccatoShorteningFactor = 2;
  280. this.idealStemLength = 3.0;
  281. this.stemNoteHeadBorderYOffset = 0.2;
  282. this.stemWidth = 0.13;
  283. this.stemMargin = 0.2;
  284. this.stemMinLength = 2.5;
  285. this.stemMaxLength = 4.5;
  286. this.beamSlopeMaxAngle = 10.0;
  287. this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine = 1.0;
  288. this.setWantedStemDirectionByXml = true;
  289. // GraceNote Variables
  290. this.graceNoteScalingFactor = 0.6;
  291. this.graceNoteXOffset = 0.2;
  292. // Wedge Variables
  293. this.wedgeOpeningLength = 1.2;
  294. this.wedgeMeasureEndOpeningLength = 0.75;
  295. this.wedgeMeasureBeginOpeningLength = 0.75;
  296. this.wedgePlacementAboveY = -1.5;
  297. this.wedgePlacementBelowY = 1.5;
  298. this.wedgeHorizontalMargin = 0.6;
  299. this.wedgeVerticalMargin = 0.5;
  300. this.distanceOffsetBetweenTwoHorizontallyCrossedWedges = 0.3;
  301. this.wedgeMinLength = 2.0;
  302. this.distanceBetweenAdjacentDynamics = 0.75;
  303. // Tempo Variables
  304. this.tempoChangeMeasureValidity = 4;
  305. this.tempoContinousFactor = 0.7;
  306. // various
  307. this.staccatoScalingFactor = 0.8;
  308. this.betweenDotsDistance = 0.8;
  309. this.ornamentAccidentalScalingFactor = 0.65;
  310. this.chordSymbolTextHeight = 2.0;
  311. this.chordSymbolXSpacing = 1.0;
  312. this.chordSymbolYOffset = 2.0;
  313. this.fingeringLabelFontHeight = 1.7;
  314. // Tuplets, MeasureNumber and TupletNumber Labels
  315. this.measureNumberLabelHeight = 1.5 * EngravingRules.unit;
  316. this.measureNumberLabelOffset = 2;
  317. this.tupletsRatioed = false;
  318. this.tupletsBracketed = false;
  319. this.tripletsBracketed = false; // special setting for triplets, overrides tuplet setting (for triplets only)
  320. this.tupletNumberLabelHeight = 1.5 * EngravingRules.unit;
  321. this.tupletNumberYOffset = 0.5;
  322. this.labelMarginBorderFactor = 0.1;
  323. this.tupletVerticalLineLength = 0.5;
  324. // Slur and Tie variables
  325. this.bezierCurveStepSize = 1000;
  326. this.calculateCurveParametersArrays();
  327. this.tieGhostObjectWidth = 0.75;
  328. this.tieYPositionOffsetFactor = 0.3;
  329. this.minimumNeededXspaceForTieGhostObject = 1.0;
  330. this.tieHeightMinimum = 0.28;
  331. this.tieHeightMaximum = 1.2;
  332. this.tieHeightInterpolationK = 0.0288;
  333. this.tieHeightInterpolationD = 0.136;
  334. this.slurNoteHeadYOffset = 0.5;
  335. this.slurStemXOffset = 0.3;
  336. this.slurSlopeMaxAngle = 15.0;
  337. this.slurTangentMinAngle = 30.0;
  338. this.slurTangentMaxAngle = 80.0;
  339. this.slursStartingAtSameStaffEntryYOffset = 0.8;
  340. // Repetitions
  341. this.repetitionEndingLabelHeight = 2.0;
  342. this.repetitionEndingLabelXOffset = 0.5;
  343. this.repetitionEndingLabelYOffset = 0.3;
  344. this.repetitionEndingLineYLowerOffset = 0.5;
  345. this.repetitionEndingLineYUpperOffset = 0.3;
  346. // Lyrics
  347. this.lyricsAlignmentStandard = TextAlignmentEnum.LeftBottom; // CenterBottom and LeftBottom tested, spacing-optimized
  348. this.lyricsHeight = 2.0; // actually size of lyrics
  349. this.lyricsYOffsetToStaffHeight = 3.0; // distance between lyrics and staff. could partly be even lower/dynamic
  350. this.verticalBetweenLyricsDistance = 0.5;
  351. this.horizontalBetweenLyricsDistance = 0.2;
  352. this.betweenSyllableMaximumDistance = 10.0;
  353. this.betweenSyllableMinimumDistance = 0.5; // + 1.0 for CenterAlignment added in lyrics spacing
  354. this.lyricOverlapAllowedIntoNextMeasure = 3.4; // optimal for dashed last lyric, see Land der Berge
  355. this.minimumDistanceBetweenDashes = 10;
  356. // expressions variables
  357. this.instantaneousTempoTextHeight = 2.3;
  358. this.continuousDynamicTextHeight = 2.3;
  359. this.moodTextHeight = 2.3;
  360. this.unknownTextHeight = 2.0;
  361. this.continuousTempoTextHeight = 2.3;
  362. this.dynamicExpressionMaxDistance = 2;
  363. this.dynamicExpressionSpacer = 0.5;
  364. // Line Widths
  365. this.staffLineWidth = 0.12;
  366. this.ledgerLineWidth = 0.12;
  367. this.wedgeLineWidth = 0.12;
  368. this.tupletLineWidth = 0.12;
  369. this.lyricUnderscoreLineWidth = 0.12;
  370. this.systemThinLineWidth = 0.12;
  371. this.systemBoldLineWidth = EngravingRules.unit / 2.0;
  372. this.systemRepetitionEndingLineWidth = 0.12;
  373. this.systemDotWidth = EngravingRules.unit / 5.0;
  374. this.distanceBetweenVerticalSystemLines = 0.35;
  375. this.distanceBetweenDotAndLine = 0.7;
  376. this.octaveShiftLineWidth = 0.12;
  377. this.octaveShiftVerticalLineLength = EngravingRules.unit;
  378. this.graceLineWidth = this.staffLineWidth * this.GraceNoteScalingFactor;
  379. // Line Widths
  380. this.minimumStaffLineDistance = 1.0;
  381. this.minimumCrossedBeamDifferenceMargin = 0.0001;
  382. // xSpacing Variables
  383. this.displacedNoteMargin = 0.1;
  384. this.minNoteDistance = 2.0;
  385. this.subMeasureXSpacingThreshold = 35;
  386. this.measureDynamicsMaxScalingFactor = 2.5;
  387. this.wholeRestXShiftVexflow = -2.5; // VexFlow draws rest notes too far to the right
  388. this.metronomeMarkXShift = -6; // our unit, is taken * unitInPixels
  389. this.metronomeMarkYShift = -0.5;
  390. // Render options (whether to render specific or invisible elements)
  391. this.alignRests = AlignRestOption.Never; // 0 = false, 1 = true, 2 = auto
  392. this.fillEmptyMeasuresWithWholeRest = FillEmptyMeasuresWithWholeRests.No;
  393. this.arpeggiosGoAcrossVoices = false; // safe option, as otherwise arpeggios will always go across all voices in Vexflow, which is often unwanted
  394. this.renderArpeggios = true;
  395. this.renderSlurs = true;
  396. this.coloringMode = ColoringMode.XML;
  397. this.coloringEnabled = true;
  398. this.colorStemsLikeNoteheads = false;
  399. this.colorBeams = true;
  400. this.colorFlags = true;
  401. this.defaultColorNotehead = "#000000"; // black. undefined is only black if a note's color hasn't been changed before.
  402. this.defaultColorRest = this.defaultColorNotehead;
  403. this.defaultColorStem = this.defaultColorNotehead;
  404. this.defaultColorLabel = this.defaultColorNotehead;
  405. this.defaultColorTitle = this.defaultColorNotehead;
  406. this.defaultFontFamily = "Times New Roman"; // what OSMD was initially optimized for
  407. this.maxMeasureToDrawIndex = Number.MAX_VALUE;
  408. this.minMeasureToDrawIndex = 0;
  409. this.renderComposer = true;
  410. this.renderTitle = true;
  411. this.renderSubtitle = true;
  412. this.renderLyricist = true;
  413. this.renderPartNames = true;
  414. this.renderPartAbbreviations = true;
  415. this.renderFingerings = true;
  416. this.renderMeasureNumbers = true;
  417. this.renderLyrics = true;
  418. this.fingeringPosition = PlacementEnum.Left; // easier to get bounding box, and safer for vertical layout
  419. this.fingeringInsideStafflines = false;
  420. this.fixStafflineBoundingBox = false; // TODO temporary workaround
  421. this.pageFormat = PageFormat.UndefinedPageFormat; // default: undefined / 'infinite' height page, using the canvas'/container's width and height
  422. this.pageBackgroundColor = undefined; // default: transparent. half-transparent white: #FFFFFF88"
  423. this.renderSingleHorizontalStaffline = false;
  424. this.populateDictionaries();
  425. try {
  426. this.maxInstructionsConstValue = this.ClefLeftMargin + this.ClefRightMargin + this.KeyRightMargin + this.RhythmRightMargin + 11;
  427. //if (FontInfo.Info !== undefined) {
  428. // this.maxInstructionsConstValue += FontInfo.Info.getBoundingBox(MusicSymbol.G_CLEF).width
  429. // + FontInfo.Info.getBoundingBox(MusicSymbol.FOUR).width
  430. // + 7 * FontInfo.Info.getBoundingBox(MusicSymbol.SHARP).width;
  431. //}
  432. } catch (ex) {
  433. log.info("EngravingRules()", ex);
  434. }
  435. }
  436. public static get Rules(): EngravingRules {
  437. return EngravingRules.rules !== undefined ? EngravingRules.rules : (EngravingRules.rules = new EngravingRules());
  438. }
  439. public get SamplingUnit(): number {
  440. return this.samplingUnit;
  441. }
  442. public get SheetTitleHeight(): number {
  443. return this.sheetTitleHeight;
  444. }
  445. public set SheetTitleHeight(value: number) {
  446. this.sheetTitleHeight = value;
  447. }
  448. public get SheetSubtitleHeight(): number {
  449. return this.sheetSubtitleHeight;
  450. }
  451. public set SheetSubtitleHeight(value: number) {
  452. this.sheetSubtitleHeight = value;
  453. }
  454. public get SheetMinimumDistanceBetweenTitleAndSubtitle(): number {
  455. return this.sheetMinimumDistanceBetweenTitleAndSubtitle;
  456. }
  457. public set SheetMinimumDistanceBetweenTitleAndSubtitle(value: number) {
  458. this.sheetMinimumDistanceBetweenTitleAndSubtitle = value;
  459. }
  460. public get SheetComposerHeight(): number {
  461. return this.sheetComposerHeight;
  462. }
  463. public set SheetComposerHeight(value: number) {
  464. this.sheetComposerHeight = value;
  465. }
  466. public get SheetAuthorHeight(): number {
  467. return this.sheetAuthorHeight;
  468. }
  469. public set SheetAuthorHeight(value: number) {
  470. this.sheetAuthorHeight = value;
  471. }
  472. public get PagePlacement(): PagePlacementEnum {
  473. return this.pagePlacementEnum;
  474. }
  475. public set PagePlacement(value: PagePlacementEnum) {
  476. this.pagePlacementEnum = value;
  477. }
  478. public get CompactMode(): boolean {
  479. return this.compactMode;
  480. }
  481. public set CompactMode(value: boolean) {
  482. this.compactMode = value;
  483. }
  484. public get PageHeight(): number {
  485. return this.pageHeight;
  486. }
  487. public set PageHeight(value: number) {
  488. this.pageHeight = value;
  489. }
  490. public get PageTopMargin(): number {
  491. return this.pageTopMargin;
  492. }
  493. public set PageTopMargin(value: number) {
  494. this.pageTopMargin = value;
  495. }
  496. public get PageTopMarginNarrow(): number {
  497. return this.pageTopMarginNarrow;
  498. }
  499. public set PageTopMarginNarrow(value: number) {
  500. this.pageTopMarginNarrow = value;
  501. }
  502. public get PageBottomMargin(): number {
  503. return this.pageBottomMargin;
  504. }
  505. public set PageBottomMargin(value: number) {
  506. this.pageBottomMargin = value;
  507. }
  508. public get PageLeftMargin(): number {
  509. return this.pageLeftMargin;
  510. }
  511. public set PageLeftMargin(value: number) {
  512. this.pageLeftMargin = value;
  513. }
  514. public get PageRightMargin(): number {
  515. return this.pageRightMargin;
  516. }
  517. public set PageRightMargin(value: number) {
  518. this.pageRightMargin = value;
  519. }
  520. public get TitleTopDistance(): number {
  521. return this.titleTopDistance;
  522. }
  523. public set TitleTopDistance(value: number) {
  524. this.titleTopDistance = value;
  525. }
  526. public get TitleBottomDistance(): number {
  527. return this.titleBottomDistance;
  528. }
  529. public set TitleBottomDistance(value: number) {
  530. this.titleBottomDistance = value;
  531. }
  532. public get SystemComposerDistance(): number {
  533. return this.systemComposerDistance;
  534. }
  535. public set SystemComposerDistance(value: number) {
  536. this.systemComposerDistance = value;
  537. }
  538. public get InstrumentLabelTextHeight(): number {
  539. return this.instrumentLabelTextHeight;
  540. }
  541. public set InstrumentLabelTextHeight(value: number) {
  542. this.instrumentLabelTextHeight = value;
  543. }
  544. public get SystemLeftMargin(): number {
  545. return this.systemLeftMargin;
  546. }
  547. public set SystemLeftMargin(value: number) {
  548. this.systemLeftMargin = value;
  549. }
  550. public get SystemRightMargin(): number {
  551. return this.systemRightMargin;
  552. }
  553. public set SystemRightMargin(value: number) {
  554. this.systemRightMargin = value;
  555. }
  556. public get FirstSystemMargin(): number {
  557. return this.firstSystemMargin;
  558. }
  559. public set FirstSystemMargin(value: number) {
  560. this.firstSystemMargin = value;
  561. }
  562. public get SystemLabelsRightMargin(): number {
  563. return this.systemLabelsRightMargin;
  564. }
  565. public set SystemLabelsRightMargin(value: number) {
  566. this.systemLabelsRightMargin = value;
  567. }
  568. public get MinimumDistanceBetweenSystems(): number {
  569. return this.minimumDistanceBetweenSystems;
  570. }
  571. public set MinimumDistanceBetweenSystems(value: number) {
  572. this.minimumDistanceBetweenSystems = value;
  573. }
  574. public get LastSystemMaxScalingFactor(): number {
  575. return this.lastSystemMaxScalingFactor;
  576. }
  577. public set LastSystemMaxScalingFactor(value: number) {
  578. this.lastSystemMaxScalingFactor = value;
  579. }
  580. public get StaffDistance(): number {
  581. return this.staffDistance;
  582. }
  583. public set StaffDistance(value: number) {
  584. this.staffDistance = value;
  585. }
  586. public get BetweenStaffDistance(): number {
  587. return this.betweenStaffDistance;
  588. }
  589. public set BetweenStaffDistance(value: number) {
  590. this.betweenStaffDistance = value;
  591. }
  592. public get StaffHeight(): number {
  593. return this.staffHeight;
  594. }
  595. public set StaffHeight(value: number) {
  596. this.staffHeight = value;
  597. }
  598. public get TabStaffHeight(): number {
  599. return this.tabStaffHeight;
  600. }
  601. public set TabStaffHeight(value: number) {
  602. this.tabStaffHeight = value;
  603. }
  604. public get BetweenStaffLinesDistance(): number {
  605. return this.betweenStaffLinesDistance;
  606. }
  607. public set BetweenStaffLinesDistance(value: number) {
  608. this.betweenStaffLinesDistance = value;
  609. }
  610. public get AutoBeamNotes(): boolean {
  611. return this.autoBeamNotes;
  612. }
  613. public set AutoBeamNotes(value: boolean) {
  614. this.autoBeamNotes = value;
  615. }
  616. public get AutoBeamOptions(): AutoBeamOptions {
  617. return this.autoBeamOptions;
  618. }
  619. public set AutoBeamOptions(value: AutoBeamOptions) {
  620. this.autoBeamOptions = value;
  621. }
  622. public get BeamWidth(): number {
  623. return this.beamWidth;
  624. }
  625. public set BeamWidth(value: number) {
  626. this.beamWidth = value;
  627. }
  628. public get BeamSpaceWidth(): number {
  629. return this.beamSpaceWidth;
  630. }
  631. public set BeamSpaceWidth(value: number) {
  632. this.beamSpaceWidth = value;
  633. }
  634. public get BeamForwardLength(): number {
  635. return this.beamForwardLength;
  636. }
  637. public set BeamForwardLength(value: number) {
  638. this.beamForwardLength = value;
  639. }
  640. public get BetweenKeySymbolsDistance(): number {
  641. return this.betweenKeySymbolsDistance;
  642. }
  643. public set BetweenKeySymbolsDistance(value: number) {
  644. this.betweenKeySymbolsDistance = value;
  645. }
  646. public get ClefLeftMargin(): number {
  647. return this.clefLeftMargin;
  648. }
  649. public set ClefLeftMargin(value: number) {
  650. this.clefLeftMargin = value;
  651. }
  652. public get ClefRightMargin(): number {
  653. return this.clefRightMargin;
  654. }
  655. public set ClefRightMargin(value: number) {
  656. this.clefRightMargin = value;
  657. }
  658. public get KeyRightMargin(): number {
  659. return this.keyRightMargin;
  660. }
  661. public set KeyRightMargin(value: number) {
  662. this.keyRightMargin = value;
  663. }
  664. public get RhythmRightMargin(): number {
  665. return this.rhythmRightMargin;
  666. }
  667. public set RhythmRightMargin(value: number) {
  668. this.rhythmRightMargin = value;
  669. }
  670. public get InStaffClefScalingFactor(): number {
  671. return this.inStaffClefScalingFactor;
  672. }
  673. public set InStaffClefScalingFactor(value: number) {
  674. this.inStaffClefScalingFactor = value;
  675. }
  676. public get DistanceBetweenNaturalAndSymbolWhenCancelling(): number {
  677. return this.distanceBetweenNaturalAndSymbolWhenCancelling;
  678. }
  679. public set DistanceBetweenNaturalAndSymbolWhenCancelling(value: number) {
  680. this.distanceBetweenNaturalAndSymbolWhenCancelling = value;
  681. }
  682. public get NoteHelperLinesOffset(): number {
  683. return this.noteHelperLinesOffset;
  684. }
  685. public set NoteHelperLinesOffset(value: number) {
  686. this.noteHelperLinesOffset = value;
  687. }
  688. public get MeasureLeftMargin(): number {
  689. return this.measureLeftMargin;
  690. }
  691. public set MeasureLeftMargin(value: number) {
  692. this.measureLeftMargin = value;
  693. }
  694. public get MeasureRightMargin(): number {
  695. return this.measureRightMargin;
  696. }
  697. public set MeasureRightMargin(value: number) {
  698. this.measureRightMargin = value;
  699. }
  700. public get DistanceBetweenLastInstructionAndRepetitionBarline(): number {
  701. return this.distanceBetweenLastInstructionAndRepetitionBarline;
  702. }
  703. public set DistanceBetweenLastInstructionAndRepetitionBarline(value: number) {
  704. this.distanceBetweenLastInstructionAndRepetitionBarline = value;
  705. }
  706. public get ArpeggioDistance(): number {
  707. return this.arpeggioDistance;
  708. }
  709. public set ArpeggioDistance(value: number) {
  710. this.arpeggioDistance = value;
  711. }
  712. public get StaccatoShorteningFactor(): number {
  713. return this.staccatoShorteningFactor;
  714. }
  715. public set StaccatoShorteningFactor(value: number) {
  716. this.staccatoShorteningFactor = value;
  717. }
  718. public get IdealStemLength(): number {
  719. return this.idealStemLength;
  720. }
  721. public set IdealStemLength(value: number) {
  722. this.idealStemLength = value;
  723. }
  724. public get StemNoteHeadBorderYOffset(): number {
  725. return this.stemNoteHeadBorderYOffset;
  726. }
  727. public set StemNoteHeadBorderYOffset(value: number) {
  728. this.stemNoteHeadBorderYOffset = value;
  729. }
  730. public get StemWidth(): number {
  731. return this.stemWidth;
  732. }
  733. public set StemWidth(value: number) {
  734. this.stemWidth = value;
  735. }
  736. public get StemMargin(): number {
  737. return this.stemMargin;
  738. }
  739. public set StemMargin(value: number) {
  740. this.stemMargin = value;
  741. }
  742. public get StemMinLength(): number {
  743. return this.stemMinLength;
  744. }
  745. public set StemMinLength(value: number) {
  746. this.stemMinLength = value;
  747. }
  748. public get StemMaxLength(): number {
  749. return this.stemMaxLength;
  750. }
  751. public set StemMaxLength(value: number) {
  752. this.stemMaxLength = value;
  753. }
  754. public get BeamSlopeMaxAngle(): number {
  755. return this.beamSlopeMaxAngle;
  756. }
  757. public set BeamSlopeMaxAngle(value: number) {
  758. this.beamSlopeMaxAngle = value;
  759. }
  760. public get StemMinAllowedDistanceBetweenNoteHeadAndBeamLine(): number {
  761. return this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine;
  762. }
  763. public set StemMinAllowedDistanceBetweenNoteHeadAndBeamLine(value: number) {
  764. this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine = value;
  765. }
  766. public get SetWantedStemDirectionByXml(): boolean {
  767. return this.setWantedStemDirectionByXml;
  768. }
  769. public set SetWantedStemDirectionByXml(value: boolean) {
  770. this.setWantedStemDirectionByXml = value;
  771. }
  772. public get GraceNoteScalingFactor(): number {
  773. return this.graceNoteScalingFactor;
  774. }
  775. public set GraceNoteScalingFactor(value: number) {
  776. this.graceNoteScalingFactor = value;
  777. }
  778. public get GraceNoteXOffset(): number {
  779. return this.graceNoteXOffset;
  780. }
  781. public set GraceNoteXOffset(value: number) {
  782. this.graceNoteXOffset = value;
  783. }
  784. public get WedgeOpeningLength(): number {
  785. return this.wedgeOpeningLength;
  786. }
  787. public set WedgeOpeningLength(value: number) {
  788. this.wedgeOpeningLength = value;
  789. }
  790. public get WedgeMeasureEndOpeningLength(): number {
  791. return this.wedgeMeasureEndOpeningLength;
  792. }
  793. public set WedgeMeasureEndOpeningLength(value: number) {
  794. this.wedgeMeasureEndOpeningLength = value;
  795. }
  796. public get WedgeMeasureBeginOpeningLength(): number {
  797. return this.wedgeMeasureBeginOpeningLength;
  798. }
  799. public set WedgeMeasureBeginOpeningLength(value: number) {
  800. this.wedgeMeasureBeginOpeningLength = value;
  801. }
  802. public get WedgePlacementAboveY(): number {
  803. return this.wedgePlacementAboveY;
  804. }
  805. public set WedgePlacementAboveY(value: number) {
  806. this.wedgePlacementAboveY = value;
  807. }
  808. public get WedgePlacementBelowY(): number {
  809. return this.wedgePlacementBelowY;
  810. }
  811. public set WedgePlacementBelowY(value: number) {
  812. this.wedgePlacementBelowY = value;
  813. }
  814. public get WedgeHorizontalMargin(): number {
  815. return this.wedgeHorizontalMargin;
  816. }
  817. public set WedgeHorizontalMargin(value: number) {
  818. this.wedgeHorizontalMargin = value;
  819. }
  820. public get WedgeVerticalMargin(): number {
  821. return this.wedgeVerticalMargin;
  822. }
  823. public set WedgeVerticalMargin(value: number) {
  824. this.wedgeVerticalMargin = value;
  825. }
  826. public get DistanceOffsetBetweenTwoHorizontallyCrossedWedges(): number {
  827. return this.distanceOffsetBetweenTwoHorizontallyCrossedWedges;
  828. }
  829. public set DistanceOffsetBetweenTwoHorizontallyCrossedWedges(value: number) {
  830. this.distanceOffsetBetweenTwoHorizontallyCrossedWedges = value;
  831. }
  832. public get WedgeMinLength(): number {
  833. return this.wedgeMinLength;
  834. }
  835. public set WedgeMinLength(value: number) {
  836. this.wedgeMinLength = value;
  837. }
  838. public get DistanceBetweenAdjacentDynamics(): number {
  839. return this.distanceBetweenAdjacentDynamics;
  840. }
  841. public set DistanceBetweenAdjacentDynamics(value: number) {
  842. this.distanceBetweenAdjacentDynamics = value;
  843. }
  844. public get TempoChangeMeasureValidity(): number {
  845. return this.tempoChangeMeasureValidity;
  846. }
  847. public set TempoChangeMeasureValidity(value: number) {
  848. this.tempoChangeMeasureValidity = value;
  849. }
  850. public get TempoContinousFactor(): number {
  851. return this.tempoContinousFactor;
  852. }
  853. public set TempoContinousFactor(value: number) {
  854. this.tempoContinousFactor = value;
  855. }
  856. public get StaccatoScalingFactor(): number {
  857. return this.staccatoScalingFactor;
  858. }
  859. public set StaccatoScalingFactor(value: number) {
  860. this.staccatoScalingFactor = value;
  861. }
  862. public get BetweenDotsDistance(): number {
  863. return this.betweenDotsDistance;
  864. }
  865. public set BetweenDotsDistance(value: number) {
  866. this.betweenDotsDistance = value;
  867. }
  868. public get OrnamentAccidentalScalingFactor(): number {
  869. return this.ornamentAccidentalScalingFactor;
  870. }
  871. public set OrnamentAccidentalScalingFactor(value: number) {
  872. this.ornamentAccidentalScalingFactor = value;
  873. }
  874. public get ChordSymbolTextHeight(): number {
  875. return this.chordSymbolTextHeight;
  876. }
  877. public set ChordSymbolTextHeight(value: number) {
  878. this.chordSymbolTextHeight = value;
  879. }
  880. public get ChordSymbolXSpacing(): number {
  881. return this.chordSymbolXSpacing;
  882. }
  883. public set ChordSymbolXSpacing(value: number) {
  884. this.chordSymbolXSpacing = value;
  885. }
  886. public get ChordSymbolYOffset(): number {
  887. return this.chordSymbolYOffset;
  888. }
  889. public set ChordSymbolYOffset(value: number) {
  890. this.chordSymbolYOffset = value;
  891. }
  892. public get FingeringLabelFontHeight(): number {
  893. return this.fingeringLabelFontHeight;
  894. }
  895. public set FingeringLabelFontHeight(value: number) {
  896. this.fingeringLabelFontHeight = value;
  897. }
  898. public get MeasureNumberLabelHeight(): number {
  899. return this.measureNumberLabelHeight;
  900. }
  901. public set MeasureNumberLabelHeight(value: number) {
  902. this.measureNumberLabelHeight = value;
  903. }
  904. public get MeasureNumberLabelOffset(): number {
  905. return this.measureNumberLabelOffset;
  906. }
  907. public set MeasureNumberLabelOffset(value: number) {
  908. this.measureNumberLabelOffset = value;
  909. }
  910. public get TupletsRatioed(): boolean {
  911. return this.tupletsRatioed;
  912. }
  913. public set TupletsRatioed(value: boolean) {
  914. this.tupletsRatioed = value;
  915. }
  916. public get TupletsBracketed(): boolean {
  917. return this.tupletsBracketed;
  918. }
  919. public set TupletsBracketed(value: boolean) {
  920. this.tupletsBracketed = value;
  921. }
  922. public get TripletsBracketed(): boolean {
  923. return this.tripletsBracketed;
  924. }
  925. public set TripletsBracketed(value: boolean) {
  926. this.tripletsBracketed = value;
  927. }
  928. public get TupletNumberLabelHeight(): number {
  929. return this.tupletNumberLabelHeight;
  930. }
  931. public set TupletNumberLabelHeight(value: number) {
  932. this.tupletNumberLabelHeight = value;
  933. }
  934. public get TupletNumberYOffset(): number {
  935. return this.tupletNumberYOffset;
  936. }
  937. public set TupletNumberYOffset(value: number) {
  938. this.tupletNumberYOffset = value;
  939. }
  940. public get LabelMarginBorderFactor(): number {
  941. return this.labelMarginBorderFactor;
  942. }
  943. public set LabelMarginBorderFactor(value: number) {
  944. this.labelMarginBorderFactor = value;
  945. }
  946. public get TupletVerticalLineLength(): number {
  947. return this.tupletVerticalLineLength;
  948. }
  949. public set TupletVerticalLineLength(value: number) {
  950. this.tupletVerticalLineLength = value;
  951. }
  952. public get RepetitionEndingLabelHeight(): number {
  953. return this.repetitionEndingLabelHeight;
  954. }
  955. public set RepetitionEndingLabelHeight(value: number) {
  956. this.repetitionEndingLabelHeight = value;
  957. }
  958. public get RepetitionEndingLabelXOffset(): number {
  959. return this.repetitionEndingLabelXOffset;
  960. }
  961. public set RepetitionEndingLabelXOffset(value: number) {
  962. this.repetitionEndingLabelXOffset = value;
  963. }
  964. public get RepetitionEndingLabelYOffset(): number {
  965. return this.repetitionEndingLabelYOffset;
  966. }
  967. public set RepetitionEndingLabelYOffset(value: number) {
  968. this.repetitionEndingLabelYOffset = value;
  969. }
  970. public get RepetitionEndingLineYLowerOffset(): number {
  971. return this.repetitionEndingLineYLowerOffset;
  972. }
  973. public set RepetitionEndingLineYLowerOffset(value: number) {
  974. this.repetitionEndingLineYLowerOffset = value;
  975. }
  976. public get RepetitionEndingLineYUpperOffset(): number {
  977. return this.repetitionEndingLineYUpperOffset;
  978. }
  979. public set RepetitionEndingLineYUpperOffset(value: number) {
  980. this.repetitionEndingLineYUpperOffset = value;
  981. }
  982. public get LyricsAlignmentStandard(): TextAlignmentEnum {
  983. return this.lyricsAlignmentStandard;
  984. }
  985. public set LyricsAlignmentStandard(value: TextAlignmentEnum) {
  986. this.lyricsAlignmentStandard = value;
  987. }
  988. public get LyricsHeight(): number {
  989. return this.lyricsHeight;
  990. }
  991. public set LyricsHeight(value: number) {
  992. this.lyricsHeight = value;
  993. }
  994. public get LyricsYOffsetToStaffHeight(): number {
  995. return this.lyricsYOffsetToStaffHeight;
  996. }
  997. public set LyricsYOffsetToStaffHeight(value: number) {
  998. this.lyricsYOffsetToStaffHeight = value;
  999. }
  1000. public get VerticalBetweenLyricsDistance(): number {
  1001. return this.verticalBetweenLyricsDistance;
  1002. }
  1003. public set VerticalBetweenLyricsDistance(value: number) {
  1004. this.verticalBetweenLyricsDistance = value;
  1005. }
  1006. public get HorizontalBetweenLyricsDistance(): number {
  1007. return this.horizontalBetweenLyricsDistance;
  1008. }
  1009. public set HorizontalBetweenLyricsDistance(value: number) {
  1010. this.horizontalBetweenLyricsDistance = value;
  1011. }
  1012. public get BetweenSyllableMaximumDistance(): number {
  1013. return this.betweenSyllableMaximumDistance;
  1014. }
  1015. public set BetweenSyllableMaximumDistance(value: number) {
  1016. this.betweenSyllableMaximumDistance = value;
  1017. }
  1018. public get BetweenSyllableMinimumDistance(): number {
  1019. return this.betweenSyllableMinimumDistance;
  1020. }
  1021. public set BetweenSyllableMinimumDistance(value: number) {
  1022. this.betweenSyllableMinimumDistance = value;
  1023. }
  1024. public get LyricOverlapAllowedIntoNextMeasure(): number {
  1025. return this.lyricOverlapAllowedIntoNextMeasure;
  1026. }
  1027. public set LyricOverlapAllowedIntoNextMeasure(value: number) {
  1028. this.lyricOverlapAllowedIntoNextMeasure = value;
  1029. }
  1030. public get MinimumDistanceBetweenDashes(): number {
  1031. return this.minimumDistanceBetweenDashes;
  1032. }
  1033. public set MinimumDistanceBetweenDashes(value: number) {
  1034. this.minimumDistanceBetweenDashes = value;
  1035. }
  1036. public get BezierCurveStepSize(): number {
  1037. return this.bezierCurveStepSize;
  1038. }
  1039. public set BezierCurveStepSize(value: number) {
  1040. this.bezierCurveStepSize = value;
  1041. }
  1042. public get TPow3(): number[] {
  1043. return this.tPower3;
  1044. }
  1045. public set TPow3(value: number[]) {
  1046. this.tPower3 = value;
  1047. }
  1048. public get OneMinusTPow3(): number[] {
  1049. return this.oneMinusTPower3;
  1050. }
  1051. public set OneMinusTPow3(value: number[]) {
  1052. this.oneMinusTPower3 = value;
  1053. }
  1054. public get BezierFactorOne(): number[] {
  1055. return this.factorOne;
  1056. }
  1057. public set BezierFactorOne(value: number[]) {
  1058. this.factorOne = value;
  1059. }
  1060. public get BezierFactorTwo(): number[] {
  1061. return this.factorTwo;
  1062. }
  1063. public set BezierFactorTwo(value: number[]) {
  1064. this.factorTwo = value;
  1065. }
  1066. public get TieGhostObjectWidth(): number {
  1067. return this.tieGhostObjectWidth;
  1068. }
  1069. public set TieGhostObjectWidth(value: number) {
  1070. this.tieGhostObjectWidth = value;
  1071. }
  1072. public get TieYPositionOffsetFactor(): number {
  1073. return this.tieYPositionOffsetFactor;
  1074. }
  1075. public set TieYPositionOffsetFactor(value: number) {
  1076. this.tieYPositionOffsetFactor = value;
  1077. }
  1078. public get MinimumNeededXspaceForTieGhostObject(): number {
  1079. return this.minimumNeededXspaceForTieGhostObject;
  1080. }
  1081. public set MinimumNeededXspaceForTieGhostObject(value: number) {
  1082. this.minimumNeededXspaceForTieGhostObject = value;
  1083. }
  1084. public get TieHeightMinimum(): number {
  1085. return this.tieHeightMinimum;
  1086. }
  1087. public set TieHeightMinimum(value: number) {
  1088. this.tieHeightMinimum = value;
  1089. }
  1090. public get TieHeightMaximum(): number {
  1091. return this.tieHeightMaximum;
  1092. }
  1093. public set TieHeightMaximum(value: number) {
  1094. this.tieHeightMaximum = value;
  1095. }
  1096. public get TieHeightInterpolationK(): number {
  1097. return this.tieHeightInterpolationK;
  1098. }
  1099. public set TieHeightInterpolationK(value: number) {
  1100. this.tieHeightInterpolationK = value;
  1101. }
  1102. public get TieHeightInterpolationD(): number {
  1103. return this.tieHeightInterpolationD;
  1104. }
  1105. public set TieHeightInterpolationD(value: number) {
  1106. this.tieHeightInterpolationD = value;
  1107. }
  1108. public get SlurNoteHeadYOffset(): number {
  1109. return this.slurNoteHeadYOffset;
  1110. }
  1111. public set SlurNoteHeadYOffset(value: number) {
  1112. this.slurNoteHeadYOffset = value;
  1113. }
  1114. public get SlurStemXOffset(): number {
  1115. return this.slurStemXOffset;
  1116. }
  1117. public set SlurStemXOffset(value: number) {
  1118. this.slurStemXOffset = value;
  1119. }
  1120. public get SlurSlopeMaxAngle(): number {
  1121. return this.slurSlopeMaxAngle;
  1122. }
  1123. public set SlurSlopeMaxAngle(value: number) {
  1124. this.slurSlopeMaxAngle = value;
  1125. }
  1126. public get SlurTangentMinAngle(): number {
  1127. return this.slurTangentMinAngle;
  1128. }
  1129. public set SlurTangentMinAngle(value: number) {
  1130. this.slurTangentMinAngle = value;
  1131. }
  1132. public get SlurTangentMaxAngle(): number {
  1133. return this.slurTangentMaxAngle;
  1134. }
  1135. public set SlurTangentMaxAngle(value: number) {
  1136. this.slurTangentMaxAngle = value;
  1137. }
  1138. public get SlursStartingAtSameStaffEntryYOffset(): number {
  1139. return this.slursStartingAtSameStaffEntryYOffset;
  1140. }
  1141. public set SlursStartingAtSameStaffEntryYOffset(value: number) {
  1142. this.slursStartingAtSameStaffEntryYOffset = value;
  1143. }
  1144. public get InstantaneousTempoTextHeight(): number {
  1145. return this.instantaneousTempoTextHeight;
  1146. }
  1147. public set InstantaneousTempoTextHeight(value: number) {
  1148. this.instantaneousTempoTextHeight = value;
  1149. }
  1150. public get ContinuousDynamicTextHeight(): number {
  1151. return this.continuousDynamicTextHeight;
  1152. }
  1153. public set ContinuousDynamicTextHeight(value: number) {
  1154. this.continuousDynamicTextHeight = value;
  1155. }
  1156. public get MoodTextHeight(): number {
  1157. return this.moodTextHeight;
  1158. }
  1159. public set MoodTextHeight(value: number) {
  1160. this.moodTextHeight = value;
  1161. }
  1162. public get ContinuousTempoTextHeight(): number {
  1163. return this.continuousTempoTextHeight;
  1164. }
  1165. public set ContinuousTempoTextHeight(value: number) {
  1166. this.continuousTempoTextHeight = value;
  1167. }
  1168. /** Distance of expressions inside a group */
  1169. public get DynamicExpressionMaxDistance(): number {
  1170. return this.dynamicExpressionMaxDistance;
  1171. }
  1172. public set DynamicExpressionMaxDistance(value: number) {
  1173. this.dynamicExpressionMaxDistance = value;
  1174. }
  1175. /** Space between expressions in a group */
  1176. public get DynamicExpressionSpacer(): number {
  1177. return this.dynamicExpressionSpacer;
  1178. }
  1179. public set DynamicExpressionSpacer(value: number) {
  1180. this.dynamicExpressionSpacer = value;
  1181. }
  1182. public get UnknownTextHeight(): number {
  1183. return this.unknownTextHeight;
  1184. }
  1185. public set UnknownTextHeight(value: number) {
  1186. this.unknownTextHeight = value;
  1187. }
  1188. public get StaffLineWidth(): number {
  1189. return this.staffLineWidth;
  1190. }
  1191. public set StaffLineWidth(value: number) {
  1192. this.staffLineWidth = value;
  1193. }
  1194. public get LedgerLineWidth(): number {
  1195. return this.ledgerLineWidth;
  1196. }
  1197. public set LedgerLineWidth(value: number) {
  1198. this.ledgerLineWidth = value;
  1199. }
  1200. public get WedgeLineWidth(): number {
  1201. return this.wedgeLineWidth;
  1202. }
  1203. public set WedgeLineWidth(value: number) {
  1204. this.wedgeLineWidth = value;
  1205. }
  1206. public get TupletLineWidth(): number {
  1207. return this.tupletLineWidth;
  1208. }
  1209. public set TupletLineWidth(value: number) {
  1210. this.tupletLineWidth = value;
  1211. }
  1212. public get LyricUnderscoreLineWidth(): number {
  1213. return this.lyricUnderscoreLineWidth;
  1214. }
  1215. public set LyricUnderscoreLineWidth(value: number) {
  1216. this.lyricUnderscoreLineWidth = value;
  1217. }
  1218. public get SystemThinLineWidth(): number {
  1219. return this.systemThinLineWidth;
  1220. }
  1221. public set SystemThinLineWidth(value: number) {
  1222. this.systemThinLineWidth = value;
  1223. }
  1224. public get SystemBoldLineWidth(): number {
  1225. return this.systemBoldLineWidth;
  1226. }
  1227. public set SystemBoldLineWidth(value: number) {
  1228. this.systemBoldLineWidth = value;
  1229. }
  1230. public get SystemRepetitionEndingLineWidth(): number {
  1231. return this.systemRepetitionEndingLineWidth;
  1232. }
  1233. public set SystemRepetitionEndingLineWidth(value: number) {
  1234. this.systemRepetitionEndingLineWidth = value;
  1235. }
  1236. public get SystemDotWidth(): number {
  1237. return this.systemDotWidth;
  1238. }
  1239. public set SystemDotWidth(value: number) {
  1240. this.systemDotWidth = value;
  1241. }
  1242. public get DistanceBetweenVerticalSystemLines(): number {
  1243. return this.distanceBetweenVerticalSystemLines;
  1244. }
  1245. public set DistanceBetweenVerticalSystemLines(value: number) {
  1246. this.distanceBetweenVerticalSystemLines = value;
  1247. }
  1248. public get DistanceBetweenDotAndLine(): number {
  1249. return this.distanceBetweenDotAndLine;
  1250. }
  1251. public set DistanceBetweenDotAndLine(value: number) {
  1252. this.distanceBetweenDotAndLine = value;
  1253. }
  1254. public get OctaveShiftLineWidth(): number {
  1255. return this.octaveShiftLineWidth;
  1256. }
  1257. public set OctaveShiftLineWidth(value: number) {
  1258. this.octaveShiftLineWidth = value;
  1259. }
  1260. public get OctaveShiftVerticalLineLength(): number {
  1261. return this.octaveShiftVerticalLineLength;
  1262. }
  1263. public set OctaveShiftVerticalLineLength(value: number) {
  1264. this.octaveShiftVerticalLineLength = value;
  1265. }
  1266. public get GraceLineWidth(): number {
  1267. return this.graceLineWidth;
  1268. }
  1269. public set GraceLineWidth(value: number) {
  1270. this.graceLineWidth = value;
  1271. }
  1272. public get MinimumStaffLineDistance(): number {
  1273. return this.minimumStaffLineDistance;
  1274. }
  1275. public set MinimumStaffLineDistance(value: number) {
  1276. this.minimumStaffLineDistance = value;
  1277. }
  1278. public get MinimumCrossedBeamDifferenceMargin(): number {
  1279. return this.minimumCrossedBeamDifferenceMargin;
  1280. }
  1281. public set MinimumCrossedBeamDifferenceMargin(value: number) {
  1282. this.minimumCrossedBeamDifferenceMargin = value;
  1283. }
  1284. public get DisplacedNoteMargin(): number {
  1285. return this.displacedNoteMargin;
  1286. }
  1287. public set DisplacedNoteMargin(value: number) {
  1288. this.displacedNoteMargin = value;
  1289. }
  1290. public get MinNoteDistance(): number {
  1291. return this.minNoteDistance;
  1292. }
  1293. public set MinNoteDistance(value: number) {
  1294. this.minNoteDistance = value;
  1295. }
  1296. public get SubMeasureXSpacingThreshold(): number {
  1297. return this.subMeasureXSpacingThreshold;
  1298. }
  1299. public set SubMeasureXSpacingThreshold(value: number) {
  1300. this.subMeasureXSpacingThreshold = value;
  1301. }
  1302. public get MeasureDynamicsMaxScalingFactor(): number {
  1303. return this.measureDynamicsMaxScalingFactor;
  1304. }
  1305. public set MeasureDynamicsMaxScalingFactor(value: number) {
  1306. this.measureDynamicsMaxScalingFactor = value;
  1307. }
  1308. public get WholeRestXShiftVexflow(): number {
  1309. return this.wholeRestXShiftVexflow;
  1310. }
  1311. public set WholeRestXShiftVexflow(value: number) {
  1312. this.wholeRestXShiftVexflow = value;
  1313. }
  1314. public get MetronomeMarkXShift(): number {
  1315. return this.metronomeMarkXShift;
  1316. }
  1317. public set MetronomeMarkXShift(value: number) {
  1318. this.metronomeMarkXShift = value;
  1319. }
  1320. public get MetronomeMarkYShift(): number {
  1321. return this.metronomeMarkYShift;
  1322. }
  1323. public set MetronomeMarkYShift(value: number) {
  1324. this.metronomeMarkYShift = value;
  1325. }
  1326. public get MaxInstructionsConstValue(): number {
  1327. return this.maxInstructionsConstValue;
  1328. }
  1329. public set MaxInstructionsConstValue(value: number) {
  1330. this.maxInstructionsConstValue = value;
  1331. }
  1332. public get NoteDistances(): number[] {
  1333. return this.noteDistances;
  1334. }
  1335. public set NoteDistances(value: number[]) {
  1336. this.noteDistances = value;
  1337. }
  1338. public get NoteDistancesScalingFactors(): number[] {
  1339. return this.noteDistancesScalingFactors;
  1340. }
  1341. public set NoteDistancesScalingFactors(value: number[]) {
  1342. this.noteDistancesScalingFactors = value;
  1343. }
  1344. public get DurationDistanceDict(): {[_: number]: number; } {
  1345. return this.durationDistanceDict;
  1346. }
  1347. public get DurationScalingDistanceDict(): {[_: number]: number; } {
  1348. return this.durationScalingDistanceDict;
  1349. }
  1350. public get AlignRests(): number {
  1351. return this.alignRests;
  1352. }
  1353. public set AlignRests(value: number) {
  1354. this.alignRests = value;
  1355. }
  1356. public get FillEmptyMeasuresWithWholeRest(): FillEmptyMeasuresWithWholeRests | number {
  1357. return this.fillEmptyMeasuresWithWholeRest;
  1358. }
  1359. public set FillEmptyMeasuresWithWholeRest(value: FillEmptyMeasuresWithWholeRests | number) {
  1360. this.fillEmptyMeasuresWithWholeRest = value;
  1361. }
  1362. public get ArpeggiosGoAcrossVoices(): boolean {
  1363. return this.arpeggiosGoAcrossVoices;
  1364. }
  1365. public set ArpeggiosGoAcrossVoices(value: boolean) {
  1366. this.arpeggiosGoAcrossVoices = value;
  1367. }
  1368. public get RenderArpeggios(): boolean {
  1369. return this.renderArpeggios;
  1370. }
  1371. public set RenderArpeggios(value: boolean) {
  1372. this.renderArpeggios = value;
  1373. }
  1374. public get RenderSlurs(): boolean {
  1375. return this.renderSlurs;
  1376. }
  1377. public set RenderSlurs(value: boolean) {
  1378. this.renderSlurs = value;
  1379. }
  1380. public get ColoringMode(): ColoringMode {
  1381. return this.coloringMode;
  1382. }
  1383. public set ColoringMode(value: ColoringMode) {
  1384. this.coloringMode = value;
  1385. }
  1386. public get ColoringEnabled(): boolean {
  1387. return this.coloringEnabled;
  1388. }
  1389. public set ColoringEnabled(value: boolean) {
  1390. this.coloringEnabled = value;
  1391. }
  1392. public get ColorStemsLikeNoteheads(): boolean {
  1393. return this.colorStemsLikeNoteheads;
  1394. }
  1395. public set ColorStemsLikeNoteheads(value: boolean) {
  1396. this.colorStemsLikeNoteheads = value;
  1397. }
  1398. public get ColorFlags(): boolean {
  1399. return this.colorFlags;
  1400. }
  1401. public set ColorFlags(value: boolean) {
  1402. this.colorFlags = value;
  1403. }
  1404. public get ColorBeams(): boolean {
  1405. return this.colorBeams;
  1406. }
  1407. public set ColorBeams(value: boolean) {
  1408. this.colorBeams = value;
  1409. }
  1410. public get ColoringSetCurrent(): Dictionary<NoteEnum|number, string> {
  1411. return this.coloringSetCustom;
  1412. }
  1413. public set ColoringSetCurrent(value: Dictionary<NoteEnum|number, string>) {
  1414. this.coloringSetCustom = value;
  1415. }
  1416. public get DefaultColorNotehead(): string {
  1417. return this.defaultColorNotehead;
  1418. }
  1419. public set DefaultColorNotehead(value: string) {
  1420. this.defaultColorNotehead = value;
  1421. }
  1422. public get DefaultColorRest(): string {
  1423. return this.defaultColorRest;
  1424. }
  1425. public set DefaultColorRest(value: string) {
  1426. this.defaultColorRest = value;
  1427. }
  1428. public get DefaultColorStem(): string {
  1429. return this.defaultColorStem;
  1430. }
  1431. public set DefaultColorStem(value: string) {
  1432. this.defaultColorStem = value;
  1433. }
  1434. public get DefaultColorLabel(): string {
  1435. return this.defaultColorLabel;
  1436. }
  1437. public set DefaultColorLabel(value: string) {
  1438. this.defaultColorLabel = value;
  1439. }
  1440. public get DefaultColorTitle(): string {
  1441. return this.defaultColorTitle;
  1442. }
  1443. public set DefaultColorTitle(value: string) {
  1444. this.defaultColorTitle = value;
  1445. }
  1446. public get DefaultFontFamily(): string {
  1447. return this.defaultFontFamily;
  1448. }
  1449. public set DefaultFontFamily(value: string) {
  1450. this.defaultFontFamily = value;
  1451. }
  1452. public get MaxMeasureToDrawIndex(): number {
  1453. return this.maxMeasureToDrawIndex;
  1454. }
  1455. public set MaxMeasureToDrawIndex(value: number) {
  1456. this.maxMeasureToDrawIndex = value;
  1457. }
  1458. public get MinMeasureToDrawIndex(): number {
  1459. return this.minMeasureToDrawIndex;
  1460. }
  1461. public set MinMeasureToDrawIndex(value: number) {
  1462. this.minMeasureToDrawIndex = value;
  1463. }
  1464. public get RenderComposer(): boolean {
  1465. return this.renderComposer;
  1466. }
  1467. public set RenderComposer(value: boolean) {
  1468. this.renderComposer = value;
  1469. }
  1470. public get RenderTitle(): boolean {
  1471. return this.renderTitle;
  1472. }
  1473. public set RenderTitle(value: boolean) {
  1474. this.renderTitle = value;
  1475. }
  1476. public get RenderSubtitle(): boolean {
  1477. return this.renderSubtitle;
  1478. }
  1479. public set RenderSubtitle(value: boolean) {
  1480. this.renderSubtitle = value;
  1481. }
  1482. public get RenderLyricist(): boolean {
  1483. return this.renderLyricist;
  1484. }
  1485. public set RenderLyricist(value: boolean) {
  1486. this.renderLyricist = value;
  1487. }
  1488. public get RenderPartNames(): boolean {
  1489. return this.renderPartNames;
  1490. }
  1491. public set RenderPartNames(value: boolean) {
  1492. this.renderPartNames = value;
  1493. }
  1494. public get RenderPartAbbreviations(): boolean {
  1495. return this.renderPartAbbreviations;
  1496. }
  1497. public set RenderPartAbbreviations(value: boolean) {
  1498. this.renderPartAbbreviations = value;
  1499. }
  1500. public get RenderFingerings(): boolean {
  1501. return this.renderFingerings;
  1502. }
  1503. public set RenderFingerings(value: boolean) {
  1504. this.renderFingerings = value;
  1505. }
  1506. public get RenderMeasureNumbers(): boolean {
  1507. return this.renderMeasureNumbers;
  1508. }
  1509. public set RenderMeasureNumbers(value: boolean) {
  1510. this.renderMeasureNumbers = value;
  1511. }
  1512. public get RenderLyrics(): boolean {
  1513. return this.renderLyrics;
  1514. }
  1515. public set RenderLyrics(value: boolean) {
  1516. this.renderLyrics = value;
  1517. }
  1518. public get FingeringPosition(): PlacementEnum {
  1519. return this.fingeringPosition;
  1520. }
  1521. public set FingeringPosition(value: PlacementEnum) {
  1522. this.fingeringPosition = value;
  1523. }
  1524. public get FingeringInsideStafflines(): boolean {
  1525. return this.fingeringInsideStafflines;
  1526. }
  1527. public set FingeringInsideStafflines(value: boolean) {
  1528. this.fingeringInsideStafflines = value;
  1529. }
  1530. public set FixStafflineBoundingBox(value: boolean) { // TODO temporary workaround
  1531. this.fixStafflineBoundingBox = value;
  1532. }
  1533. public get FixStafflineBoundingBox(): boolean {
  1534. return this.fixStafflineBoundingBox;
  1535. }
  1536. public get PageFormat(): PageFormat {
  1537. return this.pageFormat;
  1538. }
  1539. public set PageFormat(value: PageFormat) {
  1540. this.pageFormat = value;
  1541. }
  1542. public get PageBackgroundColor(): string {
  1543. return this.pageBackgroundColor;
  1544. }
  1545. public set PageBackgroundColor(value: string) {
  1546. this.pageBackgroundColor = value;
  1547. }
  1548. public get RenderSingleHorizontalStaffline(): boolean {
  1549. return this.renderSingleHorizontalStaffline;
  1550. }
  1551. public set RenderSingleHorizontalStaffline(value: boolean) {
  1552. this.renderSingleHorizontalStaffline = value;
  1553. }
  1554. /**
  1555. * This method maps NoteDurations to Distances and DistancesScalingFactors.
  1556. */
  1557. private populateDictionaries(): void {
  1558. for (let i: number = 0; i < this.noteDistances.length; i++) {
  1559. switch (i) {
  1560. case 0:
  1561. this.durationDistanceDict[0.015625] = this.noteDistances[i];
  1562. this.durationScalingDistanceDict[0.015625] = this.noteDistancesScalingFactors[i];
  1563. break;
  1564. case 1:
  1565. this.durationDistanceDict[0.03125] = this.noteDistances[i];
  1566. this.durationScalingDistanceDict[0.03125] = this.noteDistancesScalingFactors[i];
  1567. break;
  1568. case 2:
  1569. this.durationDistanceDict[0.0625] = this.noteDistances[i];
  1570. this.durationScalingDistanceDict[0.0625] = this.noteDistancesScalingFactors[i];
  1571. break;
  1572. case 3:
  1573. this.durationDistanceDict[0.125] = this.noteDistances[i];
  1574. this.durationScalingDistanceDict[0.125] = this.noteDistancesScalingFactors[i];
  1575. break;
  1576. case 4:
  1577. this.durationDistanceDict[0.25] = this.noteDistances[i];
  1578. this.durationScalingDistanceDict[0.25] = this.noteDistancesScalingFactors[i];
  1579. break;
  1580. case 5:
  1581. this.durationDistanceDict[0.5] = this.noteDistances[i];
  1582. this.durationScalingDistanceDict[0.5] = this.noteDistancesScalingFactors[i];
  1583. break;
  1584. case 6:
  1585. this.durationDistanceDict[1.0] = this.noteDistances[i];
  1586. this.durationScalingDistanceDict[1.0] = this.noteDistancesScalingFactors[i];
  1587. break;
  1588. case 7:
  1589. this.durationDistanceDict[2.0] = this.noteDistances[i];
  1590. this.durationScalingDistanceDict[2.0] = this.noteDistancesScalingFactors[i];
  1591. break;
  1592. default:
  1593. // FIXME
  1594. }
  1595. }
  1596. }
  1597. /**
  1598. * Calculate Curve-independend factors, to be used later in the Slur- and TieCurvePoints calculation
  1599. */
  1600. private calculateCurveParametersArrays(): void {
  1601. this.tPower3 = new Array(this.bezierCurveStepSize);
  1602. this.oneMinusTPower3 = new Array(this.bezierCurveStepSize);
  1603. this.factorOne = new Array(this.bezierCurveStepSize);
  1604. this.factorTwo = new Array(this.bezierCurveStepSize);
  1605. for (let i: number = 0; i < this.bezierCurveStepSize; i++) {
  1606. const t: number = i / this.bezierCurveStepSize;
  1607. this.tPower3[i] = Math.pow(t, 3);
  1608. this.oneMinusTPower3[i] = Math.pow((1 - t), 3);
  1609. this.factorOne[i] = 3 * Math.pow((1 - t), 2) * t;
  1610. this.factorTwo[i] = 3 * (1 - t) * Math.pow(t, 2);
  1611. }
  1612. }
  1613. }
  1614. // TODO maybe this should be moved to OSMDOptions. Also see OpenSheetMusicDisplay.PageFormatStandards
  1615. export class PageFormat {
  1616. constructor(width: number, height: number, idString: string = "noIdStringGiven") {
  1617. this.width = width;
  1618. this.height = height;
  1619. this.idString = idString;
  1620. }
  1621. public width: number;
  1622. public height: number;
  1623. public idString: string;
  1624. public get aspectRatio(): number {
  1625. if (!this.IsUndefined) {
  1626. return this.width / this.height;
  1627. } else {
  1628. return 0; // infinite page height
  1629. }
  1630. }
  1631. /** Undefined page format: use default page format. */
  1632. public get IsUndefined(): boolean {
  1633. return this.width === undefined || this.height === undefined || this.height === 0 || this.width === 0;
  1634. }
  1635. public static get UndefinedPageFormat(): PageFormat {
  1636. return new PageFormat(0, 0);
  1637. }
  1638. public Equals(otherPageFormat: PageFormat): boolean {
  1639. if (!otherPageFormat) {
  1640. return false;
  1641. }
  1642. return otherPageFormat.width === this.width && otherPageFormat.height === this.height;
  1643. }
  1644. }