Add ScaleFactorX/Y control CLI arguments

This commit is contained in:
Starbeamrainbowlabs 2023-12-05 20:44:39 +00:00
parent 9d2590e7c8
commit 85dce8acec
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 30 additions and 0 deletions

View file

@ -10,5 +10,7 @@ Options:
-h --help Shows this help message.
-i --input {filename} Specifies the input midi file to convert.
-o --output {filename} Specifies the file path to output the SVG music box strip to.
-sx --scale-factor-x Sets the X scale factor. Defaults to 0.03.
-sy --scale-factor-y Sets the Y scale factor. Defaults to 0.03.
--box {Note30|Note30Corrected} The music box schema to use when rendering. Default: Note30Corrected.
--debug Activates additional debugging output.

View file

@ -66,8 +66,21 @@ namespace MusicBoxConverter
}
}
public void SetScaleFactorX(float scaleFactorX) {
Vector2 newScaleFactor = ScaleFactor;
newScaleFactor.X = scaleFactorX;
ScaleFactor = newScaleFactor;
}
public void SetScaleFactorY(float scaleFactorY) {
Vector2 newScaleFactor = ScaleFactor;
newScaleFactor.Y = scaleFactorY;
ScaleFactor = newScaleFactor;
}
public void Output(string destinationFilename)
{
Console.WriteLine($"DEBUG SF {ScaleFactor}");
Vector2 area = new Vector2(TrackLength, SelectedMusicBox.NoteCount-1).Multiply(ScaleFactor);
Vector2 size = area.Add(Offset.Multiply(2));

View file

@ -17,6 +17,8 @@ namespace MusicBoxConverter
string outputFilename = "";
bool debug = false;
MusicBox targetMusicBox = MusicBox.Note30Corrected;
float scaleFactorX = 0.03f;
float scaleFactorY = 4.0f;
for(int i = 0; i < args.Length; i++)
{
@ -52,6 +54,16 @@ namespace MusicBoxConverter
).GetValue(null);
break;
case "-sx":
case "--scale-factor-x":
scaleFactorX = float.Parse(args[++i], CultureInfo.InvariantCulture);
break;
case "-sy":
case "--scale-factor-y":
scaleFactorY = float.Parse(args[++i], CultureInfo.InvariantCulture);
break;
case "-h":
case "--help":
Console.Error.WriteLine(EmbeddedFiles.ReadAllText("MusicBoxConverter.Help.txt"));
@ -78,6 +90,9 @@ namespace MusicBoxConverter
) {
Debug = debug
};
converter.SetScaleFactorX(scaleFactorX);
converter.SetScaleFactorY(scaleFactorY);
converter.Output(outputFilename);
return 0;