1 | ///
|
---|
2 | /// This file is part of ILNumerics Community Edition.
|
---|
3 | ///
|
---|
4 | /// ILNumerics Community Edition - high performance computing for applications.
|
---|
5 | /// Copyright (C) 2006 - 2012 Haymo Kutschbach, http://ilnumerics.net
|
---|
6 | ///
|
---|
7 | /// ILNumerics Community Edition is free software: you can redistribute it and/or modify
|
---|
8 | /// it under the terms of the GNU General Public License version 3 as published by
|
---|
9 | /// the Free Software Foundation.
|
---|
10 | ///
|
---|
11 | /// ILNumerics Community Edition is distributed in the hope that it will be useful,
|
---|
12 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | /// GNU General Public License for more details.
|
---|
15 | ///
|
---|
16 | /// You should have received a copy of the GNU General Public License
|
---|
17 | /// along with ILNumerics Community Edition. See the file License.txt in the root
|
---|
18 | /// of your distribution package. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | ///
|
---|
20 | /// In addition this software uses the following components and/or licenses:
|
---|
21 | ///
|
---|
22 | /// =================================================================================
|
---|
23 | /// The Open Toolkit Library License
|
---|
24 | ///
|
---|
25 | /// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
---|
26 | ///
|
---|
27 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
28 | /// of this software and associated documentation files (the "Software"), to deal
|
---|
29 | /// in the Software without restriction, including without limitation the rights to
|
---|
30 | /// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
---|
31 | /// the Software, and to permit persons to whom the Software is furnished to do
|
---|
32 | /// so, subject to the following conditions:
|
---|
33 | ///
|
---|
34 | /// The above copyright notice and this permission notice shall be included in all
|
---|
35 | /// copies or substantial portions of the Software.
|
---|
36 | ///
|
---|
37 | /// =================================================================================
|
---|
38 | ///
|
---|
39 |
|
---|
40 | #pragma warning disable 1591
|
---|
41 |
|
---|
42 | using System;
|
---|
43 | using System.Collections.Generic;
|
---|
44 | using System.Text;
|
---|
45 | using ILNumerics;
|
---|
46 |
|
---|
47 | namespace ILNumerics.Drawing.Misc {
|
---|
48 |
|
---|
49 | public class ILActionRamp : List<ILActionRampElement> {
|
---|
50 |
|
---|
51 | public static ILActionRamp s_OverrideRamp;
|
---|
52 | public static ILActionRamp Override {
|
---|
53 | get {
|
---|
54 | if (s_OverrideRamp == null) {
|
---|
55 | using (ILScope.Enter()) {
|
---|
56 | s_OverrideRamp = new ILActionRamp();
|
---|
57 | ILArray<float> tmp = ILMath.sin(ILMath.linspace<float>(-ILMath.pi / 1.7, ILMath.pi / 1.7, 20));
|
---|
58 | tmp -= tmp[0];
|
---|
59 | tmp /= tmp["end"];
|
---|
60 | foreach (float val in tmp) {
|
---|
61 | s_OverrideRamp.Add(new ILActionRampElement(val, .02f));
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 | return s_OverrideRamp;
|
---|
66 | }
|
---|
67 | }
|
---|
68 | public static ILActionRamp s_softRamp;
|
---|
69 | public static ILActionRamp Soft {
|
---|
70 | get {
|
---|
71 | if (s_softRamp == null) {
|
---|
72 | using (ILScope.Enter()) {
|
---|
73 | s_softRamp = new ILActionRamp();
|
---|
74 | ILArray<float> tmp = ILMath.sin(ILMath.linspace<float>(-ILMath.pif / 2f, ILMath.pif / 2f, 10f));
|
---|
75 | tmp += 1;
|
---|
76 | tmp /= 2;
|
---|
77 | foreach (float val in tmp) {
|
---|
78 | s_softRamp.Add(new ILActionRampElement(val, .02f));
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|
82 | return s_softRamp;
|
---|
83 | }
|
---|
84 | }
|
---|
85 | public static ILActionRamp s_hardRamp;
|
---|
86 | public static ILActionRamp Hard {
|
---|
87 | get {
|
---|
88 | if (s_hardRamp == null) {
|
---|
89 | using (ILScope.Enter()) {
|
---|
90 | s_hardRamp = new ILActionRamp();
|
---|
91 | ILArray<float> tmp = ILMath.sin(ILMath.linspace<float>(0.0, 1.0, 10.0));
|
---|
92 | foreach (float val in tmp) {
|
---|
93 | s_hardRamp.Add(new ILActionRampElement(val, .02f));
|
---|
94 | }
|
---|
95 | }
|
---|
96 | }
|
---|
97 | return s_hardRamp;
|
---|
98 | }
|
---|
99 | }
|
---|
100 | public static ILActionRamp s_linearRamp;
|
---|
101 | public static ILActionRamp Linear {
|
---|
102 | get {
|
---|
103 | if (s_linearRamp == null) {
|
---|
104 | using (ILScope.Enter()) {
|
---|
105 | s_linearRamp = new ILActionRamp();
|
---|
106 | for (int i = 0; i < 10; i++) {
|
---|
107 | s_linearRamp.Add(new ILActionRampElement(i / 9.0f, 0.02f));
|
---|
108 | }
|
---|
109 | }
|
---|
110 | }
|
---|
111 | return s_linearRamp;
|
---|
112 | }
|
---|
113 | }
|
---|
114 | public static ILActionRamp s_noRamp;
|
---|
115 | public static ILActionRamp NoRamp {
|
---|
116 | get {
|
---|
117 | if (s_noRamp == null) {
|
---|
118 | s_noRamp = new ILActionRamp();
|
---|
119 | s_noRamp.Add(new ILActionRampElement(1, 0));
|
---|
120 | }
|
---|
121 | return s_noRamp;
|
---|
122 | }
|
---|
123 | }
|
---|
124 |
|
---|
125 | public ILActionRamp() {}
|
---|
126 | }
|
---|
127 | }
|
---|