Skip to content

Commit 0a2069f

Browse files
Reduce score fit to width to use 99.5%
This should be enough to ensure that the score fits and is also scaled as nearly as possib;e to the desired limit. correct typo in recalculating the score height after scaling to fit width.
1 parent 081b78e commit 0a2069f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

examples/scaling/src/Main.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ main =
2525
Right abcTune -> do
2626
renderer <- initialiseCanvas config
2727
let
28-
desiredWidth = 580
28+
desiredWidth = 400
2929
renderFinalTuneAtWidth config desiredWidth renderer abcTune
3030
_ ->
3131
pure $ Just "ABC failed to parse"

src/VexFlow/Score.purs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,13 @@ scaleConfigToDesiredWidth :: AbcTune -> Config -> Int -> Config
148148
scaleConfigToDesiredWidth abcTune config desiredWidth =
149149
let
150150
justifiedConfig = justifiedScoreConfig (createScore config abcTune) config
151-
-- fit the score to within 98% of the desired width to avoid margin errors
152-
scaleFactor = (0.98 * toNumber desiredWidth) / (toNumber justifiedConfig.width)
151+
-- fit the score to within 99.5% of the desired width to avoid margin errors
152+
scaleFactor = (0.995 * toNumber desiredWidth) / (toNumber justifiedConfig.width)
153153
newScale = justifiedConfig.scale * scaleFactor
154-
newWidth = desiredWidth
155-
-- floor $ (toNumber justifiedConfig.width) * scaleFactor
156-
newHeight = floor $ (toNumber justifiedConfig.width) * scaleFactor
154+
newHeight = floor $ (toNumber justifiedConfig.height) * scaleFactor
157155
in
158156
justifiedConfig
159-
{ width = newWidth
157+
{ width = desiredWidth
160158
, height = newHeight
161159
, scale = newScale
162160
}

0 commit comments

Comments
 (0)