Skip to content

Commit 0a58666

Browse files
committed
Completed Asciimation_1.3 with smaller code size (compare to v.1.2).
Frames can be basic or transitional. GUI improvements. Errors fixing.
1 parent 83b9244 commit 0a58666

30 files changed

+1812
-568
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{70B54927-6583-491D-816B-9D0B648E9421}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AsciimationStatistics</RootNamespace>
11+
<AssemblyName>AsciimationStatistics</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>x86</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="Program.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<ProjectReference Include="..\FreakySources\FreakySources.csproj">
49+
<Project>{cd572e98-9d0e-486c-9a7c-7edb55a9e9b2}</Project>
50+
<Name>FreakySources</Name>
51+
</ProjectReference>
52+
</ItemGroup>
53+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
54+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
55+
Other similar extension points exist, see Microsoft.Common.targets.
56+
<Target Name="BeforeBuild">
57+
</Target>
58+
<Target Name="AfterBuild">
59+
</Target>
60+
-->
61+
</Project>

AsciimationStatistics/Program.cs

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
using FreakySources;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
8+
namespace AsciimationStatistics
9+
{
10+
class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
var generator = new AsciimationDataGenerator(File.ReadAllText(@"..\..\..\Sources\Asciimation.txt"));
15+
16+
List<CompressedFrame> compressedFrames;
17+
var compressedStr = generator.Compress_v_1_3(out compressedFrames, true);
18+
File.WriteAllText(DateTime.Now.Ticks.ToString() + ".txt", compressedStr);
19+
20+
Console.WriteLine("Global frames count: " + generator.Frames.Length);
21+
Console.WriteLine("Compressed frames count: " + compressedFrames.Where(f => f.FrameType != FrameType.Basic).Count());
22+
23+
var repeatedLengths = new List<int>();
24+
var notrepeatedLengths = new List<int>();
25+
var changeLengths = new List<int>();
26+
var changeCounts = new List<int>();
27+
int maxReducedLineLength = 0;
28+
29+
var frameTypesCount = new Dictionary<FrameType, int>()
30+
{
31+
{ FrameType.Basic, 0 },
32+
{ FrameType.Transitional, 0 },
33+
{ FrameType.TransitionalLeft, 0 },
34+
{ FrameType.TransitionalRight, 0 },
35+
{ FrameType.TransitionalTop, 0 },
36+
{ FrameType.TransitionalBottom, 0 }
37+
};
38+
39+
for (int i = 0; i < compressedFrames.Count; i++)
40+
{
41+
var compressedFrame = compressedFrames[i];
42+
switch (compressedFrame.FrameType)
43+
{
44+
case FrameType.Basic:
45+
GetRepeatedCount(generator.Frames[i].ReducedLine, repeatedLengths, notrepeatedLengths);
46+
if (generator.Frames[i].ReducedLine.Length > maxReducedLineLength)
47+
maxReducedLineLength = generator.Frames[i].ReducedLine.Length;
48+
break;
49+
case FrameType.Transitional:
50+
case FrameType.TransitionalLeft:
51+
case FrameType.TransitionalRight:
52+
case FrameType.TransitionalTop:
53+
case FrameType.TransitionalBottom:
54+
foreach (var change in compressedFrame.FrameChanges)
55+
{
56+
//GetRepeatedCount(new string(change.Chars.ToArray()), repeatedLengths, notrepeatedLengths);
57+
changeLengths.Add(change.Chars.Count);
58+
}
59+
changeCounts.Add(compressedFrame.FrameChanges.Count);
60+
break;
61+
}
62+
frameTypesCount[compressedFrame.FrameType]++;
63+
}
64+
65+
Console.WriteLine("Basic count: " + frameTypesCount[FrameType.Basic]);
66+
Console.WriteLine("Trans count: " + frameTypesCount[FrameType.Transitional]);
67+
Console.WriteLine("Trans left count: " + frameTypesCount[FrameType.TransitionalLeft]);
68+
Console.WriteLine("Trans right count: " + frameTypesCount[FrameType.TransitionalRight]);
69+
Console.WriteLine("Trans top count: " + frameTypesCount[FrameType.TransitionalTop]);
70+
Console.WriteLine("Trans bottom count: " + frameTypesCount[FrameType.TransitionalBottom]);
71+
72+
Console.WriteLine("Avg repeated chars length: " + repeatedLengths.Average());
73+
Console.WriteLine("Avg not repeated chars length: " + notrepeatedLengths.Average());
74+
Console.WriteLine("Avg change length: " + changeLengths.Average());
75+
Console.WriteLine("Max change length: " + changeLengths.Max());
76+
Console.WriteLine("Max change count: " + changeCounts.Max());
77+
Console.WriteLine("Max reduced line length: " + maxReducedLineLength);
78+
79+
Console.ReadLine();
80+
}
81+
82+
static void GetRepeatedCount(string str, List<int> repeatedLengths, List<int> notrepeatedLengths)
83+
{
84+
int i = 0;
85+
while (i < str.Length)
86+
{
87+
int j = i;
88+
do
89+
j++;
90+
while (j != str.Length && str[j] == str[i]);
91+
92+
int repeatCount = j - i;
93+
if (repeatCount >= 2)
94+
{
95+
repeatedLengths.Add(repeatCount);
96+
97+
i = j;
98+
}
99+
else
100+
{
101+
while (j != str.Length && str[j] != str[j - 1])
102+
j++;
103+
104+
int nonrepeatCount = j - i;
105+
if (j != str.Length)
106+
nonrepeatCount--;
107+
108+
notrepeatedLengths.Add(nonrepeatCount);
109+
110+
i = j;
111+
if (j != str.Length)
112+
i--;
113+
}
114+
}
115+
}
116+
}
117+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("AsciimationStatistics")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("AsciimationStatistics")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8eb4996c-087d-43f0-a3e9-fcec4a261ada")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

