Skip to main content

Posts

Showing posts from March, 2013

Draw Fractal tree in wpf

In this post I will show you how to draw Fractal tree in WPF.Before going to implementation details first go throw this link.

Algorithm:To draw a fractal tree is simple: Draw the trunkAt the end of the trunk, split by some angle and draw two branchesRepeat at the end of each branch until a sufficient level of branching is reached


Create a new WPF application and add following code




<Windowx:Class="HelloWorld.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"Height="350"Width="525">
<Grid>
<ViewboxStretch="Uniform">
<StackPanel>
<StackPanelOrientation="Horizontal"
Margin="5,5,5,0">
<ButtonName="btnStart"Click="btnStart_Click"
Width="50"Content="Start"/>
<TextBlockName="tbLabel"Margin="20,5,0,0"/>
</StackPanel&…

How to draw Sierpinski triangle in WPF

In this post,I will show you how to draw Sierpinski triangle in wpf. Create a new WPF application and add foloowing code in MainWindow.xaml <Windowx:Class="Sierpinski.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="350"Width="525"><Grid><ViewboxStretch="Uniform"><StackPanel><StackPanelOrientation="Horizontal"Margin="5,5,5,0"><ButtonName="btnStart"Click="btnStart_Click"Width="50"Content="Start"/><TextBlockName="tbLabel"Margin="20,5,0,0"/></StackPanel><CanvasName="canvas1"Width="300"Height="300"Margin="5"/></StackPanel></Viewbox></Grid></Window>Open MainWindow.xaml.cs and add following code into itusing System; using S…