OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/psychlops/silverlight
authorHOSOKAWA Kenchi <hskwk@inter7.jp>
Tue, 24 Aug 2010 04:23:12 +0000 (13:23 +0900)
committerHOSOKAWA Kenchi <hskwk@inter7.jp>
Tue, 24 Aug 2010 04:23:12 +0000 (13:23 +0900)
22 files changed:
dev4/Pages/BinomialSolver.xaml [new file with mode: 0644]
dev4/Pages/BinomialSolver.xaml.cs [new file with mode: 0644]
dev4/PsychlopsSilverlight4.csproj
dev4/WriteableBitmapEx/Readme.txt
dev4/WriteableBitmapEx/WriteableBitmapEx.XML
dev4/WriteableBitmapEx/WriteableBitmapEx.dll
dev4/WriteableBitmapEx/WriteableBitmapEx.pdb
dev4/psychlops/core/device/clock.cs
dev4/psychlops/core/graphic/canvas.cs
dev4/psychlops/core/graphic/image.cs
dev4/psychlops/core/graphic/shape.cs
dev4/psychlops/core/math/interval.cs
dev4/psychlops/core/math/matrix.cs
dev4/psychlops/core/math/util.cs
dev4/psychlops/extention/compatibility/compatibility.cs [new file with mode: 0644]
dev4/psychlops/extention/math/solver.cs
dev4/psychlops/extention/standard/widget.cs
test4/MainPage.xaml.cs
test4/PsychlopsMain.cs
test4/PsychlopsSilverlight4test.csproj
test4/Resources/logo.png [new file with mode: 0644]
test4/TestPage.html

diff --git a/dev4/Pages/BinomialSolver.xaml b/dev4/Pages/BinomialSolver.xaml
new file mode 100644 (file)
index 0000000..e08c197
--- /dev/null
@@ -0,0 +1,115 @@
+<controls:ChildWindow x:Class="PsychlopsSilverlight4.Pages.BinomialSolver"\r
+           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" \r
+           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" \r
+           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"\r
+           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"\r
+           Width="400" Height="300" \r
+           Title="Binomial Likelihood Solver" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">\r
+\r
+\r
+       <controls:ChildWindow.Resources>\r
+               <Style TargetType="toolkit:Chart">\r
+                       <!-- To Remove Legend-->\r
+                       <Setter Property="Padding" Value="10 0" />\r
+                       <Setter Property="BorderBrush" Value="Transparent" />\r
+                       <Setter Property="PlotAreaStyle">\r
+                               <Setter.Value>\r
+                                       <Style TargetType="Grid">\r
+                                               <Setter Property="Margin" Value="0"/>\r
+                                       </Style>\r
+                               </Setter.Value>\r
+                       </Setter>\r
+                       <Setter Property="TitleStyle">\r
+                               <Setter.Value>\r
+                                       <Style TargetType="toolkit:Title">\r
+                                               <Setter Property="Width" Value="0"/>\r
+                                               <Setter Property="Height" Value="0"/>\r
+                                       </Style>\r
+                               </Setter.Value>\r
+                       </Setter>\r
+                       <Setter Property="LegendStyle">\r
+                               <Setter.Value>\r
+                                       <Style TargetType="toolkit:Legend">\r
+                                               <Setter Property="Width" Value="0"/>\r
+                                               <Setter Property="Height" Value="0"/>\r
+                                       </Style>\r
+                               </Setter.Value>\r
+                       </Setter>\r
+               </Style>\r
+               <Style TargetType="toolkit:LineSeries">\r
+               </Style>                \r
+       </controls:ChildWindow.Resources>\r
+\r
+       <Grid x:Name="LayoutRoot" Margin="2">\r
+        <Grid.RowDefinitions>\r
+            <RowDefinition />\r
+            <RowDefinition Height="Auto" />\r
+        </Grid.RowDefinitions>\r
+\r
+               <StackPanel Orientation="Horizontal">\r
+                       <Canvas Width="250" Height="Auto">\r
+                               <toolkit:Chart x:Name="chart1" Title="" Width="240" Height="220" Canvas.Left="0" Canvas.Top="0"\r
+                                                          FontSize="10">\r
+                                       <toolkit:Chart.Series>\r
+                                               <toolkit:LineSeries x:Name="Fitted"\r
+                                                                               Title="Fitted"\r
+                                                                               ItemsSource="{Binding}"\r
+                                                                               IndependentValueBinding="{Binding c_abscissa}"\r
+                                                                               DependentValueBinding="{Binding c_ratio}"\r
+                                                                               >\r
+                                                       <toolkit:LineSeries.DataPointStyle>\r
+                                                               <Style TargetType="Control">\r
+                                                                       <Setter Property="Template" Value="{x:Null}"/>\r
+                                                               </Style>\r
+                                                       </toolkit:LineSeries.DataPointStyle>\r
+\r
+                                                       <toolkit:LineSeries.DependentRangeAxis>\r
+                                                               <toolkit:LinearAxis Title="" ShowGridLines="False" Orientation="Y" Minimum="0" Maximum="1">\r
+                                                               </toolkit:LinearAxis>\r
+                                                       </toolkit:LineSeries.DependentRangeAxis>\r
+                                               </toolkit:LineSeries>\r
+                                               <toolkit:ScatterSeries x:Name="Raw"\r
+                                                                               Title="Fitted"\r
+                                                                               ItemsSource="{Binding}"\r
+                                                                               IndependentValueBinding="{Binding abscissa}"\r
+                                                                               DependentValueBinding="{Binding ratio}"\r
+                                                                               >\r
+                                                       <!--\r
+                                               <toolkit:ScatterSeries.IndependentAxis>\r
+                                                       <toolkit:LinearAxis Title="" Orientation="X" Maximum="10" Minimum="0">\r
+                                                       </toolkit:LinearAxis>\r
+                                               </toolkit:ScatterSeries.IndependentAxis>\r
+                                               -->\r
+\r
+                                                       <toolkit:ScatterSeries.DependentRangeAxis>\r
+                                                               <toolkit:LinearAxis Title="" ShowGridLines="False" Orientation="Y" Minimum="0" Maximum="1">\r
+                                                               </toolkit:LinearAxis>\r
+                                                       </toolkit:ScatterSeries.DependentRangeAxis>\r
+                                               </toolkit:ScatterSeries>\r
+                                       </toolkit:Chart.Series>\r
+                               </toolkit:Chart>\r
+                               <Slider x:Name="OrdinateSlider" Canvas.Left="0" Canvas.Top="10" Orientation="Vertical"  Height="200"></Slider>\r
+                               <Slider x:Name="AbscissaSlider" Canvas.Left="20" Canvas.Top="210" Width="200" MouseLeftButtonUp="AbscissaSlider_MouseLeftButtonUp"></Slider>\r
+                       </Canvas>\r
+\r
+\r
+                       <StackPanel Orientation="Vertical">\r
+                               <sdk:DataGrid x:Name="dataGrid" Margin="0,5,0,10" RowHeight="40" AutoGenerateColumns="False" >\r
+                                       <sdk:DataGrid.Columns>\r
+                                               <sdk:DataGridTextColumn Header="Abscissa" Width="40" Binding="{Binding abscissa}" />\r
+                                               <sdk:DataGridTextColumn Header="Positive Cases" Width="40"  Binding="{Binding positive}" />\r
+                                               <sdk:DataGridTextColumn Header="Negative Cases" Width="40" Binding="{Binding negative}" />\r
+                                       </sdk:DataGrid.Columns>\r
+                               </sdk:DataGrid>\r
+                               <Button x:Name="AddConditionButton" Content="Add Condition" Click="AddConditionButton_Click" HorizontalAlignment="Right" FontSize="10" Margin="0,12,0,0" Grid.Row="1" />\r
+                       </StackPanel>\r
+               </StackPanel>\r
+\r
+               <TextBlock Text="Mean" x:Name="Parameter0Name" Width="40" Height="23" HorizontalAlignment="Left" Margin="0,12,0,0" Grid.Row="1" />\r
+               <TextBox x:Name="Parameter0" IsReadOnly="True" Width="50" Height="23" HorizontalAlignment="Left" Margin="40,12,0,0" Grid.Row="1" />\r
+               <TextBlock Text="S.D." x:Name="Parameter1Name" Width="40" Height="23" HorizontalAlignment="Left" Margin="110,12,0,0" Grid.Row="1" />\r
+               <TextBox x:Name="Parameter1" IsReadOnly="True" Width="50" Height="23" HorizontalAlignment="Left" Margin="150,12,0,0" Grid.Row="1" />\r
+               <Button x:Name="CalcButton" Content="Calculate" Click="CalcButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />\r
+        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />\r
+    </Grid>\r
+</controls:ChildWindow>
\ No newline at end of file
diff --git a/dev4/Pages/BinomialSolver.xaml.cs b/dev4/Pages/BinomialSolver.xaml.cs
new file mode 100644 (file)
index 0000000..84c26e8
--- /dev/null
@@ -0,0 +1,215 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Collections.ObjectModel;\r
+using System.Linq;\r
+using System.Net;\r
+using System.Windows;\r
+using System.Windows.Controls;\r
+using System.Windows.Documents;\r
+using System.Windows.Input;\r
+using System.Windows.Media;\r
+using System.Windows.Media.Animation;\r
+using System.Windows.Shapes;\r
+\r
+namespace PsychlopsSilverlight4.Pages\r
+{\r
+       public partial class BinomialSolver : ChildWindow\r
+       {\r
+               int func_selected;\r
+               Psychlops.Solver.Constants.Func1 func1;\r
+               Psychlops.Solver.Constants.Func2 func2;\r
+               Psychlops.Solver.Constants.Func3 func3;\r
+\r
+\r
+               public ObservableCollection<Data> data = new ObservableCollection<Data>();\r
+               public ObservableCollection<Data> fitted = new ObservableCollection<Data>();\r
+               public ObservableCollection<Data> data_ { get { return data; } }\r
+               public ObservableCollection<Data> fitted_ { get { return fitted; } }\r
+\r
+\r
+               public BinomialSolver(Psychlops.Solver.Constants.Func1 f)\r
+               {\r
+                       InitializeComponent();\r
+                       initialize();\r
+                       func_selected = 1;\r
+                       func1 = f;\r
+               }\r
+               public BinomialSolver(Psychlops.Solver.Constants.Func2 f)\r
+               {\r
+                       InitializeComponent();\r
+                       initialize();\r
+                       func_selected = 2;\r
+                       func2 = f;\r
+               }\r
+               public BinomialSolver(Psychlops.Solver.Constants.Func3 f)\r
+               {\r
+                       InitializeComponent();\r
+                       initialize();\r
+                       func_selected = 3;\r
+                       func3 = f;\r
+               }\r
+               public void initialize()\r
+               {\r
+                       dataGrid.RowHeight = 20;\r
+                       data = Data.GetDataList();\r
+                       dataGrid.ItemsSource = data;\r
+\r
+                       chart1.DataContext = data;\r
+                       solver = new Psychlops.Solver.BinomialLikelihood();\r
+               }\r
+               public class Data\r
+               {\r
+                       public double c_abscissa { get; set; }\r
+                       public double c_ratio { get; set; }\r
+                       public double abscissa { get; set; }\r
+                       public int positive { get; set; }\r
+                       public int negative { get; set; }\r
+                       public double ratio { get { return (double)(positive) / (positive+negative); } }\r
+\r
+\r
+                       public Data(double absc, int posi, int nega)\r
+                       {\r
+                               this.abscissa = absc;\r
+                               this.positive = posi;\r
+                               this.negative = nega;\r
+                               c_abscissa = 0.0;\r
+                               c_ratio = 0.0;\r
+                       }\r
+\r
+                       public static ObservableCollection<Data> GetDataList()\r
+                       {\r
+                               return new ObservableCollection<Data>(new Data[] {\r
+                                       new Data(-5, 0, 10),\r
+                                       new Data(0, 1, 9),\r
+                                       new Data(1, 3, 7),\r
+                                       new Data(2, 5, 5),\r
+                                       new Data(3, 7, 3),               \r
+                                       new Data(5, 9, 1),                \r
+                                       new Data(10, 10, 0)                \r
+                               });\r
+                       }\r
+               }\r
+\r
+               private void OKButton_Click(object sender, RoutedEventArgs e)\r
+               {\r
+                       this.DialogResult = true;\r
+               }\r
+\r
+               double minimum, maximum;\r
+               Psychlops.Solver.BinomialLikelihood solver;\r
+               private void CalcButton_Click(object sender, RoutedEventArgs e)\r
+               {\r
+                       var ber = new Psychlops.Solver.BernoulliProcess();\r
+                       ber.elems = new Psychlops.Solver.BernoulliProcess.Data[data.Count];\r
+                       int i = 0;\r
+\r
+                       minimum = Double.PositiveInfinity;\r
+                       maximum = Double.NegativeInfinity;\r
+                       foreach (var d in data)\r
+                       {\r
+                               if (d.abscissa < minimum) { minimum = d.abscissa; }\r
+                               if (d.abscissa > maximum) { maximum = d.abscissa; }\r
+                               ber.elems[i].x = d.abscissa;\r
+                               ber.elems[i].pos = d.positive;\r
+                               ber.elems[i].neg = d.negative;\r
+                               i++;\r
+                       }\r
+\r
+                       solver.data = ber;\r
+\r
+\r
+                       Psychlops.Interval itvl = new Psychlops.Interval();\r
+                       solver.itvl[0] = (-100 <= itvl <= 100);\r
+                       solver.itvl[1] = (-100 <= itvl <= 100);\r
+                       solver.itvl[2] = (-100 <= itvl <= 100);\r
+\r
+                       switch (func_selected)\r
+                       {\r
+                               case 1:\r
+                                       solver.begin(func1);\r
+                                       break;\r
+                               case 2:\r
+                                       solver.begin(func2);\r
+                                       break;\r
+                               case 3:\r
+                                       solver.begin(func3);\r
+                                       break;\r
+                       }\r
+\r
+                       reFunc();\r
+               }\r
+               private void reFunc()\r
+               {\r
+                       Data dd;\r
+                       fitted = new ObservableCollection<Data>();\r
+                       foreach (var d in data)\r
+                       {\r
+                               dd = new Data(d.abscissa, d.positive, d.negative);\r
+                               dd.c_abscissa = minimum;\r
+                               dd.c_ratio = 0.0;\r
+                               fitted.Add(dd);\r
+                       }\r
+                       switch (func_selected)\r
+                       {\r
+                               case 1:\r
+                                       for (double j = minimum; j < maximum; j += (maximum - minimum)/ 100 )\r
+                                       {\r
+                                               dd = new Data(0, 0, 0);\r
+                                               dd.c_abscissa = j;\r
+                                               dd.c_ratio = func1(j, solver.champ[0]);\r
+                                               fitted.Add(dd);\r
+                                       }\r
+                                       break;\r
+                               case 2:\r
+                                       for (double j = minimum; j < maximum; j += (maximum - minimum)/ 100 )\r
+                                       {\r
+                                               dd = new Data(0, 0, 0);\r
+                                               dd.c_abscissa = j;\r
+                                               dd.c_ratio = func2(j, solver.champ[0], solver.champ[1]);\r
+                                               fitted.Add(dd);\r
+                                       }\r
+                                       break;\r
+                               case 3:\r
+                                       for (double j = minimum; j < maximum; j += (maximum - minimum)/ 100 )\r
+                                       {\r
+                                               dd = new Data(0, 0, 0);\r
+                                               dd.c_abscissa = j;\r
+                                               dd.c_ratio = func3(j, solver.champ[0], solver.champ[1], solver.champ[2]);\r
+                                               fitted.Add(dd);\r
+                                       }\r
+                                       break;\r
+                       }\r
+\r
+\r
+                       chart1.DataContext = null;\r
+                       chart1.DataContext = fitted;\r
+\r
+                       OrdinateSlider.Maximum = 1.0;\r
+                       OrdinateSlider.Minimum = 0.0;\r
+                       OrdinateSlider.Value = 0.5;\r
+\r
+                       AbscissaSlider.Maximum = maximum;\r
+                       AbscissaSlider.Minimum = minimum;\r
+                       AbscissaSlider.Value = solver.champ[0];\r
+\r
+                       Parameter0.Text = String.Format("{0:D4}", solver.champ[0].ToString());\r
+                       Parameter1.Text = String.Format("{0, 4:F}", solver.champ[1].ToString());\r
+\r
+                       //chart1.UpdateLayout();\r
+               }\r
+\r
+               private void AddConditionButton_Click(object sender, RoutedEventArgs e)\r
+               {\r
+                       data.Add(new Data(0, 0, 0));\r
+                       this.UpdateLayout();\r
+               }\r
+\r
+               private void AbscissaSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)\r
+               {\r
+                       solver.champ[0] = AbscissaSlider.Value;\r
+                       reFunc();\r
+               }\r
+\r
+       }\r
+}\r
+\r
index 481803c..62b4e86 100644 (file)
     <Reference Include="mscorlib" />\r
     <Reference Include="system" />\r
     <Reference Include="System.Core" />\r
+    <Reference Include="System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
     <Reference Include="System.Windows.Controls.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
+    <Reference Include="System.Windows.Controls.DataVisualization.Toolkit, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
+    <Reference Include="System.Windows.Controls.Toolkit, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
     <Reference Include="System.Xml" />\r
     <Reference Include="System.Net" />\r
     <Reference Include="System.Windows.Browser" />\r
@@ -63,6 +66,9 @@
     </Reference>\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="Pages\BinomialSolver.xaml.cs">\r
+      <DependentUpon>BinomialSolver.xaml</DependentUpon>\r
+    </Compile>\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
     <Compile Include="psychlops\core\app\app.cs" />\r
     <Compile Include="psychlops\core\app\misc.cs" />\r
@@ -75,6 +81,7 @@
     <Compile Include="psychlops\core\math\interval.cs" />\r
     <Compile Include="psychlops\core\math\matrix.cs" />\r
     <Compile Include="psychlops\core\math\util.cs" />\r
+    <Compile Include="psychlops\extention\compatibility\compatibility.cs" />\r
     <Compile Include="psychlops\extention\experiments\experiments.cs" />\r
     <Compile Include="psychlops\extention\math\BigFloat.cs" />\r
     <Compile Include="psychlops\extention\math\BigInt.cs" />\r
     <Compile Include="psychlops\psychlops.cs" />\r
     <Compile Include="psychlops\core\graphic\shape.cs" />\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <Page Include="Pages\BinomialSolver.xaml">\r
+      <SubType>Designer</SubType>\r
+      <Generator>MSBuild:Compile</Generator>\r
+    </Page>\r
+  </ItemGroup>\r
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
index d271870..9165bc1 100644 (file)
@@ -1,8 +1,8 @@
 Description\r
 °°°°°°°°°°°\r
 \r
-The WriteableBitmapEx library is a collection of extension methods for Silverlight's WriteableBitmap. The WriteableBitmap class was added in Silverlight 3. It allows the direct manipulation of a bitmap and could be used to generate fast procedural images by drawing directly to a bitmap. The WriteableBitmap API is very minimalistic and there's only the raw Pixels array for such operations. The WriteableBitmapEx library tries to compensate that with extensions methods that are easy to use like built in methods. The library extends the WriteableBitmap class with elementary (2D drawing) functionality, supporting common shapes like point, line, ellipse, polyline, quad, rectangle, triangle, cubic Beziér and Cardinal spline. Conversion methods and functions to combine WriteableBitmaps (Blitting) are part of it too\r
-It is possible to use the built assembly that contains all extension methods or just specific methods by using the source CS files directly. The extension methods are grouped into multiple CS files.\r
+The WriteableBitmapEx library is a collection of extension methods for Silverlight's WriteableBitmap. The WriteableBitmap class that was added in Silverlight 3, allows the direct manipulation of a bitmap and could be used to generate fast procedural images by drawing directly to a bitmap. The WriteableBitmap API is very minimalistic and there's only the raw Pixels array for such operations. The WriteableBitmapEx library tries to compensate that with extensions methods that are easy to use like built in methods and offer GDI+ like functionality. The library extends the WriteableBitmap class with elementary and fast (2D drawing) functionality, conversion methods and functions to combine (blit) WriteableBitmaps\r
+The extension methods are grouped into different CS files with a partial class. It is possible to include just a few methods by using the specific source CS files directly or all extension methods through the built library assembly.\r
 \r
 See http://writeablebitmapex.codeplex.com\r
 \r
index 5d8eaeb..a307dd7 100644 (file)
@@ -6,9 +6,6 @@
     <members>\r
         <member name="T:System.Windows.Media.Imaging.WriteableBitmapExtensions">\r
             <summary>\r
-            Collection of blit (copy) extension methods for the Silverlight WriteableBitmap class.\r
-            </summary>\r
-            <summary>\r
             Collection of interchange extension methods for the Silverlight WriteableBitmap class.\r
             </summary>\r
             <summary>\r
             Collection of draw extension methods for the Silverlight WriteableBitmap class.\r
             </summary>\r
             <summary>\r
-            Collection of draw spline extension methods for the Silverlight WriteableBitmap class.\r
+            Collection of blit (copy) extension methods for the Silverlight WriteableBitmap class.\r
             </summary>\r
-        </member>\r
-        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode)">\r
             <summary>\r
-            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            Collection of draw extension methods for the Silverlight WriteableBitmap class.\r
             </summary>\r
-            <param name="bmp">The destination WriteableBitmap.</param>\r
-            <param name="destRect">The rectangle that defines the destination region.</param>\r
-            <param name="source">The source WriteableBitmap.</param>\r
-            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
-            <param name="BlendMode">The blending mode <see cref="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode"/>.</param>\r
-        </member>\r
-        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect)">\r
             <summary>\r
-            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            Collection of draw spline extension methods for the Silverlight WriteableBitmap class.\r
             </summary>\r
-            <param name="bmp">The destination WriteableBitmap.</param>\r
-            <param name="destRect">The rectangle that defines the destination region.</param>\r
-            <param name="source">The source WriteableBitmap.</param>\r
-            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
-        </member>\r
-        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Point,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Color,System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode)">\r
             <summary>\r
-            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            Collection of transformation extension methods for the Silverlight WriteableBitmap class.\r
             </summary>\r
-            <param name="bmp">The destination WriteableBitmap.</param>\r
-            <param name="destPosition">The destination position in the destination bitmap.</param>\r
-            <param name="source">The source WriteableBitmap.</param>\r
-            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
-            <param name="color">If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent.</param>\r
-            <param name="BlendMode">The blending mode <see cref="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode"/>.</param>\r
-        </member>\r
-        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Color,System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode)">\r
-            <summary>\r
-            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
-            </summary>\r
-            <param name="bmp">The destination WriteableBitmap.</param>\r
-            <param name="destRect">The rectangle that defines the destination region.</param>\r
-            <param name="source">The source WriteableBitmap.</param>\r
-            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
-            <param name="color">If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent.</param>\r
-            <param name="BlendMode">The blending mode <see cref="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode"/>.</param>\r
         </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.ToByteArray(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32)">\r
             <summary>\r
         </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FromByteArray(System.Windows.Media.Imaging.WriteableBitmap,System.Byte[],System.Int32,System.Int32)">\r
             <summary>\r
-            Copies color information from an ARGB byte array into the WriteableBitmap starting at a specific buffer index.\r
+            Copies color information from an ARGB byte array into this WriteableBitmap starting at a specific buffer index.\r
             </summary>\r
             <param name="bmp">The WriteableBitmap.</param>\r
             <param name="offset">The starting index in the buffer.</param>\r
             <param name="count">The number of bytes to copy from the buffer.</param>\r
             <param name="buffer">The color buffer as byte ARGB values.</param>\r
+            <returns>The WriteableBitmap that was passed as parameter.</returns>\r
         </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FromByteArray(System.Windows.Media.Imaging.WriteableBitmap,System.Byte[],System.Int32)">\r
             <summary>\r
-            Copies color information from an ARGB byte array into the WriteableBitmap.\r
+            Copies color information from an ARGB byte array into this WriteableBitmap.\r
             </summary>\r
             <param name="bmp">The WriteableBitmap.</param>\r
             <param name="count">The number of bytes to copy from the buffer.</param>\r
             <param name="buffer">The color buffer as byte ARGB values.</param>\r
+            <returns>The WriteableBitmap that was passed as parameter.</returns>\r
         </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FromByteArray(System.Windows.Media.Imaging.WriteableBitmap,System.Byte[])">\r
             <summary>\r
-            Copies all the color information from an ARGB byte array into the WriteableBitmap.\r
+            Copies all the color information from an ARGB byte array into this WriteableBitmap.\r
             </summary>\r
             <param name="bmp">The WriteableBitmap.</param>\r
             <param name="buffer">The color buffer as byte ARGB values.</param>\r
+            <returns>The WriteableBitmap that was passed as parameter.</returns>\r
         </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.WriteTga(System.Windows.Media.Imaging.WriteableBitmap,System.IO.Stream)">\r
             <summary>\r
             <param name="bmp">The WriteableBitmap.</param>\r
             <param name="destination">The destination stream.</param>\r
         </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FromResource(System.Windows.Media.Imaging.WriteableBitmap,System.String)">\r
+            <summary>\r
+            Loads an image from the applications resource file and fills this WriteableBitmap with it.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="relativePath">Only the relative path to the resource file. The assembly name is retrieved automatically.</param>\r
+            <returns>The WriteableBitmap that was passed as parameter.</returns>\r
+        </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawLineBresenham(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
             <summary>\r
             Draws a colored line by connecting two points using the Bresenham algorithm.\r
             <param name="bmp">The WriteableBitmap.</param>\r
             <param name="func">The function to apply. With parameters x, y, source color and a color as a result</param>\r
         </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.GetPixeli(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32)">\r
+            <summary>\r
+            Gets the color of the pixel at the x, y coordinate as integer.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x">The x coordinate of the pixel.</param>\r
+            <param name="y">The y coordinate of the pixel.</param>\r
+            <returns>The color of the pixel at x, y.</returns>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.GetPixel(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32)">\r
+            <summary>\r
+            Gets the color of the pixel at the x, y coordinate as a Color struct.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x">The x coordinate of the pixel.</param>\r
+            <param name="y">The y coordinate of the pixel.</param>\r
+            <returns>The color of the pixel at x, y as a Color struct.</returns>\r
+        </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.SetPixeli(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Byte,System.Byte,System.Byte)">\r
             <summary>\r
             Sets the color of the pixel using a precalculated index (faster).\r
             <param name="y">The y coordinate (column).</param>\r
             <param name="color">The color.</param>\r
         </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode)">\r
