Guest User

Mandara

a guest
Sep 20th, 2023
41
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Reflection;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using static Sio.Basic;
  9. using Sio;
  10. using Sio.LibDX;
  11.  
  12. namespace Sio.Bibo.Vis
  13. {
  14. public class Mandara : Atai.Interface.IRemove
  15. {
  16. static bool s_colorSwap = false;
  17. public static void s_SwitchColorSwapMode()
  18. {
  19. s_colorSwap = !s_colorSwap;
  20. Dbg.AddLog("Mandara.s_SwitchSwapMode() new Value=[" + s_colorSwap + "]");
  21. }
  22. int _methodType = 0;
  23. const int MethodTypeMax = 3;
  24. const int BlendParamStart = 100;
  25. const int BlendMax = 200;
  26. const int BlendDecrement = 1;
  27. const int BlendIncrement = 10;
  28. int _blendParam = BlendParamStart;
  29. Atai.FlipFlop _divLenFF = new();
  30. Atai.FlipFlop _pointsCountFF = new();
  31. Atai.FlipFlop _methodTypeFF = new();
  32. const float PI2 = MathF.PI * 2;
  33. int _max;
  34. int _dist = 2;
  35. float R { get => GetRadius(); }
  36. Sio.Atai.Integer _frameInt = new();
  37. readonly Vector2[] _points = new Vector2[0];
  38. Vector2 _center = new();
  39. const uint CoolTimeMax = 6;
  40. bool _isVanishing = false;
  41. bool _isAppearing = true;
  42. //bool _writeInfo = true;
  43. bool _writeInfoOnce = false;
  44.  
  45.  
  46.  
  47. static string[] s_varName = { "mulFrame", "_points.Count", "_center.X" };
  48. public Mandara(int pointCount, int dist, int methodType)
  49. {
  50. _max = pointCount;
  51. _points = new Vector2[_max];
  52. _center = new(Glo.CenterX, Glo.CenterY);
  53. _dist = dist;
  54. _methodType = methodType;
  55. SetPointsAll(0);
  56. }
  57. float GetRadius()
  58. {
  59. float buf = Sio.Basic.Min(Glo.WinX, Glo.WinY);//小さい方を取得
  60. //float max=Max(Glo.WinX, Glo.WinY);
  61. //Console.WriteLine("At Mandara.GetRadius(), GetMin()[{0}], Max[{1}]",buf,max);
  62. float result = buf * 0.9f;//ウィンドウサイズの90%に
  63. result /= 2f;//円の半径なので二で割る。
  64. //Console.WriteLine("result " + result);
  65. return result;
  66. }
  67. public void SetSyncFrame(Atai.Integer frame)
  68. {
  69. _frameInt = frame;
  70. }
  71. public void Draw()
  72. {
  73. //Console.WriteLine(Kakko(s_varName, vars));
  74. SetPointsAll(Glo.Frame);
  75. uint color1, color2;
  76.  
  77. var mouseV2 = Input.LimitedMouse_V2;
  78. int mouseX = (int)mouseV2.X;
  79.  
  80. int perMilliRange = 50 + 300 * (int)mouseV2.Y / Glo.WinY;
  81. int perMilliMin = (999 - perMilliRange) * mouseX / Glo.WinX;
  82.  
  83.  
  84. LibDX.Blend.TempAlphaOn(_blendParam);
  85. if (_isVanishing) { LibDX.Blend.OnMul(2, _blendParam / 5); }
  86. for (int i = 0; i < _points.Length; i++)
  87. {
  88. int dist = _dist;
  89. if (dist < 1) { dist = 1; }
  90. int target;
  91. switch (_methodType)
  92. {
  93. case 0: target = i + _points.Length * 2 / dist; break;
  94.  
  95. case 1: target = (i + _points.Length * 2) / dist; break;
  96. default:
  97. target = i + (_points.Length - dist); break;
  98. }
  99.  
  100. //target++;
  101.  
  102. target = Math.Abs(target);
  103. target %= _points.Length;
  104.  
  105.  
  106. //Console.Write(_points[i]);
  107. int angle = Sankaku.AngleMax * i / _points.Length;
  108. int perMilli = Sankaku.IIsin(perMilliRange / 2, angle);
  109. int gaugeRatio = perMilli + perMilliMin;
  110. if (_writeInfoOnce)
  111. {
  112. Console.WriteLine("i[{0}],target[{1}],gaugeRatio[{2}]", i, target, gaugeRatio);
  113.  
  114. }
  115.  
  116.  
  117. color1 = Sio.Gra.Color.Gauge.GetLightColor(gaugeRatio);
  118. color2 = Sio.Gra.Color.Gauge.GetHeatColor(gaugeRatio * 10 / 7);
  119.  
  120. if (s_colorSwap)
  121. {
  122. LibDX.Wrap.DrawLineDouble(_points[i], _points[target], color1, color2, 3, 1);
  123. }
  124. else
  125. {
  126. LibDX.Wrap.DrawLineDouble(_points[i], _points[target], color2, color1, 3, 1);
  127. }
  128.  
  129. LibDX.Blend.TempRevert();
  130. if (_isVanishing) { LibDX.Blend.Revert(); }
  131. _writeInfoOnce = false;
  132. }
  133. }
  134. public void Vanish()
  135. {
  136. _isVanishing = true;
  137. _isAppearing = false;
  138. }
  139. public void SetBlendParam(int param)
  140. {
  141. _blendParam = param;
  142. }
  143. public void Update()
  144. {
  145. if (_isAppearing)
  146. {
  147. _blendParam += BlendIncrement;
  148. if (_blendParam < BlendMax)
  149. {
  150. _isAppearing = false;
  151. _blendParam = BlendMax;
  152. }
  153. return;
  154. }
  155. if (_isVanishing) { _blendParam -= BlendDecrement; }
  156. }
  157.  
  158. public void SetPointsAll(int addAngle)
  159. {
  160. for (int i = 0; i < _points.Length; i++)
  161. {
  162. float angle = PI2 * i / _max - addAngle;
  163. _points[i] = new(
  164. MathF.Sin(angle) * R + _center.X,
  165. -MathF.Cos(angle) * R + _center.Y
  166. );
  167.  
  168. }
  169. }
  170. public bool IIGetRemoveFlag()
  171. {
  172. return _blendParam <= 0;
  173. }
  174. }
  175. }
  176.  
  177.  
  178.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment