EngravingRules.ts 62 KB

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