+            <summary>\r
+            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            </summary>\r
+            <param name="bmp">The destination WriteableBitmap.</param>\r
+            <param name="destRect">The rectangle that defines the destination region.</param>\r
+            <param name="source">The source WriteableBitmap.</param>\r
+            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
+            <param name="BlendMode">The blending mode <see cref="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode"/>.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect)">\r
+            <summary>\r
+            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            </summary>\r
+            <param name="bmp">The destination WriteableBitmap.</param>\r
+            <param name="destRect">The rectangle that defines the destination region.</param>\r
+            <param name="source">The source WriteableBitmap.</param>\r
+            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Point,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Color,System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode)">\r
+            <summary>\r
+            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            </summary>\r
+            <param name="bmp">The destination WriteableBitmap.</param>\r
+            <param name="destPosition">The destination position in the destination bitmap.</param>\r
+            <param name="source">The source WriteableBitmap.</param>\r
+            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
+            <param name="color">If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent.</param>\r
+            <param name="BlendMode">The blending mode <see cref="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode"/>.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Blit(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Media.Color,System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode)">\r
+            <summary>\r
+            Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).\r
+            </summary>\r
+            <param name="bmp">The destination WriteableBitmap.</param>\r
+            <param name="destRect">The rectangle that defines the destination region.</param>\r
+            <param name="source">The source WriteableBitmap.</param>\r
+            <param name="sourceRect">The rectangle that will be copied from the source to the destination.</param>\r
+            <param name="color">If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent.</param>\r
+            <param name="BlendMode">The blending mode <see cref="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode"/>.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillRectangle(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a filled rectangle.\r
+            x2 has to be greater than x1 and y2 has to be greater than y1.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the bounding rectangle's left side.</param>\r
+            <param name="y1">The y-coordinate of the bounding rectangle's top side.</param>\r
+            <param name="x2">The x-coordinate of the bounding rectangle's right side.</param>\r
+            <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param>\r
+            <param name="color">The color.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillRectangle(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)">\r
+            <summary>\r
+            Draws a filled rectangle.\r
+            x2 has to be greater than x1 and y2 has to be greater than y1.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the bounding rectangle's left side.</param>\r
+            <param name="y1">The y-coordinate of the bounding rectangle's top side.</param>\r
+            <param name="x2">The x-coordinate of the bounding rectangle's right side.</param>\r
+            <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param>\r
+            <param name="color">The color.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillEllipse(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
+            <summary>\r
+            A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf \r
+            x2 has to be greater than x1 and y2 has to be greater than y1.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the bounding rectangle's left side.</param>\r
+            <param name="y1">The y-coordinate of the bounding rectangle's top side.</param>\r
+            <param name="x2">The x-coordinate of the bounding rectangle's right side.</param>\r
+            <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param>\r
+            <param name="color">The color for the line.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillEllipse(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)">\r
+            <summary>\r
+            A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf \r
+            x2 has to be greater than x1 and y2 has to be greater than y1.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the bounding rectangle's left side.</param>\r
+            <param name="y1">The y-coordinate of the bounding rectangle's top side.</param>\r
+            <param name="x2">The x-coordinate of the bounding rectangle's right side.</param>\r
+            <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param>\r
+            <param name="color">The color for the line.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillEllipseCentered(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
+            <summary>\r
+            A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf \r
+            Uses a different parameter representation than DrawEllipse().\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="xc">The x-coordinate of the ellipses center.</param>\r
+            <param name="yc">The y-coordinate of the ellipses center.</param>\r
+            <param name="xr">The radius of the ellipse in x-direction.</param>\r
+            <param name="yr">The radius of the ellipse in y-direction.</param>\r
+            <param name="color">The color for the line.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillEllipseCentered(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)">\r
+            <summary>\r
+            A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf \r
+            Uses a different parameter representation than DrawEllipse().\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="xc">The x-coordinate of the ellipses center.</param>\r
+            <param name="yc">The y-coordinate of the ellipses center.</param>\r
+            <param name="xr">The radius of the ellipse in x-direction.</param>\r
+            <param name="yr">The radius of the ellipse in y-direction.</param>\r
+            <param name="color">The color for the line.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillPolygon(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a filled polygon. Add the first point also at the end of the array if the line should be closed.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points of the polygon in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).</param>\r
+            <param name="color">The color for the line.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillPolygon(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Int32)">\r
+            <summary>\r
+            Draws a filled polygon. Add the first point also at the end of the array if the line should be closed.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points of the polygon in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).</param>\r
+            <param name="color">The color for the line.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillQuad(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a filled quad.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the 1st point.</param>\r
+            <param name="y1">The y-coordinate of the 1st point.</param>\r
+            <param name="x2">The x-coordinate of the 2nd point.</param>\r
+            <param name="y2">The y-coordinate of the 2nd point.</param>\r
+            <param name="x3">The x-coordinate of the 3rd point.</param>\r
+            <param name="y3">The y-coordinate of the 3rd point.</param>\r
+            <param name="x4">The x-coordinate of the 4th point.</param>\r
+            <param name="y4">The y-coordinate of the 4th point.</param>\r
+            <param name="color">The color.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillQuad(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)">\r
+            <summary>\r
+            Draws a filled quad.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the 1st point.</param>\r
+            <param name="y1">The y-coordinate of the 1st point.</param>\r
+            <param name="x2">The x-coordinate of the 2nd point.</param>\r
+            <param name="y2">The y-coordinate of the 2nd point.</param>\r
+            <param name="x3">The x-coordinate of the 3rd point.</param>\r
+            <param name="y3">The y-coordinate of the 3rd point.</param>\r
+            <param name="x4">The x-coordinate of the 4th point.</param>\r
+            <param name="y4">The y-coordinate of the 4th point.</param>\r
+            <param name="color">The color.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillTriangle(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a filled triangle.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the 1st point.</param>\r
+            <param name="y1">The y-coordinate of the 1st point.</param>\r
+            <param name="x2">The x-coordinate of the 2nd point.</param>\r
+            <param name="y2">The y-coordinate of the 2nd point.</param>\r
+            <param name="x3">The x-coordinate of the 3rd point.</param>\r
+            <param name="y3">The y-coordinate of the 3rd point.</param>\r
+            <param name="color">The color.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillTriangle(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)">\r
+            <summary>\r
+            Draws a filled triangle.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x1">The x-coordinate of the 1st point.</param>\r
+            <param name="y1">The y-coordinate of the 1st point.</param>\r
+            <param name="x2">The x-coordinate of the 2nd point.</param>\r
+            <param name="y2">The y-coordinate of the 2nd point.</param>\r
+            <param name="x3">The x-coordinate of the 3rd point.</param>\r
+            <param name="y3">The y-coordinate of the 3rd point.</param>\r
+            <param name="color">The color.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.ComputeBezierPoints(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32[],System.Int32,System.Int32)">\r
+            <summary>\r
+            Draws a filled, cubic Beziér spline defined by start, end and two control points.\r
+            </summary>\r
+            <param name="x1">The x-coordinate of the start point.</param>\r
+            <param name="y1">The y-coordinate of the start point.</param>\r
+            <param name="cx1">The x-coordinate of the 1st control point.</param>\r
+            <param name="cy1">The y-coordinate of the 1st control point.</param>\r
+            <param name="cx2">The x-coordinate of the 2nd control point.</param>\r
+            <param name="cy2">The y-coordinate of the 2nd control point.</param>\r
+            <param name="x2">The x-coordinate of the end point.</param>\r
+            <param name="y2">The y-coordinate of the end point.</param>\r
+            <param name="color">The color.</param>\r
+            <param name="pixels">The pixels array.</param>\r
+            <param name="w">The width of the bitmap.</param>\r
+            <param name="h">The height of the bitmap.</param> \r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillBeziers(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a series of filled, cubic Beziér splines each defined by start, end and two control points. \r
+            The ending point of the previous curve is used as starting point for the next. \r
+            Therfore the inital curve needs four points and the subsequent 3 (2 control and 1 end point).\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillBeziers(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Int32)">\r
+            <summary>\r
+            Draws a series of filled, cubic Beziér splines each defined by start, end and two control points. \r
+            The ending point of the previous curve is used as starting point for the next. \r
+            Therfore the inital curve needs four points and the subsequent 3 (2 control and 1 end point).\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.ComputeSegmentPoints(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,System.Int32,System.Int32[],System.Int32,System.Int32)">\r
+            <summary>\r
+            Computes the discrete segment points of a Cardinal spline (cubic) defined by four control points.\r
+            </summary>\r
+            <param name="x1">The x-coordinate of the 1st control point.</param>\r
+            <param name="y1">The y-coordinate of the 1st control point.</param>\r
+            <param name="x2">The x-coordinate of the 2nd control point.</param>\r
+            <param name="y2">The y-coordinate of the 2nd control point.</param>\r
+            <param name="x3">The x-coordinate of the 3rd control point.</param>\r
+            <param name="y3">The y-coordinate of the 3rd control point.</param>\r
+            <param name="x4">The x-coordinate of the 4th control point.</param>\r
+            <param name="y4">The y-coordinate of the 4th control point.</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color.</param>\r
+            <param name="pixels">The pixels array.</param>\r
+            <param name="w">The width of the bitmap.</param>\r
+            <param name="h">The height of the bitmap.</param> \r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillCurve(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a filled Cardinal spline (cubic) defined by a point collection. \r
+            The cardinal spline passes through each point in the collection.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillCurve(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Int32)">\r
+            <summary>\r
+            Draws a filled Cardinal spline (cubic) defined by a point collection. \r
+            The cardinal spline passes through each point in the collection.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillCurveClosed(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a filled, closed Cardinal spline (cubic) defined by a point collection. \r
+            The cardinal spline passes through each point in the collection.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.FillCurveClosed(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Int32)">\r
+            <summary>\r
+            Draws a filled, closed Cardinal spline (cubic) defined by a point collection. \r
+            The cardinal spline passes through each point in the collection.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawBezier(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Windows.Media.Color)">\r
             <summary>\r
             Draws a cubic Beziér spline defined by start, end and two control points.\r
             <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).</param>\r
             <param name="color">The color for the spline.</param>\r
         </member>\r
-        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawCurve(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,System.Int32)">\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawCurveSegment(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Single,System.Int32,System.Int32[],System.Int32,System.Int32)">\r
             <summary>\r
-            Draws a Cardinal spline (cubic) defined by four control points.\r
+            Draws a segment of a Cardinal spline (cubic) defined by four control points.\r
             </summary>\r
-            <param name="bmp">The WriteableBitmap.</param>\r
             <param name="x1">The x-coordinate of the 1st control point.</param>\r
             <param name="y1">The y-coordinate of the 1st control point.</param>\r
             <param name="x2">The x-coordinate of the 2nd control point.</param>\r
             <param name="y4">The y-coordinate of the 4th control point.</param>\r
             <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
             <param name="color">The color.</param>\r
+            <param name="pixels">The pixels array.</param>\r
+            <param name="w">The width of the bitmap.</param>\r
+            <param name="h">The height of the bitmap.</param> \r
         </member>\r
         <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawCurve(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Windows.Media.Color)">\r
             <summary>\r
             <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
             <param name="color">The color for the spline.</param>\r
         </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawCurveClosed(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Windows.Media.Color)">\r
+            <summary>\r
+            Draws a closed Cardinal spline (cubic) defined by a point collection. \r
+            The cardinal spline passes through each point in the collection.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.DrawCurveClosed(System.Windows.Media.Imaging.WriteableBitmap,System.Int32[],System.Single,System.Int32)">\r
+            <summary>\r
+            Draws a closed Cardinal spline (cubic) defined by a point collection. \r
+            The cardinal spline passes through each point in the collection.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="points">The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).</param>\r
+            <param name="tension">The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.</param>\r
+            <param name="color">The color for the spline.</param>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Crop(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Int32,System.Int32)">\r
+            <summary>\r
+            Creates a new cropped WriteableBitmap.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="x">The x coordinate of the rectangle that defines the crop region.</param>\r
+            <param name="y">The y coordinate of the rectangle that defines the crop region.</param>\r
+            <param name="width">The width of the rectangle that defines the crop region.</param>\r
+            <param name="height">The height of the rectangle that defines the crop region.</param>\r
+            <returns>A new WriteableBitmap that is a cropped version of the input.</returns>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Crop(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect)">\r
+            <summary>\r
+            Creates a new cropped WriteableBitmap.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="region">The rectangle that defines the crop region.</param>\r
+            <returns>A new WriteableBitmap that is a cropped version of the input.</returns>\r
+        </member>\r
+        <member name="M:System.Windows.Media.Imaging.WriteableBitmapExtensions.Resize(System.Windows.Media.Imaging.WriteableBitmap,System.Int32,System.Int32,System.Windows.Media.Imaging.WriteableBitmapExtensions.Interpolation)">\r
+            <summary>\r
+            Creates a new resized WriteableBitmap.\r
+            </summary>\r
+            <param name="bmp">The WriteableBitmap.</param>\r
+            <param name="width">The new desired width.</param>\r
+            <param name="height">The new desired height.</param>\r
+            <param name="interpolation">The interpolation method that should be used.</param>\r
+            <returns>A new WriteableBitmap that is a resized version of the input.</returns>\r
+        </member>\r
         <member name="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode">\r
             <summary>\r
             The blending mode.\r
             </summary>\r
         </member>\r
-        <member name="F:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode.AlphaBlend">\r
+        <member name="F:System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode.Alpha">\r
             <summary>\r
             Alpha blendiing uses the alpha channel to combine the source and destination. \r
             </summary>\r
             No blending just copies the pixels from the source.\r
             </summary>\r
         </member>\r
+        <member name="T:System.Windows.Media.Imaging.WriteableBitmapExtensions.Interpolation">\r
+            <summary>\r
+            The interpolation method.\r
+            </summary>\r
+        </member>\r
+        <member name="F:System.Windows.Media.Imaging.WriteableBitmapExtensions.Interpolation.NearestNeighbor">\r
+            <summary>\r
+            The nearest neighbor algorithm simply selects the color of the nearest pixel.\r
+            </summary>\r
+        </member>\r
+        <member name="F:System.Windows.Media.Imaging.WriteableBitmapExtensions.Interpolation.Bilinear">\r
+            <summary>\r
+            Linear interpolation in 2D using the average of 3 neighboring pixels.\r
+            </summary>\r
+        </member>\r
     </members>\r
 </doc>\r
index 498272f..72956f0 100644 (file)
Binary files a/dev4/WriteableBitmapEx/WriteableBitmapEx.dll and b/dev4/WriteableBitmapEx/WriteableBitmapEx.dll differ
index 8ab76d3..cc55600 100644 (file)
Binary files a/dev4/WriteableBitmapEx/WriteableBitmapEx.pdb and b/dev4/WriteableBitmapEx/WriteableBitmapEx.pdb differ
index bc52821..f4a3ebf 100644 (file)
@@ -34,6 +34,10 @@ namespace Psychlops
                {\r
                        return lhs.ticks != rhs.ticks;\r
                }\r
+               public override int GetHashCode()\r
+               {\r
+                       return ticks.GetHashCode();\r
+               }\r
                public static bool operator >(Clock lhs, Clock rhs)\r
                {\r
                        return lhs.ticks > rhs.ticks;\r
index fdc3987..be3cbae 100644 (file)
@@ -9,11 +9,21 @@ using System.Windows.Media.Imaging;
 using System.Windows.Shapes;\r
 using System.Windows.Browser;\r
 \r
+using System.Collections.Generic;\r
+\r
 \r
 \r
 namespace Psychlops\r
 {\r
 \r
+       internal static partial class CONST\r
+       {\r
+               internal static readonly Int32 MAX_OBJ_N = 1500;\r
+               internal static readonly Int32 MOBJ_N = 1000;\r
+               internal static readonly Int32 COBJ_N = 300;\r
+               internal static readonly Int32 HOBJ_N = 100;\r
+       }\r
+\r
        namespace Templates\r
        {\r
 \r
@@ -21,105 +31,61 @@ namespace Psychlops
                {\r
 //                     protected System.Collections.Generic.Queue<Internal.PrimitiveFigure> stack;\r
                        internal Internal.PrimitiveFigure[] stack;\r
-                       internal int stackN;\r
+                       internal int stackN = 0;\r
                        internal Line[] lineStack;\r
-                       internal int lineStackN;\r
+                       internal int lineStackN = 0;\r
                        internal Rectangle[] rectStack;\r
-                       internal int rectStackN;\r
+                       internal int rectStackN = 0;\r
                        internal Ellipse[] ellipseStack;\r
-                       internal int ellipseStackN;\r
+                       internal int ellipseStackN = 0;\r
                        internal Polygon[] polygonStack;\r
-                       internal int polygonStackN;\r
+                       internal int polygonStackN = 0;\r
                        internal Letters[] lettersStack;\r
-                       internal int lettersStackN;\r
+                       internal int lettersStackN = 0;\r
                        internal Image[] imageStack;\r
-                       internal int imageStackN;\r
+                       internal int imageStackN = 0;\r
                        internal Group[] groupStack;\r
-                       internal int groupStackN;\r
+                       internal int groupStackN = 0;\r
 \r
 \r
                        public StackableDrawable()\r
                        {\r
-//                             stack = new System.Collections.Generic.Queue<Internal.PrimitiveFigure>();\r
-                               stack = new Internal.PrimitiveFigure[10000];\r
-                               lineStack = new Line[2000];\r
-                               rectStack = new Rectangle[2000];\r
-                               ellipseStack = new Ellipse[2000];\r
-                               polygonStack = new Polygon[1000];\r
-                               lettersStack = new Letters[1000];\r
-                               imageStack = new Image[100];\r
-                               groupStack = new Group[100];\r
-                               for (int i = 0; i < 2000; i++)\r
+                               stack = new Internal.PrimitiveFigure[CONST.MAX_OBJ_N];\r
+                               lineStack = new Line[CONST.MOBJ_N];\r
+                               rectStack = new Rectangle[CONST.MOBJ_N];\r
+                               ellipseStack = new Ellipse[CONST.MOBJ_N];\r
+                               polygonStack = new Polygon[CONST.COBJ_N];\r
+                               lettersStack = new Letters[CONST.COBJ_N];\r
+                               imageStack = new Image[CONST.HOBJ_N];\r
+                               groupStack = new Group[CONST.HOBJ_N];\r
+                               for (int i = 0; i < CONST.MOBJ_N; i++)\r
                                {\r
                                        lineStack[i] = new Line(0,0,0,0);\r
                                        rectStack[i] = new Rectangle();\r
                                        ellipseStack[i] = new Ellipse();\r
                                }\r
-                               for (int i = 0; i < 1000; i++)\r
+                               for (int i = 0; i < CONST.COBJ_N; i++)\r
                                {\r
                                        polygonStack[i] = new Polygon();\r
                                        lettersStack[i] = new Letters();\r
                                }\r
-                               for (int i = 0; i < 100; i++)\r
+                               for (int i = 0; i < CONST.HOBJ_N; i++)\r
                                {\r
                                        imageStack[i] = new Image(1, 1);\r
                                        groupStack[i] = new Group();\r
                                }\r
                        }\r
 \r
-                       public void clear()\r
-                       {\r
-                               clear(Color.black);\r
-                       }\r
-                       public virtual void clear(Color col)\r
-                       {\r
-                               //rect(back_panel, col);\r
-                       }\r
-\r
-                       public virtual void pix(int x, int y, Color col)\r
-                       {\r
-                       }\r
-\r
-                       public virtual void line(Line drawee)\r
-                       {\r
-                               //                              stack.Enqueue(drawee.clone());\r
-                               drawee.copyToStack(this);\r
-                       }\r
-\r
-                       public virtual void rect(Rectangle drawee)\r
-                       {\r
-                               //stack.Enqueue(drawee.clone());\r
-//                             stack.Enqueue(drawee.copyToStack(this));\r
-                               drawee.copyToStack(this);\r
-                       }\r
-\r
-                       public virtual void ellipse(Ellipse drawee)\r
-                       {\r
-                               //                              stack.Enqueue(drawee.clone());\r
-                               drawee.copyToStack(this);\r
-                       }\r
-\r
-                       public virtual void polygon(Polygon drawee)\r
-                       {\r
-                               //                              stack.Enqueue(drawee.clone());\r
-                               drawee.copyToStack(this);\r
-                       }\r
-\r
-                       public virtual void letters(Letters drawee)\r
-                       {\r
-                               //                              stack.Enqueue(drawee.clone());\r
-                               drawee.copyToStack(this);\r
-                       }\r
-\r
-                       public virtual void image(Image drawee)\r
-                       {\r
-                               //                              stack.Enqueue(drawee.clone());\r
-                               drawee.copyToStack(this);\r
-                       }\r
-                       public virtual void group(Group drawee)\r
-                       {\r
-                               drawee.copyToStack(this);\r
-                       }\r
+                       public void clear() { clear(Color.black); }\r
+                       public virtual void clear(Color col) { } //rect(back_panel, col); }\r
+                       public virtual void pix(int x, int y, Color col) { }\r
+                       public virtual void line(Line drawee) { drawee.copyToStack(this); }\r
+                       public virtual void rect(Rectangle drawee) { drawee.copyToStack(this); }\r
+                       public virtual void ellipse(Ellipse drawee) { drawee.copyToStack(this); }\r
+                       public virtual void polygon(Polygon drawee) { drawee.copyToStack(this); }\r
+                       public virtual void letters(Letters drawee) { drawee.copyToStack(this); }\r
+                       public virtual void image(Image drawee) { drawee.copyToStack(this); }\r
+                       public virtual void group(Group drawee) { drawee.copyToStack(this); }\r
 \r
                        public void msg(string str, double x, double y) { msg(str, x, y, Color.white); }\r
                        public virtual void msg(string dstr, double x, double y, Color col)\r
@@ -139,7 +105,6 @@ namespace Psychlops
 \r
        public class Canvas : Templates.StackableDrawable\r
        {\r
-\r
                internal System.Windows.Controls.Canvas masterPool, prevPool;\r
                internal System.Windows.Point[] pointPool;\r
                internal int pointPoolN;\r
@@ -148,6 +113,7 @@ namespace Psychlops
 \r
                internal System.Windows.Controls.Canvas[] UIElementPool;\r
                internal int UIElementPoolN;\r
+               internal int lastVisibleN;\r
 \r
                internal System.Windows.Shapes.Line[] linePool;\r
                internal int linePoolN;\r
@@ -162,6 +128,7 @@ namespace Psychlops
                internal int lettersPoolN;\r
                internal System.Windows.Controls.Image[] imagePool;\r
                internal int imagePoolN;\r
+               internal Dictionary<int, bool> imagePoolT;\r
                internal System.Windows.Controls.Canvas[] groupPool;\r
                internal int groupPoolN;\r
 \r
@@ -171,14 +138,11 @@ namespace Psychlops
                internal delegate void SimpleProcedure();\r
                SimpleProcedure flipexec;\r
 \r
-               //public static System.Windows.Controls.Image default_buffer_frame;\r
                public static System.Windows.Controls.UserControl default_panel;\r
                public static System.Windows.Controls.Canvas default_api_canvas;\r
                public static WriteableBitmap default_buffer;\r
-               //WriteableBitmap buffer;\r
-               //System.Windows.Controls.Image instance;\r
-               System.Windows.Controls.Canvas api_canvas;\r
-               System.Windows.Controls.UserControl panel;\r
+               internal System.Windows.Controls.Canvas api_canvas;\r
+               internal System.Windows.Controls.UserControl panel;\r
                Rectangle back_panel;\r
                double width_, height_;\r
                Clock before;\r
@@ -234,79 +198,79 @@ namespace Psychlops
                        htmlHost.SetStyleAttribute("height", (20+hei).ToString() + "px");\r
                        htmlHost.SetStyleAttribute("margin", "2em auto auto auto");\r
 \r
-                       UIElementPool = new System.Windows.Controls.Canvas[2000];\r
-                       pointPool = new System.Windows.Point[2000];\r
-                       brushPool = new SolidColorBrush[2000];\r
-                       linePool = new System.Windows.Shapes.Line[2000];\r
-                       rectPool = new System.Windows.Shapes.Rectangle[2000];\r
-                       dummyRectPool = new System.Windows.Shapes.Rectangle[2000];\r
-                       ellipsePool = new System.Windows.Shapes.Ellipse[2000];\r
-                       for (int i = 0; i < 2000; i++)\r
+                       pointPool = new System.Windows.Point[CONST.MOBJ_N];\r
+                       brushPool = new SolidColorBrush[CONST.MOBJ_N];\r
+                       linePool = new System.Windows.Shapes.Line[CONST.MOBJ_N];\r
+                       rectPool = new System.Windows.Shapes.Rectangle[CONST.MOBJ_N];\r
+                       ellipsePool = new System.Windows.Shapes.Ellipse[CONST.MOBJ_N];\r
+                       for (int i = 0; i < CONST.MOBJ_N; i++)\r
                        {\r
-                               UIElementPool[i] = new System.Windows.Controls.Canvas();\r
                                pointPool[i] = new System.Windows.Point();\r
                                brushPool[i] = new SolidColorBrush();\r
                                linePool[i] = new System.Windows.Shapes.Line();\r
                                rectPool[i] = new System.Windows.Shapes.Rectangle();\r
-                               dummyRectPool[i] = new System.Windows.Shapes.Rectangle();\r
                                ellipsePool[i] = new System.Windows.Shapes.Ellipse();\r
                        }\r
-                       polygonPool = new System.Windows.Shapes.Polygon[1000];\r
-                       lettersPool = new System.Windows.Controls.TextBlock[1000];\r
-                       for (int i = 0; i < 1000; i++)\r
+                       polygonPool = new System.Windows.Shapes.Polygon[CONST.COBJ_N];\r
+                       lettersPool = new System.Windows.Controls.TextBlock[CONST.COBJ_N];\r
+                       for (int i = 0; i < CONST.COBJ_N; i++)\r
                        {\r
                                polygonPool[i] = new System.Windows.Shapes.Polygon();\r
                                lettersPool[i] = new System.Windows.Controls.TextBlock();\r
                        }\r
-                       imagePool = new System.Windows.Controls.Image[100];\r
-                       groupPool = new System.Windows.Controls.Canvas[100];\r
-                       for (int i = 0; i < 100; i++)\r
+                       imagePool = new System.Windows.Controls.Image[CONST.HOBJ_N];\r
+                       imagePoolT = new Dictionary<int, bool>(CONST.HOBJ_N);\r
+                       groupPool = new System.Windows.Controls.Canvas[CONST.HOBJ_N];\r
+                       for (int i = 0; i < CONST.HOBJ_N; i++)\r
                        {\r
                                imagePool[i] = new System.Windows.Controls.Image();\r
+                               imagePoolT.Add(imagePool[i].GetHashCode(), false);\r
                                groupPool[i] = new System.Windows.Controls.Canvas();\r
                        }\r
 \r
                        masterPool = new System.Windows.Controls.Canvas();\r
                        prevPool = new System.Windows.Controls.Canvas();\r
                        api_canvas.Children.Add(masterPool);\r
+\r
                        //api_canvas.Children.Remove(Internal.Main.widgetStack);\r
+                       Psychlops.Internal.Main.widgetStack = new StackPanel();\r
+                       Psychlops.Internal.Main.widgetStack.Orientation = Orientation.Vertical;\r
+                       Psychlops.Internal.Main.widgetStack.Height = hei;\r
+                       api_canvas.Children.Add(Psychlops.Internal.Main.widgetStack);\r
+                       \r
+\r
 \r
-                       for (int i = 0; i < 2000; i++)\r
+                       UIElementPool = new System.Windows.Controls.Canvas[CONST.MAX_OBJ_N];\r
+                       dummyRectPool = new System.Windows.Shapes.Rectangle[CONST.MAX_OBJ_N];\r
+                       for (int i = 0; i < CONST.MAX_OBJ_N; i++)\r
                        {\r
+                               UIElementPool[i] = new System.Windows.Controls.Canvas();\r
                                masterPool.Children.Add(UIElementPool[i]);\r
+                               dummyRectPool[i] = new System.Windows.Shapes.Rectangle();\r
                                UIElementPool[i].Children.Add(dummyRectPool[i]);\r
+                               dummyRectPool[i].Visibility = Visibility.Collapsed;\r
                        }\r
 \r
 \r
                        AsyncInitBool = true;\r
                }\r
 \r
+               internal int findEmptyInPool(Dictionary<int, bool> pool)\r
+               {\r
+                       /*\r
+                       foreach( KeyValuePair<int, bool> elem in pool)\r
+                       {\r
+                               if(elem) \r
+                       }*/\r
+                       return 0;\r
+               }\r
+\r
                #endregion\r
 \r
                #region static initializer\r
                /*\r
-               static System.Windows.Shapes.Line api_line;\r
-               static System.Windows.Shapes.Path api_curve;\r
-               static System.Windows.Shapes.Rectangle api_rect;\r
-               static System.Windows.Shapes.Ellipse api_ellipse;\r
-               static System.Windows.Shapes.Polygon api_polygon;\r
-               static System.Windows.Shapes.Polyline api_polyline;\r
-               static System.Windows.Media.Color api_color;\r
-               static System.Windows.Media.SolidColorBrush api_fill;\r
-               static System.Windows.Media.SolidColorBrush api_stroke;\r
-               static System.Windows.Media.TranslateTransform api_translation;\r
                static Canvas()\r
                {\r
-                       api_line = new System.Windows.Shapes.Line();\r
-                       api_curve    = new System.Windows.Shapes.Path();\r
-                       api_rect     = new System.Windows.Shapes.Rectangle();\r
-                       api_ellipse  = new System.Windows.Shapes.Ellipse();\r
-                       api_polygon  = new System.Windows.Shapes.Polygon();\r
-                       api_polyline = new System.Windows.Shapes.Polyline();\r
-                       api_color       = new System.Windows.Media.Color();\r
-                       api_fill        = new System.Windows.Media.SolidColorBrush();\r
-                       api_stroke      = new System.Windows.Media.SolidColorBrush();\r
-                       api_translation = new System.Windows.Media.TranslateTransform();\r
                }\r
                */\r
                #endregion\r
@@ -328,7 +292,6 @@ namespace Psychlops
                                chacked = 1;\r
                        }\r
                        //pointStackN = 0;\r
-                       //brushStackN = 0;\r
                        lineStackN = 0;\r
                        rectStackN = 0;\r
                        polygonStackN = 0;\r
@@ -337,6 +300,8 @@ namespace Psychlops
                        imageStackN = 0;\r
                        groupStackN = 0;\r
 \r
+                       UIElementPoolN = 0;\r
+                       brushPoolN = 0;\r
                        /*\r
                        pointPoolN = 0;\r
                        brushPoolN = 0;\r
@@ -385,113 +350,109 @@ namespace Psychlops
                                nextIntervalFrame--;\r
                        }\r
 \r
-\r
-\r
-                       var en = masterPool.Children.GetEnumerator();\r
-                       bool full = en.MoveNext();\r
-                       var cnv = en.Current as System.Windows.Controls.Canvas;\r
+                       var cnv = UIElementPool[0];\r
                        if (nextIntervalFrame <= 0)\r
                        {\r
                                if (chacked > 0)\r
                                {\r
                                        if (stackN > 0)\r
                                        {\r
-                                               for (int i = 0; i < stackN - 2; i++)\r
+                                               for (int i = 0; i < stackN; i++)\r
                                                {\r
-                                                       if (full == false)\r
+                                                       if( null != (rectS = stack[i] as Rectangle) )\r
                                                        {\r
-                                                               break;\r
+                                                               if (null != (rectP = cnv.Children[0] as System.Windows.Shapes.Rectangle))\r
+                                                               {\r
+                                                                       rectS.modifyNative(rectP, this);\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
+                                                               }\r
                                                        }\r
-                                                       else\r
+                                                       else if (null != (lineS = stack[i] as Line))\r
                                                        {\r
-                                                               if( null != (rectS = stack[i] as Rectangle) )\r
+                                                               if (null != (lineP = cnv.Children[0] as System.Windows.Shapes.Line))\r
                                                                {\r
-                                                                       if (null != (rectP = cnv.Children[0] as System.Windows.Shapes.Rectangle))\r
-                                                                       {\r
-                                                                               rectS.modifyNative(rectP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       lineS.modifyNative(lineP, this);\r
                                                                }\r
-                                                               else if (null != (lineS = stack[i] as Line))\r
+                                                               else\r
                                                                {\r
-                                                                       if (null != (lineP = cnv.Children[0] as System.Windows.Shapes.Line))\r
-                                                                       {\r
-                                                                               lineS.modifyNative(lineP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
                                                                }\r
-                                                               else if (null != (ellipseS = stack[i] as Ellipse))\r
+                                                       }\r
+                                                       else if (null != (ellipseS = stack[i] as Ellipse))\r
+                                                       {\r
+                                                               if (null != (ellipseP = cnv.Children[0] as System.Windows.Shapes.Ellipse))\r
                                                                {\r
-                                                                       if (null != (ellipseP = cnv.Children[0] as System.Windows.Shapes.Ellipse))\r
-                                                                       {\r
-                                                                               ellipseS.modifyNative(ellipseP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       ellipseS.modifyNative(ellipseP, this);\r
                                                                }\r
-                                                               else if (null != (polygonS = stack[i] as Polygon))\r
+                                                               else\r
                                                                {\r
-                                                                       if (null != (polygonP = cnv.Children[0] as System.Windows.Shapes.Polygon))\r
-                                                                       {\r
-                                                                               polygonS.modifyNative(polygonP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
                                                                }\r
-                                                               else if (null != (lettersS = stack[i] as Letters))\r
+                                                       }\r
+                                                       else if (null != (polygonS = stack[i] as Polygon))\r
+                                                       {\r
+                                                               if (null != (polygonP = cnv.Children[0] as System.Windows.Shapes.Polygon))\r
                                                                {\r
-                                                                       if (null != (lettersP = cnv.Children[0] as System.Windows.Controls.TextBlock))\r
-                                                                       {\r
-                                                                               lettersS.modifyNative(lettersP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       polygonS.modifyNative(polygonP, this);\r
                                                                }\r
-                                                               else if (null != (imageS = stack[i] as Image))\r
+                                                               else\r
                                                                {\r
-                                                                       if (null != (imageP = cnv.Children[0] as System.Windows.Controls.Image))\r
-                                                                       {\r
-                                                                               imageS.modifyNative(imageP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
                                                                }\r
-                                                               else if (null != (groupS = stack[i] as Group))\r
+                                                       }\r
+                                                       else if (null != (lettersS = stack[i] as Letters))\r
+                                                       {\r
+                                                               if (null != (lettersP = cnv.Children[0] as System.Windows.Controls.TextBlock))\r
                                                                {\r
-                                                                       if (null != (groupP = cnv.Children[0] as System.Windows.Controls.Canvas))\r
-                                                                       {\r
-                                                                               groupS.modifyNative(groupP, this);\r
-                                                                       }\r
-                                                                       else\r
-                                                                       {\r
-                                                                               cnv.Children.Clear();\r
-                                                                               cnv.Children.Add(stack[i].poolNative(this));\r
-                                                                       }\r
+                                                                       lettersS.modifyNative(lettersP, this);\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
+                                                               }\r
+                                                       }\r
+                                                       else if (null != (imageS = stack[i] as Image))\r
+                                                       {\r
+                                                               if (null != (imageP = cnv.Children[0] as System.Windows.Controls.Image))\r
+                                                               {\r
+                                                                       imageS.modifyNative(imageP, this);\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
                                                                }\r
-                                                               full = en.MoveNext();\r
-                                                               cnv = en.Current as System.Windows.Controls.Canvas;\r
                                                        }\r
+                                                       else if (null != (groupS = stack[i] as Group))\r
+                                                       {\r
+                                                               if (null != (groupP = cnv.Children[0] as System.Windows.Controls.Canvas))\r
+                                                               {\r
+                                                                       groupS.modifyNative(groupP, this);\r
+                                                               }\r
+                                                               else\r
+                                                               {\r
+                                                                       cnv.Children.Clear();\r
+                                                                       cnv.Children.Add(stack[i].poolNative(this));\r
+                                                               }\r
+                                                       }\r
+                                                       cnv.Visibility = Visibility.Visible;\r
+                                                       UIElementPoolN++;\r
+                                                       cnv = UIElementPool[UIElementPoolN];\r
+                                               }\r
+                                               for (int i = UIElementPoolN; i < lastVisibleN; i++)\r
+                                               {\r
+                                                       cnv = UIElementPool[i];\r
+                                                       cnv.Visibility = Visibility.Collapsed;\r
                                                }\r
+                                               lastVisibleN = UIElementPoolN;\r
                                                stackN = 0;\r
                                        }\r
                                        lock (this)\r
@@ -676,12 +637,46 @@ namespace Psychlops
                #endregion\r
 \r
 \r
+               #region compatibitily trick\r
+\r
+               public enum Mode { window, fullscreen }\r
+               public static readonly Mode window = Mode.window, fullscreen = Mode.fullscreen;\r
+\r
+               public Canvas(int wid, int hei, Mode mod)\r
+               {\r
+                       panel = default_panel;\r
+                       api_canvas = default_api_canvas;\r
+                       initialize(500, 500);\r
+               }\r
+               public Canvas(Mode mod) : base()\r
+               {\r
+                       panel = default_panel;\r
+                       api_canvas = default_api_canvas;\r
+                       initialize(500, 500);\r
+               }\r
+\r
+\r
+               public void showFPS(bool sw = true) { }\r
+               public void watchFPS(bool sw = true) { }\r
+\r
+\r
+               public void clear(double lum)\r
+               {\r
+                       clear(new Color(lum));\r
+               }\r
+\r
+               #endregion\r
+\r
+\r
        }\r
 \r
 \r
 \r
        #region primitive tokenizer\r
 \r
+\r
+       #region primitive\r
+\r
        partial struct Point\r
        {\r
                public static implicit operator System.Windows.Point(Point d)\r
@@ -700,6 +695,14 @@ namespace Psychlops
                {\r
                        return new SolidColorBrush { Color = d };\r
                }\r
+               public System.Windows.Media.SolidColorBrush getNativeFromStack(Canvas d)\r
+               {\r
+                       var tmp = d.brushPool[d.brushPoolN];\r
+                       tmp.Color = this;\r
+                       d.brushPoolN++;\r
+                       return tmp;\r
+               }\r
+\r
        }\r
 \r
        partial struct Stroke\r
@@ -714,7 +717,18 @@ namespace Psychlops
                {\r
                        return new SolidColorBrush { Color = d.color };\r
                }\r
+               public System.Windows.Media.SolidColorBrush getNativeFromStack(Canvas d)\r
+               {\r
+                       var tmp = d.brushPool[d.brushPoolN];\r
+                       tmp.Color = this.color;\r
+                       d.brushPoolN++;\r
+                       return tmp;\r
+               }\r
        }\r
+       \r
+       #endregion\r
+       \r
+       #region Line\r
 \r
        partial class Line\r
        {\r
@@ -755,7 +769,7 @@ namespace Psychlops
                        tmp.Y1 = begin.y;\r
                        tmp.X2 = end.x;\r
                        tmp.Y2 = end.y;\r
-                       if (stroke.thick == 0.0) tmp.Stroke = fill;\r
+                       if (stroke.thick == 0.0) tmp.Stroke = fill.getNativeFromStack(d);\r
                        else stroke.apply(tmp);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, top);\r
@@ -769,13 +783,17 @@ namespace Psychlops
                        tmp.Y1 = begin.y;\r
                        tmp.X2 = end.x;\r
                        tmp.Y2 = end.y;\r
-                       if (stroke.thick == 0.0) tmp.Stroke = fill;\r
+                       if (stroke.thick == 0.0) tmp.Stroke = fill.getNativeFromStack(d);\r
                        else stroke.apply(tmp);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, top);\r
                        tmp.Visibility = Visibility.Visible;\r
                }\r
        }\r
+       \r
+       #endregion\r
+               \r
+       #region Rectangle\r
 \r
        partial class Rectangle\r
        {\r
@@ -816,7 +834,7 @@ namespace Psychlops
                        var tmp = d.rectPool[d.rectPoolN];\r
                        tmp.Width = width;\r
                        tmp.Height = height;\r
-                       tmp.Fill = fill;\r
+                       tmp.Fill = fill.getNativeFromStack(d);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, top);\r
                        tmp.Visibility = Visibility.Visible;\r
@@ -827,12 +845,16 @@ namespace Psychlops
                {\r
                        tmp.Width = width;\r
                        tmp.Height = height;\r
-                       tmp.Fill = fill;\r
+                       tmp.Fill = fill.getNativeFromStack(d);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, top);\r
                        tmp.Visibility = Visibility.Visible;\r
                }\r
        }\r
+       \r
+       #endregion\r
+\r
+       #region Ellipse\r
 \r
        partial class Ellipse\r
        {\r
@@ -871,7 +893,7 @@ namespace Psychlops
                        var tmp = d.ellipsePool[d.ellipsePoolN];\r
                        tmp.Width = width;\r
                        tmp.Height = height;\r
-                       tmp.Fill = fill;\r
+                       tmp.Fill = fill.getNativeFromStack(d);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, top);\r
                        tmp.Visibility = Visibility.Visible;\r
@@ -882,13 +904,17 @@ namespace Psychlops
                {\r
                        tmp.Width = width;\r
                        tmp.Height = height;\r
-                       tmp.Fill = fill;\r
+                       tmp.Fill = fill.getNativeFromStack(d);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, top);\r
                        tmp.Visibility = Visibility.Visible;\r
                }\r
        }\r
 \r
+       #endregion\r
+\r
+       #region Polygon\r
+\r
        partial class Polygon\r
        {\r
                public Polygon dup()\r
@@ -930,7 +956,7 @@ namespace Psychlops
                public UIElement poolNative(Canvas d)\r
                {\r
                        var tmp = d.polygonPool[d.polygonPoolN];\r
-                       tmp.Fill = fill;\r
+                       tmp.Fill = fill.getNativeFromStack(d);\r
                        tmp.Points.Clear();\r
                        foreach (var v in vertices)\r
                        {\r
@@ -944,7 +970,7 @@ namespace Psychlops
                }\r
                public void modifyNative(System.Windows.Shapes.Polygon tmp, Canvas d)\r
                {\r
-                       tmp.Fill = fill;\r
+                       tmp.Fill = fill.getNativeFromStack(d);\r
                        tmp.Points.Clear();\r
                        foreach (var v in vertices)\r
                        {\r
@@ -956,7 +982,11 @@ namespace Psychlops
                }\r
 \r
        }\r
-       \r
+               \r
+       #endregion\r
+\r
+       #region Letters\r
+\r
        partial class Letters\r
        {\r
                #region static initializer\r
@@ -1033,7 +1063,7 @@ namespace Psychlops
                        tmp.FontStyle = FONT_STYLE_BRIDGE[font.style];\r
                        tmp.FontWeight = FONT_WEIGHT_BRIDGE[font.weight];\r
                        tmp.TextAlignment = LETTERS_H_ALIGN_BRIDGE[align];\r
-                       tmp.Foreground = fill;\r
+                       tmp.Foreground = fill.getNativeFromStack(d);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
                        tmp.Visibility = Visibility.Visible;\r
@@ -1050,25 +1080,66 @@ namespace Psychlops
                        tmp.FontStyle = FONT_STYLE_BRIDGE[font.style];\r
                        tmp.FontWeight = FONT_WEIGHT_BRIDGE[font.weight];\r
                        tmp.TextAlignment = LETTERS_H_ALIGN_BRIDGE[align];\r
-                       tmp.Foreground = fill;\r
+                       tmp.Foreground = fill.getNativeFromStack(d);\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
                        System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
                        tmp.Visibility = Visibility.Visible;\r
                }\r
        }\r
+       \r
+       #endregion\r
+       \r
+       #region Image\r
 \r
        partial class Image\r
        {\r
                internal void initialize__(int wid, int hei)\r
                {\r
+                       AsyncBool = false;\r
                        Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Canvas.TwoIntProcedure(create__), wid, hei);\r
-                       //buffer = new WriteableBitmap(wid, hei);\r
+                       while (!AsyncBool) { System.Threading.Thread.Sleep(10); }\r
                }\r
                internal void create__(int wid, int hei)\r
                {\r
                        buffer = new WriteableBitmap(wid, hei);\r
                        AsyncBool = true;\r
                }\r
+               internal void load__(string uri)\r
+               {\r
+                       AsyncBool = false;\r
+                       var ur = new System.Uri(uri,  System.UriKind.RelativeOrAbsolute);\r
+                       Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Action<Uri>(load_), ur);\r
+                       while (!AsyncBool) { System.Threading.Thread.Sleep(10); }\r
+               }\r
+               internal void load_(Uri uri)\r
+               {\r
+                       var bitmap = new BitmapImage();\r
+                       bitmap.CreateOptions = BitmapCreateOptions.None;\r
+                       bitmap.UriSource = uri;\r
+                       try\r
+                       {\r
+                               var wbm = new System.Windows.Media.Imaging.WriteableBitmap(bitmap);\r
+                               buffer = wbm;\r
+                       }\r
+                       catch (Exception e)\r
+                       {\r
+                               buffer = new WriteableBitmap(64, 64);\r
+                               buffer.ForEach(bitmap_drawChecker);\r
+                       }\r
+                       self_rect.set(buffer.PixelWidth, buffer.PixelHeight);\r
+                       AsyncBool = true;\r
+               }\r
+               static System.Windows.Media.Color[] CHECKER_C;\r
+               static Image()\r
+               {\r
+                       CHECKER_C = new System.Windows.Media.Color[2];\r
+                       CHECKER_C[0] = System.Windows.Media.Color.FromArgb(0, 0, 0, 0);\r
+                       CHECKER_C[1] = System.Windows.Media.Color.FromArgb(128,128,128,128);\r
+               }\r
+               static System.Windows.Media.Color bitmap_drawChecker(int x, int y)\r
+               {\r
+                       return ((x / 4) + (y / 4)) % 2 == 0 ? CHECKER_C[0] : CHECKER_C[1];\r
+               }\r
                delegate void FieldFunc1(System.Func<int, int, System.Windows.Media.Color> func);\r
                delegate void FieldFunc2(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func);\r
                public void field__(System.Func<int, int, System.Windows.Media.Color> func)\r
@@ -1134,6 +1205,9 @@ namespace Psychlops
 \r
        }\r
 \r
+       #endregion\r
+\r
+       #region Group\r
 \r
        partial class Group\r
        {\r
@@ -1215,6 +1289,7 @@ namespace Psychlops
                }\r
 \r
        }\r
+       #endregion\r
        \r
        #endregion\r
 \r
index 6d5f3f5..f4c48d9 100644 (file)
@@ -21,12 +21,23 @@ namespace Psychlops{
                public Rectangle self_rect;\r
                protected bool AsyncBool;\r
 \r
+               public Image(string uri)\r
+               {\r
+                       self_rect = new Rectangle();\r
+                       load__(uri);\r
+               }\r
+\r
                public Image(int wid, int hei)\r
                {\r
-                       AsyncBool = false;\r
+                       self_rect = new Rectangle(wid, hei);\r
                        initialize__(wid, hei);\r
+               }\r
+\r
+               public Image set(int wid, int hei)\r
+               {\r
                        self_rect = new Rectangle(wid, hei);\r
-                       while (!AsyncBool) { }\r
+                       initialize__(wid, hei);\r
+                       return this;\r
                }\r
 \r
                public Figure shift(Point p)\r
@@ -53,22 +64,23 @@ namespace Psychlops{
                public void field(System.Func<int, int, System.Windows.Media.Color> func)\r
                {\r
                        field__(func);\r
-                       //buffer.ForEach(func);\r
                }\r
                public void field(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)\r
                {\r
                        field__(func);\r
-                       //buffer.ForEach(func);\r
                }\r
                public void each(System.Func<int, int, System.Windows.Media.Color> func)\r
                {\r
                        field__(func);\r
-                       //buffer.ForEach(func);\r
                }\r
                public void each(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func)\r
                {\r
                        field__(func);\r
-                       //buffer.ForEach(func);\r
+               }\r
+\r
+               public void load(string uri)\r
+               {\r
+                       load__(uri);\r
                }\r
 \r
                public void draw()\r
index 9cebe91..23cbeca 100644 (file)
@@ -19,6 +19,10 @@ namespace Psychlops{
        }\r
        public static class ShapeExtention\r
        {\r
+               public static void draw(this Shape drawee, double c)\r
+               {\r
+                       drawee.draw( new Color(c) );\r
+               }\r
                public static void draw(this Shape drawee, Color c)\r
                {\r
                        Color tmp_col = drawee.fill;\r
index 6426046..843338f 100644 (file)
@@ -9,66 +9,92 @@ namespace Psychlops
                public enum OPERATOR { CLOSE, OPEN };\r
                public const OPERATOR CLOSE = OPERATOR.CLOSE, OPEN = OPERATOR.OPEN;\r
                public struct VAL {\r
-                       public double val;\r
+                       public double value;\r
                        public OPERATOR op;\r
+                       /*public VAL()\r
+                       {\r
+                               val = Double.NaN;\r
+                               op = OPERATOR.CLOSE;\r
+                       }*/\r
                        public VAL(double v, OPERATOR o)\r
                        {\r
-                               val = v;\r
+                               value = v;\r
                                op = o;\r
                        }\r
                        public bool bounded()\r
                        {\r
-                               return !Double.IsNaN(val) && (!Double.IsInfinity(val) || op == OPERATOR.OPEN);\r
+                               return !Double.IsNaN(value) && (!Double.IsInfinity(value) || op == OPERATOR.OPEN);\r
                        }\r
                }\r
                public VAL begin, end;\r
 \r
-               /*\r
-               public Interval()\r
+               \r
+               /*public Interval()\r
                {\r
                        begin = new VAL { val = Double.PositiveInfinity, op = OPERATOR.CLOSE };\r
                        end = new VAL { val = Double.NegativeInfinity, op = OPERATOR.CLOSE };\r
-               }\r
-               */\r
+               }*/\r
                public Interval(double floor_val, double ceil_val)\r
                {\r
-                       begin.val = floor_val;\r
+                       begin.value = floor_val;\r
                        begin.op =  OPERATOR.CLOSE;\r
-                       end.val = ceil_val;\r
+                       end.value = ceil_val;\r
                        end.op = OPERATOR.CLOSE;\r
                }\r
                public Interval(double floor_val, OPERATOR floor_op, double ceil_val, OPERATOR ceil_op)\r
                {\r
-                       begin.val = floor_val;\r
+                       begin.value = floor_val;\r
                        begin.op = floor_op;\r
-                       end.val = ceil_val;\r
+                       end.value = ceil_val;\r
                        end.op = ceil_op;\r
                }\r
 \r
-               /*\r
-               public int int_floor();\r
-               public int int_floor(int minval);\r
-               public int int_ceil();\r
-               public int int_ceil(int maxval);\r
-               */\r
+\r
+               public int int_floor()\r
+               {\r
+                       double v = Math.ceil(begin.value);\r
+                       if (begin.op == OPEN && v == begin.value) { return (int)v + 1; }\r
+                       else return (int)v;\r
+               }\r
+               public int int_floor(int minval)\r
+               {\r
+                       if(begin.value<minval) return minval;\r
+                       double v = Math.ceil(begin.value);\r
+                       if (begin.op == OPEN && v == begin.value) { return (int)v + 1; }\r
+                       else return (int)v;\r
+               }\r
+               public int int_ceil()\r
+               {\r
+                       double v = Math.floor(end.value);\r
+                       if (end.op == OPEN && v == end.value) { return (int)v - 1; }\r
+                       else return (int)v;\r
+               }\r
+               public int int_ceil(int maxval)\r
+               {\r
+                       if(end.value>maxval) return maxval;\r
+                       double v = Math.floor(end.value);\r
+                       if (end.op == OPEN && v == end.value) { return (int)v - 1; }\r
+                       else return (int)v;\r
+               }\r
+               \r
                bool includes(double val)\r
                {\r
                        bool result = false;\r
                        switch(begin.op) {\r
                                case OPERATOR.CLOSE:\r
-                               result = begin.val<=val ? true : false;\r
-                               break;\r
+                                       result = begin.value <= val ? true : false;\r
+                                       break;\r
                                case OPERATOR.OPEN:\r
-                               result = begin.val<val ? true : false;\r
-                               break;\r
+                                       result = begin.value < val ? true : false;\r
+                                       break;\r
                        }\r
                        switch(end.op) {\r
                                case OPERATOR.CLOSE:\r
-                               result = result && ( end.val>=val ? true : false );\r
-                               break;\r
+                                       result = result && (end.value >= val ? true : false);\r
+                                       break;\r
                                case OPERATOR.OPEN:\r
-                               result = result && ( end.val>val ? true : false );\r
-                               break;\r
+                                       result = result && (end.value > val ? true : false);\r
+                                       break;\r
                        }\r
                        return result;\r
                }\r
@@ -84,13 +110,13 @@ namespace Psychlops
                        //                      return new IntervalIEnumerable(this, steps);\r
                        Interval it = this;\r
                        long front_step = (it.begin.op == Interval.OPERATOR.CLOSE ? -1 : 0);\r
-                       long back_step = (long)System.Math.Floor((it.end.val - it.begin.val) / steps);\r
-                       if (it.end.op == Interval.OPERATOR.OPEN && 0 == System.Math.IEEERemainder(it.end.val - it.begin.val, steps))\r
+                       long back_step = (long)System.Math.Floor((it.end.value - it.begin.value) / steps);\r
+                       if (it.end.op == Interval.OPERATOR.OPEN && 0 == System.Math.IEEERemainder(it.end.value - it.begin.value, steps))\r
                        {\r
                                back_step -= 1;\r
                        }\r
                        while (front_step <= back_step)\r
-                               yield return steps * front_step + it.begin.val;\r
+                               yield return steps * front_step + it.begin.value;\r
                }\r
 \r
 \r
@@ -143,35 +169,35 @@ namespace Psychlops
 \r
                        public static IntervalAcc operator <(double val, IntervalAcc rng)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.OPEN, rng.instance.end.val, rng.instance.end.op) };\r
+                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.OPEN, rng.instance.end.value, rng.instance.end.op) };\r
                        }\r
                        public static IntervalAcc operator <=(double val, IntervalAcc rng)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.CLOSE, rng.instance.end.val, rng.instance.end.op) };\r