FreakySources.GUI/FreakySources.GUI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<Reference Include="System.Core" />
4040
<Reference Include="System.Drawing" />
4141
<Reference Include="System.Windows.Forms" />
42+
<Reference Include="System.XML" />
4243
</ItemGroup>
4344
<ItemGroup>
4445
<Compile Include="frmMain.cs">

FreakySources.GUI/Properties/Settings.Designer.cs

Lines changed: 62 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FreakySources.GUI/Properties/Settings.settings

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<Value Profile="(Default)">0</Value>
1313
</Setting>
1414
<Setting Name="ExtraParams" Type="System.String" Scope="User">
15-
<Value Profile="(Default)">0/*$currentFrame$*/~0/*$currentFrame$*/~currentFrame~0|/*$output$*/~/*$output$*/~output.ToString()~|/*$frames*/~/*frames$*/~frames.ToString()~frames.ToString()|</Value>
15+
<Value Profile="(Default)" />
1616
</Setting>
1717
<Setting Name="Kernel" Type="System.String" Scope="User">
18-
<Value Profile="(Default)">/*print*/</Value>
18+
<Value Profile="(Default)">/*@*/</Value>
1919
</Setting>
2020
<Setting Name="QuineStr" Type="System.String" Scope="User">
2121
<Value Profile="(Default)">s</Value>
@@ -41,5 +41,20 @@
4141
<Setting Name="SelectedPattern" Type="System.String" Scope="User">
4242
<Value Profile="(Default)" />
4343
</Setting>
44+
<Setting Name="splitContGenWidth" Type="System.Int32" Scope="User">
45+
<Value Profile="(Default)">0</Value>
46+
</Setting>
47+
<Setting Name="splitCont1Height" Type="System.Int32" Scope="User">
48+
<Value Profile="(Default)">0</Value>
49+
</Setting>
50+
<Setting Name="splitCont2Height" Type="System.Int32" Scope="User">
51+
<Value Profile="(Default)">0</Value>
52+
</Setting>
53+
<Setting Name="OutputWordWrap" Type="System.Boolean" Scope="User">
54+
<Value Profile="(Default)">False</Value>
55+
</Setting>
56+
<Setting Name="CompilationsCount" Type="System.Int32" Scope="User">
57+
<Value Profile="(Default)">1</Value>
58+
</Setting>
4459
</Settings>
4560
</SettingsFile>

FreakySources.GUI/app.config

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
<value>0</value>
1818
</setting>
1919
<setting name="ExtraParams" serializeAs="String">
20-
<value>0/*$currentFrame$*/~0/*$currentFrame$*/~currentFrame~0|/*$output$*/~/*$output$*/~output.ToString()~|/*$frames*/~/*frames$*/~frames.ToString()~frames.ToString()|</value>
20+
<value />
2121
</setting>
2222
<setting name="Kernel" serializeAs="String">
23-
<value>/*print*/</value>
23+
<value>/*@*/</value>
2424
</setting>
2525
<setting name="QuineStr" serializeAs="String">
2626
<value>s</value>
@@ -46,6 +46,21 @@
4646
<setting name="SelectedPattern" serializeAs="String">
4747
<value />
4848
</setting>
49+
<setting name="splitContGenWidth" serializeAs="String">
50+
<value>0</value>
51+
</setting>
52+
<setting name="splitCont1Height" serializeAs="String">
53+
<value>0</value>
54+
</setting>
55+
<setting name="splitCont2Height" serializeAs="String">
56+
<value>0</value>
57+
</setting>
58+
<setting name="OutputWordWrap" serializeAs="String">
59+
<value>False</value>
60+
</setting>
61+
<setting name="CompilationsCount" serializeAs="String">
62+
<value>1</value>
63+
</setting>
4964
</FreakySources.GUI.Properties.Settings>
5065
</userSettings>
5166
</configuration>

0 commit comments

Comments
 (0)