Skip to content

Commit

Permalink
Improvements to animation scaling and UI
Browse files Browse the repository at this point in the history
* Fix scaling factor for the source SVG files. The scaling factor must contain decimal places and cannot just be an integer.
* Revert SVG.resx and SVG.Designer.resx; it's not necessary to draw the line with variable offsets depending on the size the user desires, because we're scaling a 109px canvas using an SVG transform already.
* Add image size option to GUI
  • Loading branch information
shuuryou committed Mar 27, 2024
1 parent d178df0 commit 0c97d83
Show file tree
Hide file tree
Showing 6 changed files with 382 additions and 307 deletions.
648 changes: 357 additions & 291 deletions kanji2gif/MainForm.Designer.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions kanji2gif/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="folderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAwAMDAQAAEABABoBgAAxgAAACAgEAABAAQA6AIAAC4HAAAYGBAAAQAEAOgBAAAWCgAAEBAQAAEA
Expand Down
20 changes: 15 additions & 5 deletions kanji2gif/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ public static void Main(string[] args)
newArgs.Add(string.Format(CultureInfo.CurrentCulture, "/w:{0}",
mainForm.loopDelayUpDown.Value));

args = newArgs.ToArray();
newArgs.Add(string.Format(CultureInfo.InvariantCulture, "/imgw:{0}",
mainForm.widthHeightUpDown.Value));

newArgs.Add(string.Format(CultureInfo.InvariantCulture, "/imgh:{0}",
mainForm.widthHeightUpDown.Value));

args = newArgs.ToArray();
}
}
#endregion
Expand Down Expand Up @@ -171,10 +177,14 @@ private static void Convert(string text, string outputFile, bool colorful,
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
"No stroke information found for \"{0}\".", c), "text");

sb.AppendFormat(CultureInfo.InvariantCulture, SVG.TransformHeader,
imageWidth * charIndex, imageWidth / 109, imageHeight / 109);
{
double scalex = imageWidth / 109D;
double scaley = imageHeight / 109D;
sb.AppendFormat(CultureInfo.InvariantCulture, SVG.TransformHeader,
imageWidth * charIndex, scalex , scaley);
}

sb.AppendFormat(SVG.Lines, imageWidth, imageHeight, imageWidth / 2, imageHeight / 2);
sb.AppendFormat(SVG.Lines);

foreach (XmlNode node in nodes)
{
Expand All @@ -194,7 +204,7 @@ private static void Convert(string text, string outputFile, bool colorful,

animTimeline += animLength + strokeDelay;
}

sb.Append(SVG.TransformFooter);
charIndex++;
}
Expand Down
2 changes: 1 addition & 1 deletion kanji2gif/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyCopyright("Copyright © 2011 - 2022")]
[assembly: ComVisible(false)]
[assembly: Guid("a072de5c-9086-4d6f-b501-5617a15db179")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyVersion("1.1.0.2")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
[assembly: CLSCompliant(true)]

Expand Down
4 changes: 2 additions & 2 deletions kanji2gif/SVG.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions kanji2gif/SVG.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@
<value>&lt;svg width="{0}" height="{1}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1200/xlink" xml:space="preserve" version="1.1" baseProfile="full"&gt;</value>
<comment>0 = Total width (109 * numChars), 1 Height</comment>
</data>
<data name="Lines" xml:space="preserve">
<value>&lt;line x1="1" y1="{2}" x2="{0}" y2="{2}" stroke="#dddddd" stroke-width="1" /&gt;&lt;line x1="{3}" y1="1" x2="{3}" y2="{1}" stroke="#dddddd" stroke-width="1" /&gt;</value>
<comment>0, Width, 1 Height</comment>
<data name="Lines" xml:space="preserve">
<value>&lt;line x1="1" y1="54.5" x2="109" y2="54.5" stroke="#dddddd" stroke-width="1" /&gt;&lt;line x1="54.5" y1="1" x2="54.5" y2="109" stroke="#dddddd" stroke-width="1" /&gt;</value>
</data>
<data name="Stroke" xml:space="preserve">
<value>&lt;path stroke-width="2" fill="none" stroke="{0}" stroke-dasharray="{1},{1}" stroke-dashoffset="{1}" d="{2}"&gt;&lt;animate begin="{3}s" attributeName="stroke-dashoffset" from="{1}" to="0" dur="{4}s" fill="freeze" /&gt;&lt;/path&gt;</value>
Expand All @@ -141,6 +140,6 @@
</data>
<data name="TransformHeader" xml:space="preserve">
<value>&lt;g transform="translate({0}, 0) scale({1},{2})"&gt;</value>
<comment>0 = New X offset (109 * charPos)</comment>
<comment>0 = New X offset (109 * charPos), {1} Scale X, {2} Scale Y</comment>
</data>
</root>

0 comments on commit 0c97d83

Please # to comment.