+                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.CLOSE, rng.instance.end.value, rng.instance.end.op) };\r
                        }\r
                        public static IntervalAcc operator >(double val, IntervalAcc rng)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(rng.instance.begin.val, rng.instance.begin.op, val, Interval.OPERATOR.OPEN) };\r
+                               return new IntervalAcc { instance = new Interval(rng.instance.begin.value, rng.instance.begin.op, val, Interval.OPERATOR.OPEN) };\r
                        }\r
                        public static IntervalAcc operator >=(double val, IntervalAcc rng)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(rng.instance.begin.val, rng.instance.begin.op, val, Interval.OPERATOR.CLOSE) };\r
+                               return new IntervalAcc { instance = new Interval(rng.instance.begin.value, rng.instance.begin.op, val, Interval.OPERATOR.CLOSE) };\r
                        }\r
                        public static IntervalAcc operator <(IntervalAcc rng, double val)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(rng.instance.begin.val, rng.instance.begin.op, val, Interval.OPERATOR.OPEN) };\r
+                               return new IntervalAcc { instance = new Interval(rng.instance.begin.value, rng.instance.begin.op, val, Interval.OPERATOR.OPEN) };\r
                        }\r
                        public static IntervalAcc operator <=(IntervalAcc rng, double val)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(rng.instance.begin.val, rng.instance.begin.op, val, Interval.OPERATOR.CLOSE) };\r
