Skip to content

Commit 579a586

Browse files
committed
Me release
1 parent b2e57df commit 579a586

15 files changed

+193
-81
lines changed

PythagorasTree/App.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
3+
<configSections>
4+
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5+
<section name="PythagorasTree.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6+
</sectionGroup>
7+
</configSections>
38
<startup>
49
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
510
</startup>
11+
<userSettings>
12+
<PythagorasTree.Properties.Settings>
13+
<setting name="TriangleSizeFactor" serializeAs="String">
14+
<value>2</value>
15+
</setting>
16+
</PythagorasTree.Properties.Settings>
17+
</userSettings>
618
</configuration>

PythagorasTree/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ internal static class Program
2323
[STAThread]
2424
private static void Main()
2525
{
26+
/*
27+
* Start the application
28+
*/
2629
using (var window = new PythagorasWindow())
2730
{
2831
window.Run(30.0, 0.0);

PythagorasTree/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
// set of attributes. Change these attribute values to modify the information
1919
// associated with an assembly.
2020

21-
[assembly: AssemblyTitle("WindowsFormsApplication1")]
22-
[assembly: AssemblyDescription("")]
21+
[assembly: AssemblyTitle("Pythagoras tree")]
22+
[assembly: AssemblyDescription("Renders an awesome pythagoras tree")]
2323
[assembly: AssemblyConfiguration("")]
2424
[assembly: AssemblyCompany("")]
25-
[assembly: AssemblyProduct("WindowsFormsApplication1")]
26-
[assembly: AssemblyCopyright("Copyright © 2014")]
25+
[assembly: AssemblyProduct("Pythagoras tree")]
26+
[assembly: AssemblyCopyright("Copyright © Tim Potze 2014")]
2727
[assembly: AssemblyTrademark("")]
2828
[assembly: AssemblyCulture("")]
2929

PythagorasTree/Properties/Resources.Designer.cs

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

PythagorasTree/Properties/Resources.resx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
4747
mimetype: application/x-microsoft.net.object.binary.base64
4848
value : The object must be serialized with
49-
: System.Serialization.Formatters.Binary.BinaryFormatter
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
5151
5252
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
6060
: and then encoded with base64 encoding.
6161
-->
6262
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6364
<xsd:element name="root" msdata:IsDataSet="true">
6465
<xsd:complexType>
6566
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
6869
<xsd:sequence>
6970
<xsd:element name="value" type="xsd:string" minOccurs="0" />
7071
</xsd:sequence>
71-
<xsd:attribute name="name" type="xsd:string" />
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
7273
<xsd:attribute name="type" type="xsd:string" />
7374
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
7476
</xsd:complexType>
7577
</xsd:element>
7678
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
8587
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
8688
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
8789
</xsd:sequence>
88-
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
8991
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
9092
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
9194
</xsd:complexType>
9295
</xsd:element>
9396
<xsd:element name="resheader">
@@ -109,9 +112,13 @@
109112
<value>2.0</value>
110113
</resheader>
111114
<resheader name="reader">
112-
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113116
</resheader>
114117
<resheader name="writer">
115-
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116119
</resheader>
120+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121+
<data name="tree" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\Resources\tree.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123+
</data>
117124
</root>

PythagorasTree/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
3-
<Profiles>
4-
<Profile Name="(Default)" />
5-
</Profiles>
6-
<Settings />
7-
</SettingsFile>
2+
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PythagorasTree.Properties" GeneratedClassName="Settings">
3+
<Profiles />
4+
<Settings>
5+
<Setting Name="TriangleSizeFactor" Type="System.Single" Scope="User">
6+
<Value Profile="(Default)">2</Value>
7+
</Setting>
8+
</Settings>
9+
</SettingsFile>

PythagorasTree/Pythagoras.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System;
1515
using System.Collections.Generic;
1616
using OpenTK;
17+
using PythagorasTree.Properties;
1718

1819
namespace PythagorasTree
1920
{
@@ -40,21 +41,21 @@ private static Vector2 AngleVector(double angle)
4041
public static Pythagoras Generate(Vector2 leftVector, Vector2 rightVector, int iteration)
4142
{
4243
/*
43-
* Triangle
44-
*/
44+
* Calculate triangle corners.
45+
*/
4546

4647
double angle = VecAngle(leftVector, rightVector) + Math.PI/2;
4748
Vector2 midVector = leftVector + (rightVector - leftVector)/2;
4849
Vector2 newVector = AngleVector(angle);
4950

50-
newVector *= (rightVector - leftVector).Length/2;
51+
newVector *= (rightVector - leftVector).Length/Settings.Default.TriangleSizeFactor;
5152
newVector += midVector;
5253

5354
double newVectorAngle = VecAngle(newVector, leftVector);
5455
double newVectorAngle2 = VecAngle(rightVector, newVector);
5556

5657
/*
57-
* Squares below
58+
* Calculate squares' corners.
5859
*/
5960

6061
Vector2 leftTranslation = AngleVector(newVectorAngle - Math.PI/2)*(newVector - leftVector).Length;
@@ -66,6 +67,9 @@ public static Pythagoras Generate(Vector2 leftVector, Vector2 rightVector, int i
6667
Vector2 rightTopLeft = newVector + rightTranslation;
6768
Vector2 rightTopRight = rightVector + rightTranslation;
6869

70+
/*
71+
* Initialize the structure.
72+
*/
6973
return new Pythagoras
7074
{
7175
Triangle = new[] {leftVector, rightVector, newVector},

PythagorasTree/PythagorasSets.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// For more information, please refer to <http://unlicense.org>
1313

1414
using System.Collections.Generic;
15+
using System.Diagnostics;
1516
using System.Linq;
1617
using OpenTK;
1718

@@ -26,17 +27,19 @@ public static int AvailableIterations
2627
get { return Sets.Count; }
2728
}
2829

29-
private static IEnumerable<Pythagoras> GetSetsForSets(IEnumerable<Pythagoras> previousSets)
30-
{
31-
return previousSets.SelectMany(set => set.Next());
32-
}
33-
3430
public static IEnumerable<Pythagoras> GetSet(int iteration, float baseSize)
3531
{
36-
if (Sets.Count > iteration) //Available in known
32+
/*
33+
* Set was already generated, parse from list.
34+
*/
35+
if (Sets.Count > iteration)
3736
{
3837
return Sets[iteration];
3938
}
39+
40+
/*
41+
* First iterations need to be handed the base plate.
42+
*/
4043
if (iteration == 0)
4144
{
4245
var set = new[] {Pythagoras.Generate(new Vector2(0, baseSize), new Vector2(baseSize, baseSize), 0)};
@@ -45,22 +48,21 @@ public static IEnumerable<Pythagoras> GetSet(int iteration, float baseSize)
4548
return set;
4649
}
4750

48-
IEnumerable<Pythagoras> sets = GetSetsForSets(GetSet(iteration - 1, baseSize));
51+
/*
52+
* Other iterations can simply ge generated using the Pythagoras.Next function.
53+
*/
54+
IEnumerable<Pythagoras> sets = GetSet(iteration - 1, baseSize).SelectMany(set => set.Next()).ToList();
4955

5056
Sets.Add(sets);
5157
return sets;
5258
}
5359

5460
public static IEnumerable<IEnumerable<Pythagoras>> GetSets(int iterations, float baseSize)
5561
{
56-
GenerateSets(iterations, baseSize);
57-
return Sets.Take(iterations);
58-
}
59-
60-
public static void GenerateSets(int iterations, float baseSize)
61-
{
62-
if (Sets.Count <= iterations)
63-
GetSet(iterations, baseSize);
62+
for (var i = 0; i < iterations; i++)
63+
{
64+
yield return GetSet(i, baseSize).ToArray();
65+
}
6466
}
6567
}
6668
}

PythagorasTree/PythagorasTree.csproj

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
<AssemblyName>PythagorasTree</AssemblyName>
1212
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<IsWebBootstrapper>false</IsWebBootstrapper>
15+
<PublishUrl>publish\</PublishUrl>
16+
<Install>true</Install>
17+
<InstallFrom>Disk</InstallFrom>
18+
<UpdateEnabled>false</UpdateEnabled>
19+
<UpdateMode>Foreground</UpdateMode>
20+
<UpdateInterval>7</UpdateInterval>
21+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
22+
<UpdatePeriodically>false</UpdatePeriodically>
23+
<UpdateRequired>false</UpdateRequired>
24+
<MapFileExtensions>false</MapFileExtensions>
25+
<ProductName>Pythagoras tree</ProductName>
26+
<PublisherName>Tim Potze</PublisherName>
27+
<ApplicationRevision>1</ApplicationRevision>
28+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
29+
<UseApplicationTrust>false</UseApplicationTrust>
30+
<PublishWizardCompleted>true</PublishWizardCompleted>
31+
<BootstrapperEnabled>true</BootstrapperEnabled>
1432
</PropertyGroup>
1533
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1634
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -31,6 +49,21 @@
3149
<ErrorReport>prompt</ErrorReport>
3250
<WarningLevel>4</WarningLevel>
3351
</PropertyGroup>
52+
<PropertyGroup>
53+
<ApplicationIcon>tree.ico</ApplicationIcon>
54+
</PropertyGroup>
55+
<PropertyGroup>
56+
<ManifestCertificateThumbprint>12F1D542CDE8EB8D36E5F497C75BDB0AE3DF4A69</ManifestCertificateThumbprint>
57+
</PropertyGroup>
58+
<PropertyGroup>
59+
<ManifestKeyFile>PythagorasTree_TemporaryKey.pfx</ManifestKeyFile>
60+
</PropertyGroup>
61+
<PropertyGroup>
62+
<GenerateManifests>true</GenerateManifests>
63+
</PropertyGroup>
64+
<PropertyGroup>
65+
<SignManifests>true</SignManifests>
66+
</PropertyGroup>
3467
<ItemGroup>
3568
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
3669
<HintPath>..\packages\OpenTK.1.1.1589.5942\lib\NET40\OpenTK.dll</HintPath>
@@ -73,10 +106,32 @@
73106
<DependentUpon>Settings.settings</DependentUpon>
74107
<DesignTimeSharedInput>True</DesignTimeSharedInput>
75108
</Compile>
109+
<None Include="PythagorasTree_TemporaryKey.pfx" />
76110
</ItemGroup>
77111
<ItemGroup>
78112
<None Include="App.config" />
79113
</ItemGroup>
114+
<ItemGroup>
115+
<None Include="Resources\tree.ico" />
116+
<Content Include="tree.ico" />
117+
</ItemGroup>
118+
<ItemGroup>
119+
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
120+
<Visible>False</Visible>
121+
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
122+
<Install>true</Install>
123+
</BootstrapperPackage>
124+
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
125+
<Visible>False</Visible>
126+
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
127+
<Install>false</Install>
128+
</BootstrapperPackage>
129+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
130+
<Visible>False</Visible>
131+
<ProductName>.NET Framework 3.5 SP1</ProductName>
132+
<Install>false</Install>
133+
</BootstrapperPackage>
134+
</ItemGroup>
80135
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
81136
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
82137
Other similar extension points exist, see Microsoft.Common.targets.

0 commit comments

Comments
 (0)