psychlops silverlight
Revision | 6f8443d682c25aa44d9158e8728ced9dd54fa4ca (tree) |
---|---|
Time | 2011-05-24 08:11:28 |
Author | HOSOKAWA Kenchi <hskwk@user...> |
Commiter | HOSOKAWA Kenchi |
shader
@@ -93,6 +93,8 @@ | ||
93 | 93 | <Compile Include="psychlops\extention\standard\widget.cs" /> |
94 | 94 | <Compile Include="psychlops\psychlops.cs" /> |
95 | 95 | <Compile Include="psychlops\core\graphic\shape.cs" /> |
96 | + <Resource Include="Shader\Grating.ps" /> | |
97 | + <Resource Include="Shader\Plaid.ps" /> | |
96 | 98 | <Resource Include="Shader\Gabor.ps" /> |
97 | 99 | <Resource Include="Shader\GaborAlpha.ps" /> |
98 | 100 | </ItemGroup> |
@@ -22,6 +22,17 @@ float phase: register(C3); | ||
22 | 22 | /// <defaultValue>0</defaultValue> |
23 | 23 | float orientation: register(C4); |
24 | 24 | |
25 | +/// <summary>Width of envelope</summary> | |
26 | +/// <minValue>1</minValue> | |
27 | +/// <maxValue>1024</maxValue> | |
28 | +/// <defaultValue>32</defaultValue> | |
29 | +float SizeH : register(C5); | |
30 | + | |
31 | +/// <summary>Height of envelope</summary> | |
32 | +/// <minValue>1</minValue> | |
33 | +/// <maxValue>1024</maxValue> | |
34 | +/// <defaultValue>32</defaultValue> | |
35 | +float SizeV : register(C6); | |
25 | 36 | |
26 | 37 | float rp(float2 uv) |
27 | 38 | { |
@@ -46,6 +46,18 @@ float phase2: register(C7); | ||
46 | 46 | /// <defaultValue>0.785398</defaultValue> |
47 | 47 | float orientation2: register(C8); |
48 | 48 | |
49 | +/// <summary>Width of envelope</summary> | |
50 | +/// <minValue>1</minValue> | |
51 | +/// <maxValue>1024</maxValue> | |
52 | +/// <defaultValue>32</defaultValue> | |
53 | +float SizeH : register(C9); | |
54 | + | |
55 | +/// <summary>Height of envelope</summary> | |
56 | +/// <minValue>1</minValue> | |
57 | +/// <maxValue>1024</maxValue> | |
58 | +/// <defaultValue>32</defaultValue> | |
59 | +float SizeV : register(C10); | |
60 | + | |
49 | 61 | |
50 | 62 | float rp(float2 uv) |
51 | 63 | { |
@@ -22,6 +22,109 @@ namespace Psychlops | ||
22 | 22 | public static partial class Figures |
23 | 23 | { |
24 | 24 | |
25 | + public class ShaderGrating : ShaderField | |
26 | + { | |
27 | + protected Shader.GratingProgram ps = null; | |
28 | + public ShaderGrating() | |
29 | + { | |
30 | + initialize__ = initialize___; | |
31 | + setParameters = setParameters__; | |
32 | + } | |
33 | + internal void initialize() | |
34 | + { | |
35 | + if (!initialized) | |
36 | + { | |
37 | + Main.canvas.beginInvoke(initialize___); | |
38 | + initialized = true; | |
39 | + } | |
40 | + } | |
41 | + internal void initialize___() | |
42 | + { | |
43 | + if (!initialized) | |
44 | + { | |
45 | + if (ps == null) | |
46 | + { | |
47 | + ps = new Shader.GratingProgram(); | |
48 | + initializeShader(); | |
49 | + } | |
50 | + shader = ps; | |
51 | + initialized = true; | |
52 | + } | |
53 | + } | |
54 | + | |
55 | + public double contrast = 1.0, wavelength = 20.0, phase = 0.0, orientation = 0.0; | |
56 | + public ShaderGrating setSize(double s) { set(s, s); return this; } | |
57 | + public ShaderGrating setSize(double h, double v) { set(h, v); return this; } | |
58 | + | |
59 | + public void setParameters__() | |
60 | + { | |
61 | + ps.Contrast = contrast; | |
62 | + ps.WaveLength = wavelength; | |
63 | + ps.Phase = phase; | |
64 | + ps.Orientation = orientation; | |
65 | + ps.SizeH = width; | |
66 | + ps.SizeV = height; | |
67 | + ps.Update(); | |
68 | + } | |
69 | + | |
70 | + | |
71 | + } | |
72 | + | |
73 | + | |
74 | + public class ShaderPlaid : ShaderField | |
75 | + { | |
76 | + protected Shader.PlaidProgram ps = null; | |
77 | + public ShaderPlaid() | |
78 | + { | |
79 | + initialize__ = initialize___; | |
80 | + setParameters = setParameters__; | |
81 | + } | |
82 | + internal void initialize() | |
83 | + { | |
84 | + if (!initialized) | |
85 | + { | |
86 | + Main.canvas.beginInvoke(initialize___); | |
87 | + initialized = true; | |
88 | + } | |
89 | + } | |
90 | + internal void initialize___() | |
91 | + { | |
92 | + if (!initialized) | |
93 | + { | |
94 | + if (ps == null) | |
95 | + { | |
96 | + ps = new Shader.PlaidProgram(); | |
97 | + initializeShader(); | |
98 | + } | |
99 | + shader = ps; | |
100 | + initialized = true; | |
101 | + } | |
102 | + } | |
103 | + | |
104 | + public double contrast = 0.5, wavelength = 20.0, phase = 0.0, orientation = 0.0; | |
105 | + public double contrast2 = 0.5, wavelength2 = 20.0, phase2 = 0.0, orientation2 = Math.PI / 4; | |
106 | + public ShaderPlaid setSize(double s) { set(s, s); return this; } | |
107 | + public ShaderPlaid setSize(double h, double v) { set(h, v); return this; } | |
108 | + | |
109 | + public void setParameters__() | |
110 | + { | |
111 | + ps.Contrast = contrast; | |
112 | + ps.WaveLength = wavelength; | |
113 | + ps.Phase = phase; | |
114 | + ps.Orientation = orientation; | |
115 | + ps.Size = width; | |
116 | + ps.Contrast2 = contrast; | |
117 | + ps.WaveLength2 = wavelength; | |
118 | + ps.Phase2 = phase; | |
119 | + ps.Orientation2 = orientation; | |
120 | + ps.SizeH = width; | |
121 | + ps.SizeV = height; | |
122 | + ps.Update(); | |
123 | + } | |
124 | + | |
125 | + | |
126 | + } | |
127 | + | |
25 | 128 | |
26 | 129 | public class ShaderGabor : ShaderField |
27 | 130 | { |
@@ -150,6 +253,334 @@ namespace Psychlops | ||
150 | 253 | { |
151 | 254 | } |
152 | 255 | |
256 | + #region GratingProgram | |
257 | + public class GratingProgram : ShaderProgram | |
258 | + { | |
259 | + public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight4;component/Shader/Grating.ps", UriKind.Relative); | |
260 | + | |
261 | + public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GratingProgram), 0); | |
262 | + public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(1D)), PixelShaderConstantCallback(1))); | |
263 | + public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2))); | |
264 | + public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3))); | |
265 | + public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4))); | |
266 | + public static readonly DependencyProperty SizeHProperty = DependencyProperty.Register("SizeH", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(5))); | |
267 | + public static readonly DependencyProperty SizeVProperty = DependencyProperty.Register("SizeV", typeof(double), typeof(GratingProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(6))); | |
268 | + public GratingProgram() | |
269 | + { | |
270 | + PixelShader pixelShader = new PixelShader(); | |
271 | + pixelShader.UriSource = ps; | |
272 | + this.PixelShader = pixelShader; | |
273 | + | |
274 | + this.UpdateShaderValue(InputProperty); | |
275 | + this.UpdateShaderValue(ContrastProperty); | |
276 | + this.UpdateShaderValue(FrequencyProperty); | |
277 | + this.UpdateShaderValue(PhaseProperty); | |
278 | + this.UpdateShaderValue(OrientationProperty); | |
279 | + this.UpdateShaderValue(SizeHProperty); | |
280 | + this.UpdateShaderValue(SizeVProperty); | |
281 | + | |
282 | + Size = 200; | |
283 | + Contrast = 1.0; | |
284 | + WaveLength = 100.0; | |
285 | + Orientation = 0.0; | |
286 | + SizeH = 32.0; | |
287 | + SizeV = 32.0; | |
288 | + } | |
289 | + | |
290 | + public void Update() | |
291 | + { | |
292 | + this.UpdateShaderValue(InputProperty); | |
293 | + this.UpdateShaderValue(ContrastProperty); | |
294 | + this.UpdateShaderValue(FrequencyProperty); | |
295 | + this.UpdateShaderValue(PhaseProperty); | |
296 | + this.UpdateShaderValue(OrientationProperty); | |
297 | + this.UpdateShaderValue(SizeHProperty); | |
298 | + this.UpdateShaderValue(SizeVProperty); | |
299 | + } | |
300 | + | |
301 | + | |
302 | + private double size__, wavelength__; | |
303 | + public double Size { get { return size__; } set { size__ = value; setFrequency(); } } | |
304 | + private void setFrequency() | |
305 | + { | |
306 | + double freq = size__ * 2.0 * Math.PI / (wavelength__); | |
307 | + this.SetValue(FrequencyProperty, freq); | |
308 | + } | |
309 | + | |
310 | + /// <summary>Amplitude of Grating</summary> | |
311 | + public double Contrast | |
312 | + { | |
313 | + get | |
314 | + { | |
315 | + return ((double)(this.GetValue(ContrastProperty))) * 2.0; | |
316 | + } | |
317 | + set | |
318 | + { | |
319 | + this.SetValue(ContrastProperty, value / 2.0); | |
320 | + } | |
321 | + } | |
322 | + /// <summary>Phase of Grating</summary> | |
323 | + public double WaveLength | |
324 | + { | |
325 | + get | |
326 | + { | |
327 | + return wavelength__; | |
328 | + } | |
329 | + set | |
330 | + { | |
331 | + wavelength__ = value; | |
332 | + setFrequency(); | |
333 | + } | |
334 | + } | |
335 | + /// <summary>Phase of Grating</summary> | |
336 | + public double Phase | |
337 | + { | |
338 | + get | |
339 | + { | |
340 | + return ((double)(this.GetValue(PhaseProperty))); | |
341 | + } | |
342 | + set | |
343 | + { | |
344 | + this.SetValue(PhaseProperty, value); | |
345 | + } | |
346 | + } | |
347 | + /// <summary>Orientation of Grating</summary> | |
348 | + public double Orientation | |
349 | + { | |
350 | + get | |
351 | + { | |
352 | + return ((double)(this.GetValue(OrientationProperty))); | |
353 | + } | |
354 | + set | |
355 | + { | |
356 | + this.SetValue(OrientationProperty, value); | |
357 | + } | |
358 | + } | |
359 | + /// <summary>Width of envelope</summary> | |
360 | + public double SizeH | |
361 | + { | |
362 | + get | |
363 | + { | |
364 | + return ((double)(this.GetValue(SizeHProperty))); | |
365 | + } | |
366 | + set | |
367 | + { | |
368 | + this.SetValue(SizeHProperty, value); | |
369 | + } | |
370 | + } | |
371 | + /// <summary>Height of Figure</summary> | |
372 | + public double SizeV | |
373 | + { | |
374 | + get | |
375 | + { | |
376 | + return ((double)(this.GetValue(SizeVProperty))); | |
377 | + } | |
378 | + set | |
379 | + { | |
380 | + this.SetValue(SizeVProperty, value); | |
381 | + } | |
382 | + } | |
383 | + } | |
384 | + #endregion | |
385 | + | |
386 | + #region PlaidProgram | |
387 | + public class PlaidProgram : ShaderProgram | |
388 | + { | |
389 | + public static readonly Uri ps = new Uri(@"/PsychlopsSilverlight4;component/Shader/Plaid.ps", UriKind.Relative); | |
390 | + | |
391 | + public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(PlaidProgram), 0); | |
392 | + public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.5D)), PixelShaderConstantCallback(1))); | |
393 | + public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(2))); | |
394 | + public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(3))); | |
395 | + public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(4))); | |
396 | + public static readonly DependencyProperty Contrast2Property = DependencyProperty.Register("Contrast2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.5D)), PixelShaderConstantCallback(5))); | |
397 | + public static readonly DependencyProperty Frequency2Property = DependencyProperty.Register("Frequency2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(100D)), PixelShaderConstantCallback(6))); | |
398 | + public static readonly DependencyProperty Phase2Property = DependencyProperty.Register("Phase2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0D)), PixelShaderConstantCallback(7))); | |
399 | + public static readonly DependencyProperty Orientation2Property = DependencyProperty.Register("Orientation2", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(0.785398D)), PixelShaderConstantCallback(8))); | |
400 | + public static readonly DependencyProperty SizeHProperty = DependencyProperty.Register("SizeH", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(9))); | |
401 | + public static readonly DependencyProperty SizeVProperty = DependencyProperty.Register("SizeV", typeof(double), typeof(PlaidProgram), new PropertyMetadata(((double)(32D)), PixelShaderConstantCallback(10))); | |
402 | + public PlaidProgram() | |
403 | + { | |
404 | + PixelShader pixelShader = new PixelShader(); | |
405 | + pixelShader.UriSource = ps; | |
406 | + this.PixelShader = pixelShader; | |
407 | + | |
408 | + this.UpdateShaderValue(InputProperty); | |
409 | + this.UpdateShaderValue(ContrastProperty); | |
410 | + this.UpdateShaderValue(FrequencyProperty); | |
411 | + this.UpdateShaderValue(PhaseProperty); | |
412 | + this.UpdateShaderValue(OrientationProperty); | |
413 | + this.UpdateShaderValue(Contrast2Property); | |
414 | + this.UpdateShaderValue(Frequency2Property); | |
415 | + this.UpdateShaderValue(Phase2Property); | |
416 | + this.UpdateShaderValue(Orientation2Property); | |
417 | + this.UpdateShaderValue(SizeHProperty); | |
418 | + this.UpdateShaderValue(SizeVProperty); | |
419 | + | |
420 | + Size = 200; | |
421 | + Contrast = 0.5; | |
422 | + WaveLength = 100.0; | |
423 | + Phase = 0.0; | |
424 | + Orientation = 0.0; | |
425 | + Contrast2 = 0.5; | |
426 | + WaveLength2 = 100.0; | |
427 | + Phase2 = 0.0; | |
428 | + Orientation2 = Math.PI/4; | |
429 | + SizeH = 32.0; | |
430 | + SizeV = 32.0; | |
431 | + } | |
432 | + | |
433 | + public void Update() | |
434 | + { | |
435 | + this.UpdateShaderValue(InputProperty); | |
436 | + this.UpdateShaderValue(ContrastProperty); | |
437 | + this.UpdateShaderValue(FrequencyProperty); | |
438 | + this.UpdateShaderValue(PhaseProperty); | |
439 | + this.UpdateShaderValue(OrientationProperty); | |
440 | + this.UpdateShaderValue(Contrast2Property); | |
441 | + this.UpdateShaderValue(Frequency2Property); | |
442 | + this.UpdateShaderValue(Phase2Property); | |
443 | + this.UpdateShaderValue(Orientation2Property); | |
444 | + this.UpdateShaderValue(SizeHProperty); | |
445 | + this.UpdateShaderValue(SizeVProperty); | |
446 | + } | |
447 | + | |
448 | + | |
449 | + private double size__, wavelength__, wavelength2__; | |
450 | + public double Size { get { return size__; } set { size__ = value; setFrequency(); } } | |
451 | + private void setFrequency() | |
452 | + { | |
453 | + double freq = size__ * 2.0 * Math.PI / (wavelength__); | |
454 | + this.SetValue(FrequencyProperty, freq); | |
455 | + double freq2 = size__ * 2.0 * Math.PI / (wavelength2__); | |
456 | + this.SetValue(Frequency2Property, freq); | |
457 | + } | |
458 | + | |
459 | + /// <summary>Amplitude of Grating</summary> | |
460 | + public double Contrast | |
461 | + { | |
462 | + get | |
463 | + { | |
464 | + return ((double)(this.GetValue(ContrastProperty))) * 2.0; | |
465 | + } | |
466 | + set | |
467 | + { | |
468 | + this.SetValue(ContrastProperty, value / 2.0); | |
469 | + } | |
470 | + } | |
471 | + /// <summary>Phase of Grating</summary> | |
472 | + public double WaveLength | |
473 | + { | |
474 | + get | |
475 | + { | |
476 | + return wavelength__; | |
477 | + } | |
478 | + set | |
479 | + { | |
480 | + wavelength__ = value; | |
481 | + setFrequency(); | |
482 | + } | |
483 | + } | |
484 | + /// <summary>Phase of Grating</summary> | |
485 | + public double Phase | |
486 | + { | |
487 | + get | |
488 | + { | |
489 | + return ((double)(this.GetValue(PhaseProperty))); | |
490 | + } | |
491 | + set | |
492 | + { | |
493 | + this.SetValue(PhaseProperty, value); | |
494 | + } | |
495 | + } | |
496 | + /// <summary>Orientation of Grating</summary> | |
497 | + public double Orientation | |
498 | + { | |
499 | + get | |
500 | + { | |
501 | + return ((double)(this.GetValue(OrientationProperty))); | |
502 | + } | |
503 | + set | |
504 | + { | |
505 | + this.SetValue(OrientationProperty, value); | |
506 | + } | |
507 | + } | |
508 | + /// <summary>Amplitude of Grating</summary> | |
509 | + public double Contrast2 | |
510 | + { | |
511 | + get | |
512 | + { | |
513 | + return ((double)(this.GetValue(Contrast2Property))) * 2.0; | |
514 | + } | |
515 | + set | |
516 | + { | |
517 | + this.SetValue(Contrast2Property, value / 2.0); | |
518 | + } | |
519 | + } | |
520 | + /// <summary>Phase of Grating</summary> | |
521 | + public double WaveLength2 | |
522 | + { | |
523 | + get | |
524 | + { | |
525 | + return wavelength2__; | |
526 | + } | |
527 | + set | |
528 | + { | |
529 | + wavelength2__ = value; | |
530 | + setFrequency(); | |
531 | + } | |
532 | + } | |
533 | + /// <summary>Phase2 of Grating</summary> | |
534 | + public double Phase2 | |
535 | + { | |
536 | + get | |
537 | + { | |
538 | + return ((double)(this.GetValue(Phase2Property))); | |
539 | + } | |
540 | + set | |
541 | + { | |
542 | + this.SetValue(Phase2Property, value); | |
543 | + } | |
544 | + } | |
545 | + /// <summary>Orientation2 of Grating</summary> | |
546 | + public double Orientation2 | |
547 | + { | |
548 | + get | |
549 | + { | |
550 | + return ((double)(this.GetValue(Orientation2Property))); | |
551 | + } | |
552 | + set | |
553 | + { | |
554 | + this.SetValue(Orientation2Property, value); | |
555 | + } | |
556 | + } | |
557 | + /// <summary>Width of envelope</summary> | |
558 | + public double SizeH | |
559 | + { | |
560 | + get | |
561 | + { | |
562 | + return ((double)(this.GetValue(SizeHProperty))); | |
563 | + } | |
564 | + set | |
565 | + { | |
566 | + this.SetValue(SizeHProperty, value); | |
567 | + } | |
568 | + } | |
569 | + /// <summary>Height of Figure</summary> | |
570 | + public double SizeV | |
571 | + { | |
572 | + get | |
573 | + { | |
574 | + return ((double)(this.GetValue(SizeVProperty))); | |
575 | + } | |
576 | + set | |
577 | + { | |
578 | + this.SetValue(SizeVProperty, value); | |
579 | + } | |
580 | + } | |
581 | + } | |
582 | + #endregion | |
583 | + | |
153 | 584 | #region GaborProgram |
154 | 585 | public class GaborProgram : ShaderProgram |
155 | 586 | { |
@@ -1,4 +1,79 @@ | ||
1 | -/* | |
1 | + | |
2 | + | |
3 | + | |
4 | +using Psychlops; | |
5 | +//Position Bias Program | |
6 | +namespace PsychlopsSilverlightApp | |
7 | +{ | |
8 | + | |
9 | + public class PsychlopsMain | |
10 | + { | |
11 | + Canvas cnvs; | |
12 | + Image img, img2, img3; | |
13 | + int isize = 40; | |
14 | + int frames; | |
15 | + Psychlops.Widgets.Slider tfreq; | |
16 | + Psychlops.Widgets.Slider contrast; | |
17 | + Psychlops.Widgets.Slider lambda; | |
18 | + | |
19 | + | |
20 | + | |
21 | + public void psychlops_main() | |
22 | + { | |
23 | + cnvs = new Canvas(300, 600); | |
24 | + Interval rng = new Interval(); | |
25 | + tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0); | |
26 | + contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25); | |
27 | + lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30); | |
28 | + | |
29 | + img = new Image(isize * 2, isize * 2); | |
30 | + img2 = new Image(isize * 2, isize * 2); | |
31 | + img3 = new Image(isize * 2, isize * 2); | |
32 | + | |
33 | + var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100); | |
34 | + foreach (var g in gabor1) | |
35 | + { | |
36 | + g.setSigma(isize/8).centering().shift(Math.random(300) - 150, Math.random(600) - 300); | |
37 | + //g.setSize(isize).centering().shift(Math.random(300) - 150, Math.random(600) - 300); | |
38 | + g.orientation = Math.random(2 * Math.PI); | |
39 | + //g.orientation2 = Math.random(2 * Math.PI); | |
40 | + } | |
41 | + | |
42 | + while (true) | |
43 | + { | |
44 | + cnvs.clear(new Color(0.5)); | |
45 | + | |
46 | + Figures.drawGabor(ref img, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); | |
47 | + Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60); | |
48 | + Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); | |
49 | + | |
50 | + | |
51 | + //img.centering().shift(0, -isize * 1.5).draw(); | |
52 | + //img2.centering().draw(); | |
53 | + //img3.centering().shift(0, isize * 1.5).draw(); | |
54 | + | |
55 | + | |
56 | + foreach (var g in gabor1) | |
57 | + { | |
58 | + g.wavelength = lambda; | |
59 | + g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60; | |
60 | + g.contrast = contrast; | |
61 | + //g.wavelength2 = lambda * 2; | |
62 | + //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60; | |
63 | + //g.contrast2 = contrast / 2; | |
64 | + g.draw(); | |
65 | + } | |
66 | + | |
67 | + if (!Mouse.left.pressed()) frames++; | |
68 | + | |
69 | + cnvs.flip(); | |
70 | + } | |
71 | + } | |
72 | + } | |
73 | +} | |
74 | + | |
75 | + | |
76 | +/* | |
2 | 77 | ///+ Prefix linkto BasicCode1 |
3 | 78 | //// Lines for set up Psychlops environment |
4 | 79 | using Psychlops; |
@@ -540,75 +615,3 @@ using Psychlops; | ||
540 | 615 | } |
541 | 616 | } |
542 | 617 | */ |
543 | - | |
544 | - | |
545 | - | |
546 | -using Psychlops; | |
547 | -//Position Bias Program | |
548 | -namespace PsychlopsSilverlightApp | |
549 | -{ | |
550 | - | |
551 | - public class PsychlopsMain | |
552 | - { | |
553 | - Canvas cnvs; | |
554 | - Image img, img2, img3; | |
555 | - int isize = 40; | |
556 | - int frames; | |
557 | - Psychlops.Widgets.Slider tfreq; | |
558 | - Psychlops.Widgets.Slider contrast; | |
559 | - Psychlops.Widgets.Slider lambda; | |
560 | - | |
561 | - | |
562 | - | |
563 | - public void psychlops_main() | |
564 | - { | |
565 | - cnvs = new Canvas(300, 600); | |
566 | - Interval rng = new Interval(); | |
567 | - tfreq = new Psychlops.Widgets.Slider("Temporal Frequency(Hz)", -5 <= rng <= 5, 3.0); | |
568 | - contrast = new Psychlops.Widgets.Slider("Contrast", 0.0 <= rng <= 1.0, 0.25); | |
569 | - lambda = new Psychlops.Widgets.Slider("Wave Length", 10.0 <= rng <= 120.0, 30); | |
570 | - | |
571 | - img = new Image(isize * 2, isize * 2); | |
572 | - img2 = new Image(isize * 2, isize * 2); | |
573 | - img3 = new Image(isize * 2, isize * 2); | |
574 | - | |
575 | -<<<<<<< HEAD | |
576 | - var gabor1 = StaticFunctions.NewArray<Figures.ShaderGabor>(100); | |
577 | -======= | |
578 | - var gabor1 = StaticFunctions.NewArray<Figures.ShaderGaborAlpha>(100); | |
579 | ->>>>>>> remotes/psychlopssilverlight/master | |
580 | - foreach(var g in gabor1) | |
581 | - { | |
582 | - g.setSigma(isize / 8).centering().shift(Math.random(300) - 150, Math.random(600) - 300); | |
583 | - g.orientation = Math.random(2*Math.PI); | |
584 | - } | |
585 | - | |
586 | - while (true) | |
587 | - { | |
588 | - cnvs.clear(new Color(0.5)); | |
589 | - | |
590 | - Figures.drawGabor(ref img, isize / 8, 1/lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); | |
591 | - Figures.drawGabor(ref img2, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * -tfreq / 60); | |
592 | - Figures.drawGabor(ref img3, isize / 8, 1 / lambda, contrast, 0.5 * Math.PI, (double)frames * 2.0 * Math.PI * tfreq / 60); | |
593 | - | |
594 | - | |
595 | - //img.centering().shift(0, -isize * 1.5).draw(); | |
596 | - //img2.centering().draw(); | |
597 | - //img3.centering().shift(0, isize * 1.5).draw(); | |
598 | - | |
599 | - | |
600 | - foreach (var g in gabor1) | |
601 | - { | |
602 | - g.wavelength = lambda; | |
603 | - g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60; | |
604 | - g.contrast = contrast; | |
605 | - g.draw(); | |
606 | - } | |
607 | - | |
608 | - if (!Mouse.left.pressed()) frames++; | |
609 | - | |
610 | - cnvs.flip(); | |
611 | - } | |
612 | - } | |
613 | - } | |
614 | -} |