+                               return new IntervalAcc { instance = new Interval(rng.instance.begin.value, rng.instance.begin.op, val, Interval.OPERATOR.CLOSE) };\r
                        }\r
                        public static IntervalAcc operator >(IntervalAcc rng, double val)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.OPEN, rng.instance.end.val, rng.instance.end.op) };\r
+                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.OPEN, rng.instance.end.value, rng.instance.end.op) };\r
                        }\r
                        public static IntervalAcc operator >=(IntervalAcc rng, double val)\r
                        {\r
-                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.CLOSE, rng.instance.end.val, rng.instance.end.op) };\r
+                               return new IntervalAcc { instance = new Interval(val, Interval.OPERATOR.CLOSE, rng.instance.end.value, rng.instance.end.op) };\r
                        }\r
 \r
                        public static implicit operator Interval(IntervalAcc rhs)\r
index 9bd895f..de4a836 100644 (file)
@@ -13,11 +13,25 @@ namespace Psychlops
                }\r
 \r
                /*\r
+               public abstract Internal.MatrixExpression this[Interval row, Interval col]\r
+               {\r
+                       get;\r
+                       set;\r
+               }\r
+\r
+\r
+               /*\r
                public static Matrix operator +(Matrix m, double d)\r
                {\r
                        return new Internal.MatrixExpression();\r
                }\r
                */\r
+\r
+               public abstract int rows { get; }\r
+               public abstract int cols { get; }\r
+               public int getRows() { return rows; }\r
+               public int getCols() { return cols; }\r
+\r
        }\r
 \r
 \r
@@ -26,41 +40,56 @@ namespace Psychlops
 \r
                public class MatrixImplementation : Matrix\r
                {\r
-                       internal double[] elements;\r
-                       readonly int nrow, ncol;\r
+                       internal double[,] elements;\r
 \r
                        public MatrixImplementation(int dnrow, int dncol)\r
                        {\r
-                               nrow = dnrow;\r
-                               ncol = dncol;\r
-                               elements = new double[nrow * ncol];\r
+                               elements = new double[dnrow, dncol];\r
                        }\r
 \r
                        public override double this[int row, int col]\r
                        {\r
                                get\r
                                {\r
-                                       return elements[(row - 1) * ncol + (col - 1)];\r
+                                       return elements[row - 1, col - 1];\r
                                }\r
                                set\r
                                {\r
-                                       elements[(row - 1) * ncol + (col - 1)] = value;\r
+                                       elements[row - 1, col - 1] = value;\r
                                }\r
                        }\r
+                       /*\r
+                       public override MatrixExpression this[Interval row, Interval col]\r
+                       {\r
+                               get\r
+                               {\r
+                                       return new MatrixExpression(this, row.int_floor(), col.int_floor(), row.int_ceil(), col.int_ceil());\r
+                               }\r
+                               set\r
+                               {\r
+                                       for(int r = 0, r<)\r
+                                       elements[row - 1, col - 1] = value;\r
+                               }\r
+                       }\r
+                        * */\r
+\r
+                       public override int rows { get { return elements.GetLength(0); } }\r
+                       public override int cols { get { return elements.GetLength(1); } }\r
+\r
                }\r
 \r
                public class MatrixExpression : Matrix\r
                {\r
                        MatrixImplementation imp;\r
-                       readonly int nrow, ncol;\r
-                       readonly int drow, dcol;\r
-                       \r
-                       public MatrixExpression(MatrixImplementation target, int ddrow, int ddcol, int dnrow, int dncol)\r
+                       readonly int brow, bcol;\r
+                       readonly int erow, ecol;\r
+\r
+                       internal MatrixExpression(MatrixImplementation target, int dbrow, int dbcol, int derow, int decol)\r
                        {\r
-                               nrow = dnrow;\r
-                               ncol = dncol;\r
-                               drow = ddrow;\r
-                               dcol = ddcol;\r
+                               brow = dbrow;\r
+                               bcol = dbcol;\r
+                               erow = derow;\r
+                               ecol = decol;\r
                                imp = target;\r
                        }\r
 \r
@@ -68,13 +97,16 @@ namespace Psychlops
                        {\r
                                get\r
                                {\r
-                                       return imp.elements[(row - drow) * ncol + (col - dcol)];\r
+                                       return imp.elements[(row - 1 - brow), (col - 1 - bcol)];\r
                                }\r
                                set\r
                                {\r
-                                       imp.elements[(row - drow) * ncol + (col - dcol)] = value;\r
+                                       imp.elements[(row - 1 - brow), (col - 1 - bcol)] = value;\r
                                }\r
                        }\r
+\r
+                       public override int rows { get { return erow - brow + 1; } }\r
+                       public override int cols { get { return ecol - bcol + 1; } }\r
                }\r
        }\r
 \r
index 85134a9..20886e0 100644 (file)
@@ -5,20 +5,20 @@ namespace Psychlops
 \r
        public static class Math\r
        {\r
-               public static readonly double PI = 3.14159265, E = 2.718281828459045, LOG2E = 1.44269504088896340736;\r
+               public const double PI = 3.14159265, E = 2.718281828459045, LOG2E = 1.44269504088896340736;\r
                public static Random random_generator;\r
                static Math()\r
                {\r
                        random_generator = new Random();\r
                }\r
 \r
-               public static double max(double val1, double val2)\r
+               public static T max<T>(T val1, T val2) where T : IComparable\r
                {\r
-                       return val1 > val2 ? val1 : val2;\r
+                       return val1.CompareTo(val2) > 0 ? val1 : val2;\r
                }\r
-               public static double min(double val1, double val2)\r
+               public static T min<T>(T val1, T val2) where T : IComparable\r
                {\r
-                       return val1 < val2 ? val1 : val2;\r
+                       return val1.CompareTo(val2) < 0 ? val1 : val2;\r
                }\r
                public static void shuffle<X>(X[] array, int n)\r
                {\r
@@ -41,6 +41,14 @@ namespace Psychlops
                {\r
                        return System.Math.Abs(x);\r
                }\r
+               public static double floor(double x)\r
+               {\r
+                       return System.Math.Floor(x);\r
+               }\r
+               public static double ceil(double x)\r
+               {\r
+                       return System.Math.Ceiling(x);\r
+               }\r
                public static double sin(double x)\r
                {\r
                        return System.Math.Sin(x);\r
@@ -53,6 +61,26 @@ namespace Psychlops
                {\r
                        return System.Math.Tan(x);\r
                }\r
+               public static double asin(double x)\r
+               {\r
+                       return System.Math.Asin(x);\r
+               }\r
+               public static double acos(double x)\r
+               {\r
+                       return System.Math.Acos(x);\r
+               }\r
+               public static double atan(double x)\r
+               {\r
+                       return System.Math.Atan(x);\r
+               }\r
+               public static double atan(double y, double x)\r
+               {\r
+                       return System.Math.Atan2(y, x);\r
+               }\r
+               public static double atan2(double y, double x)\r
+               {\r
+                       return System.Math.Atan2(y, x);\r
+               }\r
                public static double sqrt(double x)\r
                {\r
                        return System.Math.Sqrt(x);\r
@@ -69,11 +97,10 @@ namespace Psychlops
                {\r
                        return log(val) * LOG2E;\r
                }\r
-               /*public static int round(double val)\r
+               public static double round(double val)\r
                {\r
-                       double integer_part, particle = modf(val, &integer_part);\r
-                       return ((particle < 0.5 | (particle == 0.5 && (int)integer_part % 2 == 0)) ? (int)integer_part : (int)integer_part + 1);\r
-               }*/\r
+                       return System.Math.Round(val);\r
+               }\r
 \r
                public static double radius(double x, double y)\r
                {\r
@@ -102,6 +129,131 @@ namespace Psychlops
                {\r
                        return exp(- (x*x) / (2*sigma*sigma));\r
                }\r
+\r
+               public static double normalDistibution(double x, double mu, double sigma)\r
+               {\r
+                       return exp( -( (x-mu)*(x-mu) / (2*sigma*sigma) ) ) / sqrt(2*PI*sigma*sigma);\r
+               }\r
+\r
+               public static double cumulativeNormalDistibution(double x, double mu, double sigma)\r
+               {\r
+                       return .5 + .5*Internal.GammaFunction.erf( (x-mu)/(sigma*sqrt(2.0) ) );\r
+               }\r
+\r
        }\r
 \r
+       namespace Internal\r
+       {\r
+               public static class GammaFunction\r
+               {\r
+                       /************ loggamma(x) -- gamma.c より再掲 *************/\r
+\r
+                       static readonly double PI      = 3.14159265358979324;  /* $\pi$ */\r
+                       static readonly double LOG_2PI = 1.83787706640934548;  /* $\log 2\pi$ */\r
+                       static readonly double N       = 8;\r
+\r
+                       static readonly double B0  = 1            ;     /* 以下はBernoulli数 */\r
+                       static readonly double B1  = (-1.0 / 2.0);\r
+                       static readonly double B2  = ( 1.0 / 6.0);\r
+                       static readonly double B4  = (-1.0 / 30.0);\r
+                       static readonly double B6  = ( 1.0 / 42.0);\r
+                       static readonly double B8  = (-1.0 / 30.0);\r
+                       static readonly double B10 = ( 5.0 / 66.0);\r
+                       static readonly double B12 = (-691.0 / 2730.0);\r
+                       static readonly double B14 = ( 7.0 / 6.0);\r
+                       static readonly double B16 = (-3617.0 / 510.0);\r
+\r
+                       public static double loggamma(double x)  /* ガンマ関数の対数 */\r
+                       {\r
+                               double v, w;\r
+\r
+                               v = 1;\r
+                               while (x < N) {  v *= x;  x++;  }\r
+                               w = 1 / (x * x);\r
+                               return ((((((((B16 / (16 * 15))  * w + (B14 / (14 * 13))) * w\r
+                                                       + (B12 / (12 * 11))) * w + (B10 / (10 *  9))) * w\r
+                                                       + (B8  / ( 8 *  7))) * w + (B6  / ( 6 *  5))) * w\r
+                                                       + (B4  / ( 4 *  3))) * w + (B2  / ( 2 *  1))) / x\r
+                                                       + 0.5 * LOG_2PI - Math.log(v) - x + (x - 0.5) * Math.log(x);\r
+                       }\r
+\r
+                       public static double p_gamma(double a, double x, double loggamma_a)  /* 本文参照 */\r
+                       {\r
+                               int k;\r
+                               double result, term, previous;\r
+\r
+                               if (x >= 1 + a) return 1 - q_gamma(a, x, loggamma_a);\r
+                               if (x == 0)     return 0;\r
+                               result = term = Math.exp(a * Math.log(x) - x - loggamma_a) / a;\r
+                               for (k = 1; k < 1000; k++) {\r
+                                       term *= x / (a + k);\r
+                                       previous = result;  result += term;\r
+                                       if (result == previous) return result;\r
+                               }\r
+                               //throw new Exception("p_gamma(): the sequence is not convergent.");\r
+                               return result;\r
+                       }\r
+\r
+                       public static double q_gamma(double a, double x, double loggamma_a)  /* 本文参照 */\r
+                       {\r
+                               int k;\r
+                               double result, w, temp, previous;\r
+                               double la = 1, lb = 1 + x - a;  /* Laguerreの多項式 */\r
+\r
+                               if (x < 1 + a) return 1 - p_gamma(a, x, loggamma_a);\r
+                               w = Math.exp(a * Math.log(x) - x - loggamma_a);\r
+                               result = w / lb;\r
+                               for (k = 2; k < 1000; k++) {\r
+                                       temp = ((k - 1 - a) * (lb - la) + (k + x) * lb) / k;\r
+                                       la = lb;  lb = temp;\r
+                                       w *= (k - 1 - a) / k;\r
+                                       temp = w / (la * lb);\r
+                                       previous = result;  result += temp;\r
+                                       if (result == previous) return result;\r
+                               }\r
+                               //throw new Exception("q_gamma(): the sequence is not convergent.");\r
+                               return result;\r
+                       }\r
+\r
+                       public static double p_chisq(double chisq, int df)  /* カイ2乗分布の下側確率 */\r
+                       {\r
+                               return p_gamma(0.5 * df, 0.5 * chisq, loggamma(0.5 * df));\r
+                       }\r
+\r
+                       public static double q_chisq(double chisq, int df)  /* カイ2乗分布の上側確率 */\r
+                       {\r
+                               return q_gamma(0.5 * df, 0.5 * chisq, loggamma(0.5 * df));\r
+                       }\r
+\r
+                       static readonly double LOG_PI = 1.14472988584940017;  /* $\log_e \pi$ */\r
+\r
+                       public static double erf(double x)  /* Gaussの誤差関数 ${\rm erf}(x)$ */\r
+                       {\r
+                               if (x >= 0) return   p_gamma(0.5, x * x, LOG_PI / 2);\r
+                               else        return - p_gamma(0.5, x * x, LOG_PI / 2);\r
+                       }\r
+\r
+                       public static double erfc(double x)  /* $1 - {\rm erf}(x)$ */\r
+                       {\r
+                               if (x >= 0) return  q_gamma(0.5, x * x, LOG_PI / 2);\r
+                               else        return  1 + p_gamma(0.5, x * x, LOG_PI / 2);\r
+                       }\r
+\r
+                       public static double p_normal(double x)  /* 標準正規分布の下側確率 */\r
+                       {\r
+                               if (x >= 0) return\r
+                                       0.5 * (1 + p_gamma(0.5, 0.5 * x * x, LOG_PI / 2));\r
+                               else return\r
+                                       0.5 * q_gamma(0.5, 0.5 * x * x, LOG_PI / 2);\r
+                       }\r
+\r
+                       public static double q_normal(double x)  /* 標準正規分布の上側確率 */\r
+                       {\r
+                               if (x >= 0) return\r
+                                       0.5 * q_gamma(0.5, 0.5 * x * x, LOG_PI / 2);\r
+                               else return\r
+                                       0.5 * (1 + p_gamma(0.5, 0.5 * x * x, LOG_PI / 2));\r
+                       }\r
+               }\r
+       }\r
 }
\ No newline at end of file
diff --git a/dev4/psychlops/extention/compatibility/compatibility.cs b/dev4/psychlops/extention/compatibility/compatibility.cs
new file mode 100644 (file)
index 0000000..f43b5d5
--- /dev/null
@@ -0,0 +1,68 @@
+\r
+\r
+\r
+namespace Psychlops\r
+{\r
+\r
+       /*\r
+       namespace Internal\r
+       {\r
+               public class IndependentAccessor\r
+               {\r
+                       Widgets.Slider sld; \r
+                       public static IndependentAccessor operator <<( IndependentAccessor ind, Widgets.Slider sl )\r
+                       {\r
+                               ind.sld = sl;\r
+                               Psychlops.Main.canvas.independent_list.Add(sl);\r
+                               return ind;\r
+                       }\r
+                       public static IndependentAccessor operator | (IndependentAccessor ind, string str)\r
+                       {\r
+                               label = l;\r
+                               Psychlops.Main.canvas.independent_list.Add(sl);\r
+                               return ind;\r
+                       }\r
+               }\r
+       }\r
+        **/\r
+\r
+       public static class Display\r
+       {\r
+               public static void pix(int x, int y, Color col) { Main.canvas.pix(x, y, col); }\r
+               public static void line(Line drawee) { Main.canvas.line(drawee); }\r
+               public static void rect(Rectangle drawee) { Main.canvas.rect(drawee); }\r
+               public static void ellipse(Ellipse drawee) { Main.canvas.ellipse(drawee); }\r
+               public static void polygon(Polygon drawee) { Main.canvas.polygon(drawee); }\r
+               public static void letters(Letters drawee) { Main.canvas.letters(drawee); }\r
+               public static void image(Image drawee) { Main.canvas.image(drawee); }\r
+               public static void group(Group drawee) { Main.canvas.group(drawee); }\r
+\r
+\r
+               public static void msg(string str, double x, double y) { Main.canvas.msg(str, x, y, Color.white); }\r
+               public static void msg(string dstr, double x, double y, Color col) { Main.canvas.msg(dstr, x, y, col); }\r
+               public static void var<Type>(Type val, double x, double y) { Main.canvas.var(val, x, y, Color.white); }\r
+               public static void var<Type>(Type val, double x, double y, Color col) { Main.canvas.var(val, x, y, col); }\r
+\r
+\r
+\r
+               public static void clear() { Main.canvas.clear(Color.black); }\r
+               public static void clear(double lum) { Main.canvas.clear(lum); }\r
+               public static void clear(Color col) { Main.canvas.clear(col); }\r
+               public static void flip(int n = 1) { Main.canvas.flip(n); }\r
+\r
+               public static double width { get { return Main.canvas.width; } }\r
+               public static double height { get { return Main.canvas.height; } }\r
+               public static Point center { get { return Main.canvas.center; } }\r
+               public static double getWidth() { return width; }\r
+               public static double getHeight() { return height; }\r
+               public static Point getCenter() { return center; }\r
+               public static double getHCenter() { return Main.canvas.getHCenter(); }\r
+               public static double getVCenter() { return Main.canvas.getVCenter(); }\r
+               public static double getRefreshRate() { return Main.canvas.getRefreshRate(); }\r
+\r
+               public static void showFPS(bool sw = true) { Main.canvas.showFPS(sw); }\r
+               public static void watchFPS(bool sw = true) { Main.canvas.watchFPS(sw); }\r
+\r
+       }\r
+\r
+}\r
index e26365f..2bca111 100644 (file)
@@ -7,6 +7,10 @@ namespace Psychlops
 \r
        namespace Solver\r
        {\r
+               internal static class CONST\r
+               {\r
+                       public static readonly uint MAX_ARG = 5;\r
+               }\r
 \r
                \r
                static public class Constants\r
@@ -34,7 +38,8 @@ namespace Psychlops
                        }\r
                        public static double combination(int nn, int kk)\r
                        {\r
-                               //return (double)(Int64)(factorial(n) / (factorial(kk) * factorial(n - kk)));\r
+                               return (double)(Int64)(factorial(nn) / (factorial(kk) * factorial(nn - kk)));\r
+                               /*\r
                                BigInt n = new BigInt((Int64)nn, new PrecisionSpec());\r
                                BigInt k = new BigInt((Int64)kk, new PrecisionSpec());\r
                                BigInt n_k = n - k;\r
@@ -42,6 +47,7 @@ namespace Psychlops
                                k.Factorial();\r
                                n_k.Factorial();\r
                                return (double)(Int64)(n / (k * n_k) );\r
+                                * */\r
                        }\r
                        public static double likelihood(double pp, int yes, int no)\r
                        {\r
@@ -112,22 +118,27 @@ namespace Psychlops
 \r
                        public BinomialLikelihoodThread()\r
                        {\r
+                               itvl = new Interval[CONST.MAX_ARG];\r
+                               step = new double[CONST.MAX_ARG];\r
+                               champ = new double[CONST.MAX_ARG];\r
+                               data = new BernoulliProcess();\r
                        }\r
                        public void waitLoop()\r
                        {\r
                                finished = false;\r
-                               for(int i=0; i<10; i++) {\r
+                               for (int i = 0; i < CONST.MAX_ARG; i++)\r
+                               {\r
                                        champ[i] = 0;\r
                                }\r
                                current = this;\r
                                started = false;\r
                        }\r
 \r
-                       public void loop1() { waitLoop(); th = new Thread(new ThreadStart(loop1_)); }\r
-                       public void loop2() { waitLoop(); th = new Thread(new ThreadStart(loop2_)); }\r
-                       public void loop3() { waitLoop(); th = new Thread(new ThreadStart(loop3_)); }\r
-                       public void loop4() { waitLoop(); th = new Thread(new ThreadStart(loop4_)); }\r
-                       public void loop5() { waitLoop(); th = new Thread(new ThreadStart(loop5_)); }\r
+                       public void loop1() { waitLoop(); th = new Thread(new ThreadStart(loop1_)); th.Start(); }\r
+                       public void loop2() { waitLoop(); th = new Thread(new ThreadStart(loop2_)); th.Start(); }\r
+                       public void loop3() { waitLoop(); th = new Thread(new ThreadStart(loop3_)); th.Start(); }\r
+                       public void loop4() { waitLoop(); th = new Thread(new ThreadStart(loop4_)); th.Start(); }\r
+                       public void loop5() { waitLoop(); th = new Thread(new ThreadStart(loop5_)); th.Start(); }\r
                        void loop1_()\r
                        {\r
                                started = true;\r
@@ -135,7 +146,7 @@ namespace Psychlops
                                double like = 1.0;\r
                                champ_like=0.0;\r
                                int L = data.length;\r
-                               for (double a = itvl[0].begin.val; a < itvl[0].end.val; a += step[0])\r
+                               for (double a = itvl[0].begin.value; a < itvl[0].end.value; a += step[0])\r
                                {\r
                                        like = 1.0;\r
                                        for(int i=0; i<L; i++) {\r
@@ -152,13 +163,13 @@ namespace Psychlops
                        void loop2_()\r
                        {\r
                                started = true;\r
-                               double p;\r
+                               double p = 0.0;\r
                                double like = 1.0;\r
                                champ_like = 0.0;\r
                                int L = data.length;\r
-                               for (double a = itvl[0].begin.val; a < itvl[0].end.val; a += step[0])\r
+                               for (double a = itvl[0].begin.value; a < itvl[0].end.value; a += step[0])\r
                                {\r
-                                       for (double b = itvl[1].begin.val; b < itvl[1].end.val; b += step[1])\r
+                                       for (double b = itvl[1].begin.value; b < itvl[1].end.value; b += step[1])\r
                                        {\r
                                                like = 1.0;\r
                                                for (int i = 0; i < L; i++)\r
@@ -170,6 +181,7 @@ namespace Psychlops
                                                {\r
                                                        champ_like = like;\r
                                                        champ[0] = a;\r
+                                                       champ[1] = b;\r
                                                }\r
                                        }\r
                                }\r
@@ -182,11 +194,11 @@ namespace Psychlops
                                double like = 1.0;\r
                                champ_like = 0.0;\r
                                int L = data.length;\r
-                               for (double a = itvl[0].begin.val; a < itvl[0].end.val; a += step[0])\r
+                               for (double a = itvl[0].begin.value; a < itvl[0].end.value; a += step[0])\r
                                {\r
-                                       for (double b = itvl[1].begin.val; b < itvl[1].end.val; b += step[1])\r
+                                       for (double b = itvl[1].begin.value; b < itvl[1].end.value; b += step[1])\r
                                        {\r
-                                               for (double c = itvl[2].begin.val; c < itvl[2].end.val; c += step[2])\r
+                                               for (double c = itvl[2].begin.value; c < itvl[2].end.value; c += step[2])\r
                                                {\r
                                                        like = 1.0;\r
                                                        for (int i = 0; i < L; i++)\r
@@ -198,6 +210,8 @@ namespace Psychlops
                                                        {\r
                                                                champ_like = like;\r
                                                                champ[0] = a;\r
+                                                               champ[1] = b;\r
+                                                               champ[1] = c;\r
                                                        }\r
                                                }\r
                                        }\r
@@ -218,8 +232,36 @@ namespace Psychlops
 \r
 \r
 \r
-               class BinomialLikelihood\r
+               public class BinomialLikelihood\r
                {\r
+                       public static void showWindow(Constants.Func1 f)\r
+                       {\r
+                               Main.canvas.api_canvas.Dispatcher.BeginInvoke(new Action<Constants.Func1>(showWindow_), f);\r
+                       }\r
+                       internal static void showWindow_(Constants.Func1 f)\r
+                       {\r
+                               System.Windows.Controls.ChildWindow page = new PsychlopsSilverlight4.Pages.BinomialSolver(f);\r
+                               page.Show();\r
+                       }\r
+                       public static void showWindow(Constants.Func2 f)\r
+                       {\r
+                               Main.canvas.api_canvas.Dispatcher.BeginInvoke(new Action<Constants.Func2>(showWindow_), f);\r
+                       }\r
+                       internal static void showWindow_(Constants.Func2 f)\r
+                       {\r
+                               System.Windows.Controls.ChildWindow page = new PsychlopsSilverlight4.Pages.BinomialSolver(f);\r
+                               page.Show();\r
+                       }\r
+                       public static void showWindow(Constants.Func3 f)\r
+                       {\r
+                               Main.canvas.api_canvas.Dispatcher.BeginInvoke(new Action<Constants.Func3>(showWindow_), f);\r
+                       }\r
+                       internal static void showWindow_(Constants.Func3 f)\r
+                       {\r
+                               System.Windows.Controls.ChildWindow page = new PsychlopsSilverlight4.Pages.BinomialSolver(f);\r
+                               page.Show();\r
+                       }\r
+\r
                        public int iteration;\r
 \r
                        public Interval[] itvl;\r
@@ -237,6 +279,9 @@ namespace Psychlops
 \r
                        public BinomialLikelihood()\r
                        {\r
+                               itvl = new Interval[CONST.MAX_ARG];\r
+                               step = new double[CONST.MAX_ARG];\r
+                               champ = new double[CONST.MAX_ARG];\r
                                iteration = 2;\r
                        }\r
 \r
@@ -247,12 +292,10 @@ namespace Psychlops
                                func1 = d_func;\r
 \r
                                BinomialLikelihoodThread[] l = new BinomialLikelihoodThread[4];\r
+                               for (int i = 0; i < 4; i++) { l[i] = new BinomialLikelihoodThread(); }\r
 \r
-                               double r, low, high;\r
                                for (int k = 0; k < iteration; k++)\r
                                {\r
-                                       champ_like = 0;\r
-\r
                                        begin_base(l);\r
                                        for (int i = 0; i < 4; i++)\r
                                        {\r
@@ -261,14 +304,6 @@ namespace Psychlops
                                                l[i].loop1();\r
                                        }\r
                                        end_base(l);\r
-\r
-                                       for (int j = 0; j < Constants.LIMIT; j++)\r
-                                       {\r
-                                               r = itvl[j].end.val - itvl[j].begin.val;\r
-                                               low = champ[j] - r / 8.0 < itvl[j].begin.val ? itvl[j].begin.val : champ[j] - r / 8.0;\r
-                                               high = champ[j] + r / 8.0 > itvl[j].end.val ? itvl[j].end.val : champ[j] + r / 8.0;\r
-                                               itvl[j] = new Interval(low, high);\r
-                                       }\r
                                }\r
                        }\r
                        public void begin(Constants.Func2 d_func)\r
@@ -276,12 +311,10 @@ namespace Psychlops
                                func2 = d_func;\r
 \r
                                BinomialLikelihoodThread[] l = new BinomialLikelihoodThread[4];\r
+                               for (int i = 0; i < 4; i++) { l[i] = new BinomialLikelihoodThread(); }\r
 \r
-                               double r, low, high;\r
                                for (int k = 0; k < iteration; k++)\r
                                {\r
-                                       champ_like = 0;\r
-\r
                                        begin_base(l);\r
                                        for (int i = 0; i < 4; i++)\r
                                        {\r
@@ -290,14 +323,6 @@ namespace Psychlops
                                                l[i].loop2();\r
                                        }\r
                                        end_base(l);\r
-\r
-                                       for (int j = 0; j < Constants.LIMIT; j++)\r
-                                       {\r
-                                               r = itvl[j].end.val - itvl[j].begin.val;\r
-                                               low = champ[j] - r / 8.0 < itvl[j].begin.val ? itvl[j].begin.val : champ[j] - r / 8.0;\r
-                                               high = champ[j] + r / 8.0 > itvl[j].end.val ? itvl[j].end.val : champ[j] + r / 8.0;\r
-                                               itvl[j] = new Interval(low, high);\r
-                                       }\r
                                }\r
                        }\r
                        public void begin(Constants.Func3 d_func)\r
@@ -305,12 +330,10 @@ namespace Psychlops
                                func3 = d_func;\r
 \r
                                BinomialLikelihoodThread[] l = new BinomialLikelihoodThread[4];\r
+                               for (int i = 0; i < 4; i++) { l[i] = new BinomialLikelihoodThread(); }\r
 \r
-                               double r, low, high;\r
                                for (int k = 0; k < iteration; k++)\r
                                {\r
-                                       champ_like = 0;\r
-\r
                                        begin_base(l);\r
                                        for(int i=0; i<4; i++) {\r
                                                l[i].data = data;\r
@@ -318,14 +341,6 @@ namespace Psychlops
                                                l[i].loop3();\r
                                        }\r
                                        end_base(l);\r
-\r
-                                       for (int j = 0; j < Constants.LIMIT; j++)\r
-                                       {\r
-                                               r = itvl[j].end.val - itvl[j].begin.val;\r
-                                               low  = champ[j]-r/8.0 < itvl[j].begin.val ? itvl[j].begin.val : champ[j]-r/8.0;\r
-                                               high = champ[j]+r/8.0 > itvl[j].end.val   ? itvl[j].end.val   : champ[j]+r/8.0;\r
-                                               itvl[j] = new Interval(low, high);\r
-                                       }\r
                                }\r
                        }\r
 \r
@@ -338,16 +353,18 @@ namespace Psychlops
 \r
                        void begin_base(BinomialLikelihoodThread[] l)\r
                        {\r
+                               champ_like = 0;\r
+\r
                                data.length = data.elems.GetLength(0);\r
                                for (int i = 0; i < data.elems.GetLength(0); i++)\r
                                {\r
                                        data.elems[i].comb = (int)Binomial.combination(data.elems[i].pos + data.elems[i].neg, data.elems[i].pos);\r
                                }\r
 \r
-                               for (int j = 0; j < Constants.LIMIT; j++) { step[j] = (itvl[j].end.val - itvl[j].begin.val) / 256.0; }\r
+                               for (int j = 0; j < Constants.LIMIT; j++) { step[j] = (itvl[j].end.value - itvl[j].begin.value) / 256.0; }\r
                                for (int i = 0; i < 4; i++)\r
                                {\r
-                                       l[i].itvl[0] = new Interval((itvl[0].begin.val) + (i * step[0] * 64), (itvl[0].begin.val) + ((i + 1) * step[0] * 64));\r
+                                       l[i].itvl[0] = new Interval((itvl[0].begin.value) + (i * step[0] * 64), (itvl[0].begin.value) + ((i + 1) * step[0] * 64));\r
                                        l[i].step[0] = step[0];\r
                                        for (int j = 1; j < Constants.LIMIT; j++)\r
                                        {\r
@@ -360,12 +377,11 @@ namespace Psychlops
 \r
                        void end_base(BinomialLikelihoodThread[] l)\r
                        {\r
-                               for (int i = 0; i < 4; i++)\r
-                               {\r
-                                       l[i].th.Join();\r
-                               }\r
+                               //for (int i = 0; i < 4; i++) { l[i].th.Join(); }\r
+                               while (!l[0].finished || !l[1].finished || !l[2].finished || !l[3].finished) { Thread.Sleep(100);  } \r
 \r
                                for(int j=0; j<Constants.LIMIT; j++) { champ[j] = 0; }\r
+                               champ_like = 0.0;\r
                                for(int i=0; i<4; i++) {\r
                                        if(champ_like < l[i].champ_like) {\r
                                                champ_like = l[i].champ_like;\r
@@ -373,6 +389,15 @@ namespace Psychlops
                                        }\r
                                }\r
 \r
+                               double r, low, high;\r
+                               for (int j = 0; j < Constants.LIMIT; j++)\r
+                               {\r
+                                       r = itvl[j].end.value - itvl[j].begin.value;\r
+                                       low = champ[j] - r / 8.0 < itvl[j].begin.value ? itvl[j].begin.value : champ[j] - r / 8.0;\r
+                                       high = champ[j] + r / 8.0 > itvl[j].end.value ? itvl[j].end.value : champ[j] + r / 8.0;\r
+                                       itvl[j] = new Interval(low, high);\r
+                               }\r
+\r
                        }\r
 \r
 \r
index 4fe21e7..42e7668 100644 (file)
@@ -8,6 +8,7 @@ using System.Windows.Media.Animation;
 using System.Windows.Media.Imaging;\r
 using System.Windows.Shapes;\r
 using System.Windows.Browser;\r
+using System.Windows.Data;\r
 \r
 \r
 \r
@@ -79,33 +80,107 @@ namespace Psychlops
                        public WidgetRect& pushThis();\r
                };\r
                */\r
+               \r
                /*\r
                public class Slider\r
                {\r
+                       public string label;\r
                        public Rectangle outer;\r
+                       public Rectangle inner;\r
+                       public Stroke outer_strk;\r
+\r
+                       public Slider()\r
+                       {\r
+                               set(0, 0);\r
+                       }\r
+                       public Slider(double width, double height)\r
+                       {\r
+                               set(width, height);\r
+                       }\r
+                       public Slider set(double width, double height)\r
+                       {\r
+                               outer = new Rectangle(width, height);\r
+                               outer.fill = Color.gray;\r
+                               inner = new Rectangle();\r
+                               inner.fill = Color.blue;\r
+                               outer_strk = new Stroke();\r
+                               outer_strk.color = Color.white;\r
+                               outer_strk.thick = 1;\r
+                               return this;\r
+                       }\r
+                       public void checkClick()\r
+                       {\r
+                               if (outer.include(Mouse.position))\r
+                               {\r
+                                       outer.stroke = outer_strk;\r
+                               }\r
+                       }\r
                }\r
-               */\r
+                */\r
+\r
 \r
                public class Slider\r
                {\r
+                       public static Color bgcolor;\r
+\r
                        internal System.Windows.UIElement instance;\r
                        internal System.Windows.Controls.Slider uislider;\r
+                       internal System.Windows.Controls.TextBlock uilabel;\r
+                       internal System.Windows.Controls.TextBox uibox;\r
                        internal string label;\r
                        internal Interval range;\r
+                       internal SelfDelegate get_;\r
+                       internal SelfDelegate set_;\r
+                       internal double retval;\r
+                       internal bool setted_;\r
 \r
-                       public Slider(string l, Interval r)\r
+                       static Slider()\r
                        {\r
+                               bgcolor.set(.5,.5, .5, .3);\r
+                       }\r
+\r
+                       public Slider(string l, Interval r, double initialvalue)\r
+                       {\r
+                               retval = initialvalue;\r
                                range = r;\r
                                label = l;\r
+                               setted_ = false;\r
                                Psychlops.Widgets.Connector.stackSlider(this);\r
+                               get_ = new SelfDelegate(get__);\r
+                               set_ = new SelfDelegate(set__);\r
+                               while (!setted_) { System.Threading.Thread.Sleep(10); }\r
                        }\r
                        public static implicit operator double(Slider s)\r
                        {\r
                                return s.value;\r
                        }\r
-                       public double value {\r
-                               get { return uislider.Value; }\r
-                               set { if(uislider!=null) uislider.Dispatcher.BeginInvoke( new Action<System.Windows.Controls.Slider, double>(Connector.sliderSet) , uislider, value ); }\r
+\r
+                       public delegate void SelfDelegate(System.Windows.Controls.Slider s);\r
+                       public void get__(System.Windows.Controls.Slider s) { retval = s.Value; }\r
+                       public void set__(System.Windows.Controls.Slider s) { s.Value = retval; }\r
+\r
+                       public double getValue()\r
+                       {\r
+                               if (uislider != null) {\r
+                                       uislider.Dispatcher.BeginInvoke(get_, uislider);\r
+                                       return retval;\r
+                               } else {\r
+                                       return 0;\r
+                               }\r
+                       }\r
+                       public void setValue(double v)\r
+                       {\r
+                               if (uislider != null)\r
+                               {\r
+                                       retval = v;\r
+                                       uislider.Dispatcher.BeginInvoke(set_, uislider);\r
+                               }\r
+                       }\r
+\r
+                       public double value\r
+                       {\r
+                               get { return getValue(); }\r
+                               set { setValue(value); }\r
                        }\r
                        public bool changed { get; set; }\r
                }\r
@@ -178,13 +253,34 @@ namespace Psychlops
                }\r
 \r
 \r
-\r
                internal static class Connector\r
                {\r
                        internal delegate void VoidString(string s);\r
                        internal delegate void VoidStringObject(String s, System.Object o);\r
-                       \r
 \r
+                       public class Double02fFormatter : IValueConverter\r
+                       {\r
+                               public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)\r
+                               {\r
+                                       string formatString = parameter as string;\r
+                                       if (!string.IsNullOrEmpty(formatString))\r
+                                       {\r
+                                               return string.Format(culture, formatString, value);\r
+                                       }\r
+                                       return string.Format("{0, -8:F}", value);\r
+                               }\r
+                               public object ConvertBack(object val, Type targetType, object parameter, System.Globalization.CultureInfo culture)\r
+                               {\r
+                                       string str = val.ToString();\r
+                                       double result;\r
+                                       var objCultureInfo = new System.Globalization.CultureInfo("en-US");\r
+                                       if (Double.TryParse(str, System.Globalization.NumberStyles.Number, objCultureInfo, out result))\r
+                                       {\r
+                                               return result;\r
+                                       }\r
+                                       return val;\r
+                               }\r
+                       }\r
 \r
                        delegate void StackSlider_(Slider s);\r
                        internal static void stackSlider(Slider s)\r
@@ -193,46 +289,49 @@ namespace Psychlops
                        }\r
                        static void stackSlider__(Slider ss)\r
                        {\r
-                               var holder = new System.Windows.Controls.Canvas { Width = 200 };\r
+                               var label = new System.Windows.Controls.TextBlock { Text = ss.label };\r
+                               label.Foreground = Color.white;\r
+                               System.Windows.Controls.Canvas.SetLeft(label, 3);\r
+                               System.Windows.Controls.Canvas.SetTop(label, 3);\r
+                               ss.uilabel = label;\r
+\r
+                               var holder = new System.Windows.Controls.Canvas { Width = 200, Height = 50 };\r
                                var val = new System.Windows.Controls.TextBox { Width = 100 };\r
                                System.Windows.Controls.Canvas.SetLeft(val, 100);\r
                                var slide = new System.Windows.Controls.Slider {\r
-                                               Minimum = ss.range.begin.val, Maximum = ss.range.end.val,\r
+                                               Minimum = ss.range.begin.value, Maximum = ss.range.end.value,\r
                                                Name = ss.label,\r
+                                               Value = ss.retval,\r
                                                Tag = ss, Width = 200,\r
                                };\r
-                               System.Windows.Controls.Canvas.SetTop(slide, 25);\r
+                               System.Windows.Controls.Canvas.SetTop(slide, label.ActualHeight - 3);\r
                                var b = new System.Windows.Data.Binding {\r
                                                Path = new PropertyPath("Value"),\r
                                                Mode = System.Windows.Data.BindingMode.TwoWay,\r
                                                Source = slide,\r
+                                               Converter = new Double02fFormatter()\r
                                };\r
                                val.SetBinding(TextBox.TextProperty, b);\r
                                ss.uislider = slide;\r
-                               //var b2 = new System.Windows.Data.Binding\r
-                               //{\r
-                               //      Path = new PropertyPath("value"),\r
-                               //      Mode = System.Windows.Data.BindingMode.TwoWay,\r
-                               //      Source = ss,\r
-                               //};\r
-                               //val.SetBinding(System.Windows.Controls.Slider.ValueProperty, b2);\r
-                               var label = new System.Windows.Controls.TextBlock { Text = ss.label };\r
-                               System.Windows.Controls.Canvas.SetLeft(label, 3);\r
-                               System.Windows.Controls.Canvas.SetTop(label, 3);\r
+                               ss.uibox = val;\r
+                               val.Background = Color.null_color;\r
+                               val.BorderBrush = Color.null_color;\r
+                               val.Foreground = Color.white;\r
+                               val.TextAlignment = TextAlignment.Right;\r
+\r
+                               holder.Background = Slider.bgcolor;\r
 \r
                                holder.Children.Add(label);\r
-                               holder.Children.Add(slide);\r
                                holder.Children.Add(val);\r
+                               holder.Children.Add(slide);\r
+                               holder.Height = label.ActualHeight + slide.ActualHeight + val.ActualHeight + 15;\r
                                ss.instance = holder;\r
                                Internal.Main.widgetStack.Children.Add(ss.instance);\r
+                               ss.setted_ = true;\r
                        }\r
-                       public static void sliderSet(System.Windows.Controls.Slider s, double v)\r
-                       {\r
-                               s.Value = v;\r
-                       }\r
-\r
                }\r
 \r
        }\r
 \r
-}
\ No newline at end of file
+}\r
+\r
index 685c460..a303773 100644 (file)
@@ -38,8 +38,18 @@ namespace PsychlopsSilverlight4test
                        //main_routine = main.psychlops_main();\r
 \r
                        Psychlops.Internal.Main.statusBar = AppStatusBar;\r
-                       Psychlops.Internal.Main.widgetStack = Controller;\r
+                       //Psychlops.Internal.Main.widgetStack = Controller;\r
                        AppStatusBar.Text = "Now starting Psychlops environment... please wait a minute";\r
+\r
+\r
+                       var ur = new System.Uri("Resources/logo.png", System.UriKind.RelativeOrAbsolute);\r
+                       var bitmap = new System.Windows.Media.Imaging.BitmapImage(ur);\r
+                       var img = new System.Windows.Controls.Image();\r
+                       img.Source = bitmap;\r
+                       System.Windows.Controls.Canvas.SetLeft(img, 100);\r
+                       System.Windows.Controls.Canvas.SetTop(img, 100);\r
+                       LayoutRoot.Children.Add(img);\r
+\r
                }\r
                protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) {\r
                        this.Focus();\r
index e7b6754..f5df20f 100644 (file)
@@ -1,4 +1,70 @@
-/*using Psychlops;\r
+\r
+using Psychlops;\r
+\r
+namespace PsychlopsSilverlight4test\r
+{\r
+\r
+       public class PsychlopsMain\r
+       {\r
+\r
+               Psychlops.Widgets.Slider rect_size;\r
+               Psychlops.Widgets.Slider rect_lum;\r
+               Psychlops.Widgets.Slider bg_lum;\r
+\r
+\r
+               void RectLuminance()\r
+               {\r
+                       Canvas display = new Canvas(Canvas.window);\r
+                       Interval rng = new Interval();\r
+                       rect_size = new Psychlops.Widgets.Slider("Rect Size", 1 < rng < 500, 10.0);\r
+                       rect_lum = new Psychlops.Widgets.Slider("Rect Luminance", 0.0 <= rng <= 1.0, 0.1);\r
+                       bg_lum = new Psychlops.Widgets.Slider("BG Luminance", 0.0 <= rng <= 1.0, 0.1);\r
+                       Ellipse drawee = new Ellipse(100, 100);\r
+                       display.showFPS();\r
+                       display.watchFPS();\r
+\r
+                       Rectangle rect = new Rectangle(rect_size, rect_size);\r
+                       rect.centering();\r
+\r
+\r
+                       Clock before = new Clock(), after = new Clock();\r
+                       while (!Keyboard.esc.pushed())\r
+                       {\r
+                               Display.clear(bg_lum);\r
+                               rect.resize(rect_size, rect_size).draw(rect_lum);\r
+                               after.update();\r
+                               display.var((after - before).at_msec(), 100, 100, Color.green);\r
+                               display.var((after - before).at_msec(), 100, 200, Color.green);\r
+                               drawee.centering().shift(Math.random(100), 0);\r
+                               drawee.draw(Color.black);\r
+                               Display.flip();\r
+                       }\r
+\r
+               }\r
+\r
+\r
+               public void psychlops_main()\r
+               {\r
+                       RectLuminance();\r
+               }\r
+\r
+\r
+       }\r
+\r
+}\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+/*\r
+ using Psychlops;\r
 \r
 namespace PsychlopsSilverlight4test\r
 {\r
@@ -14,12 +80,25 @@ namespace PsychlopsSilverlight4test
                double TargetEcce = 100.0, TargetSize = 5.0, TargetNumber = 5, Rotate = 0.0;\r
 \r
                //Set Background Initial Value\r
-               double DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
+               double Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
+               Psychlops.Widgets.Slider thetaSpeed, DotNumber;\r
+               Image img;\r
+\r
+\r
 \r
                public void psychlops_main()\r
                {\r
                        cnvs = new Canvas(500, 500);\r
 \r
+                       Psychlops.Solver.BinomialLikelihood.showWindow(Math.cumulativeNormalDistibution);\r
+\r
+\r
+                       img = new Image("Resources/logo.png");\r
+\r
+                       Interval rng = new Interval();\r
+                       thetaSpeed = new Psychlops.Widgets.Slider("Label", -10 <= rng <= 10, 3.0);\r
+                       DotNumber  = new Psychlops.Widgets.Slider("DotNum",   0 <= rng <= 100, 50.0);\r
+\r
                        //Declare background dots and target\r
                        Rectangle[] BGDot = new Rectangle[2048];\r
                        for(int i=0; i<2048; i++){\r
@@ -56,11 +135,11 @@ namespace PsychlopsSilverlight4test
                        for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);\r
 \r
                        double COS, SIN;\r
-                       DotNumber = 200;\r
+                       //DotNumber = 200;\r
                        //Main stimulus loop\r
                        while(true){\r
                                //Clear the main window\r
-                               cnvs.clear(Color.green);\r
+                               cnvs.clear();\r
 \r
 \r
                                temp=Axis/360*2*Math.PI;\r
@@ -101,6 +180,11 @@ namespace PsychlopsSilverlight4test
                                        Target[i].draw();\r
                                }\r
 \r
+                               img.centering(Mouse.position).draw();\r
+\r
+                               cnvs.var(Mouse.position.x, 100, 100);\r
+                               cnvs.var(Mouse.position.y, 100, 140);\r
+\r
                                //Reflect drawing at the next frame;\r
                                cnvs.flip();\r
                        }\r
@@ -110,6 +194,7 @@ namespace PsychlopsSilverlight4test
 }\r
 */\r
 \r
+\r
 /*using Psychlops;\r
 \r
 namespace PsychlopsSilverlight4test\r
@@ -156,10 +241,10 @@ namespace PsychlopsSilverlight4test
 \r
 }\r
 \r
-*/\r
 \r
 \r
 \r
+/*\r
 using Psychlops;\r
 \r
 namespace Psychlops\r
@@ -224,7 +309,7 @@ namespace PsychlopsSilverlight4test
                        shape = poly;\r
 \r
                        var rng = new Interval();\r
-                       var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);\r
+                       var slider = new Psychlops.Widgets.Slider("tesrt", -100 <= rng <= 100);\r
 \r
                        dots = new RandomDots();\r
 \r
@@ -241,36 +326,37 @@ namespace PsychlopsSilverlight4test
                                {\r
                                        fixation.centering().shift(100, 100);\r
                                        fixation.draw(new Stroke(Color.blue, 3));\r
-                               }*/\r
+                               }* /\r
 \r
-                               fixation.centering();\r
+                               fixation.centering().shift(slider, 0);\r
                                fixation.draw(Color.red);\r
 \r
                                //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
                                //Figures.drawGaussian(ref img, 20, 1);\r
                                //Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
-                               img.centering(Mouse.position);\r
-                               img.draw();\r
-                               //g.centering(Mouse.position).draw();\r
-                               //g.rotation += 1;\r
+                               //img.centering(Mouse.position);\r
+                               //img.draw();\r
+                               g.centering(Mouse.position).draw();\r
+                               g.rotation += 1;\r
 \r
                                shape.centering(Mouse.position).shift(100, 0);\r
                                shape.draw();\r
                                if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
 \r
                                cnvs.var(frames, 0, 20);\r
-                               slider.value = frames / 100.0;\r
+                               //slider.value = frames / 100.0;\r
 \r
                                /*if (frames % 2 != 0)\r
                                {\r
                                        fixation.shift(100, 100);\r
                                        fixation.draw(new Stroke(Color.green, 3));\r
-                               }*/\r
+                               }* /\r
 \r
                                for (int i = 0; i < dots.cood.Length; i++)\r
                                {\r
                                        dots.cood[i].set(Math.random(500), Math.random(500));\r
                                }\r
+                               cnvs.var((double)slider, 200, 200);\r
                                dots.draw();\r
 \r
                                cnvs.flip();\r
@@ -279,3 +365,45 @@ namespace PsychlopsSilverlight4test
        }\r
 }\r
 \r
+**/\r
+\r
+\r
+/*\r
+\r
+using Psychlops;\r
+namespace PsychlopsSilverlight4test\r
+{\r
+\r
+       public class PsychlopsMain\r
+       {\r
+               Canvas cnvs;\r
+               Rectangle[] rect;\r
+               int n;\r
+\r
+               public void psychlops_main()\r
+               {\r
+                       n = 1;\r
+                       cnvs = new Canvas(500, 500);\r
+                       rect = new Rectangle[n];\r
+                       for (int i = 0; i < n; i++)\r
+                       {\r
+                               rect[i] = new Rectangle(10, 10);\r
+                               rect[i].fill = Color.red;\r
+                       }\r
+                       Interval rng = new Interval();\r
+                       var slider = new Psychlops.Widgets.Slider("Label", -100 <= rng <= 100);\r
+\r
+                       while (true)\r
+                       {\r
+                               cnvs.clear();\r
+                               for (int i = 0; i < n; i++)\r
+                               {\r
+                                       rect[i].centering().shift(slider * i*3, i*3).draw();\r
+                               }\r
+                               cnvs.flip();\r
+                       }\r
+               }\r
+       }\r
+}\r
+\r
+*/
\ No newline at end of file
index 5b49ffc..c6601b6 100644 (file)
@@ -70,6 +70,7 @@
     <Reference Include="system" />\r
     <Reference Include="System.Core" />\r
     <Reference Include="System.Net" />\r
+    <Reference Include="System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />\r
     <Reference Include="System.Xml" />\r
     <Reference Include="System.Windows.Browser" />\r
   </ItemGroup>\r
     <None Include="Properties\AppManifest.xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Resource Include="Resources\logo.png" />\r
     <Content Include="TestPage.html" />\r
   </ItemGroup>\r
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />\r
diff --git a/test4/Resources/logo.png b/test4/Resources/logo.png
new file mode 100644 (file)
index 0000000..ebdc130
Binary files /dev/null and b/test4/Resources/logo.png differ
index 1bcd588..23aee1f 100644 (file)
 \r
     <form id="form1" runat="server" style="height:60%">\r
     <div id="silverlightControlHost">\r
-        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="90%" height="80%">\r
+        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">\r
                  <param name="source" value="Bin/Debug/PsychlopsSilverlight4test.xap"/>\r
                  <param name="onError" value="onSilverlightError" />\r
                  <param name="background" value="white" />\r
                  <param name="minRuntimeVersion" value="3.0.40624.0" />\r
                  <param name="autoUpgrade" value="true" />\r
                  <param name="enableHtmlAccess" value="true" />\r
-                 <param name="enableGPUAcceleration" value="true" />\r
+                 <param name="enableGPUAcceleration" value="false" />\r
                  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">\r
                          <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Microsoft Silverlight を入手" style="border-style:none"/>\r
                  </a>\r