Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using static Sio.Basic;
- using Sio;
- using Sio.LibDX;
- namespace Sio.Bibo.Vis
- {
- public class Mandara : Atai.Interface.IRemove
- {
- static bool s_colorSwap = false;
- public static void s_SwitchColorSwapMode()
- {
- s_colorSwap = !s_colorSwap;
- Dbg.AddLog("Mandara.s_SwitchSwapMode() new Value=[" + s_colorSwap + "]");
- }
- int _methodType = 0;
- const int MethodTypeMax = 3;
- const int BlendParamStart = 100;
- const int BlendMax = 200;
- const int BlendDecrement = 1;
- const int BlendIncrement = 10;
- int _blendParam = BlendParamStart;
- Atai.FlipFlop _divLenFF = new();
- Atai.FlipFlop _pointsCountFF = new();
- Atai.FlipFlop _methodTypeFF = new();
- const float PI2 = MathF.PI * 2;
- int _max;
- int _dist = 2;
- float R { get => GetRadius(); }
- Sio.Atai.Integer _frameInt = new();
- readonly Vector2[] _points = new Vector2[0];
- Vector2 _center = new();
- const uint CoolTimeMax = 6;
- bool _isVanishing = false;
- bool _isAppearing = true;
- //bool _writeInfo = true;
- bool _writeInfoOnce = false;
- static string[] s_varName = { "mulFrame", "_points.Count", "_center.X" };
- public Mandara(int pointCount, int dist, int methodType)
- {
- _max = pointCount;
- _points = new Vector2[_max];
- _center = new(Glo.CenterX, Glo.CenterY);
- _dist = dist;
- _methodType = methodType;
- SetPointsAll(0);
- }
- float GetRadius()
- {
- float buf = Sio.Basic.Min(Glo.WinX, Glo.WinY);//小さい方を取得
- //float max=Max(Glo.WinX, Glo.WinY);
- //Console.WriteLine("At Mandara.GetRadius(), GetMin()[{0}], Max[{1}]",buf,max);
- float result = buf * 0.9f;//ウィンドウサイズの90%に
- result /= 2f;//円の半径なので二で割る。
- //Console.WriteLine("result " + result);
- return result;
- }
- public void SetSyncFrame(Atai.Integer frame)
- {
- _frameInt = frame;
- }
- public void Draw()
- {
- //Console.WriteLine(Kakko(s_varName, vars));
- SetPointsAll(Glo.Frame);
- uint color1, color2;
- var mouseV2 = Input.LimitedMouse_V2;
- int mouseX = (int)mouseV2.X;
- int perMilliRange = 50 + 300 * (int)mouseV2.Y / Glo.WinY;
- int perMilliMin = (999 - perMilliRange) * mouseX / Glo.WinX;
- LibDX.Blend.TempAlphaOn(_blendParam);
- if (_isVanishing) { LibDX.Blend.OnMul(2, _blendParam / 5); }
- for (int i = 0; i < _points.Length; i++)
- {
- int dist = _dist;
- if (dist < 1) { dist = 1; }
- int target;
- switch (_methodType)
- {
- case 0: target = i + _points.Length * 2 / dist; break;
- case 1: target = (i + _points.Length * 2) / dist; break;
- default:
- target = i + (_points.Length - dist); break;
- }
- //target++;
- target = Math.Abs(target);
- target %= _points.Length;
- //Console.Write(_points[i]);
- int angle = Sankaku.AngleMax * i / _points.Length;
- int perMilli = Sankaku.IIsin(perMilliRange / 2, angle);
- int gaugeRatio = perMilli + perMilliMin;
- if (_writeInfoOnce)
- {
- Console.WriteLine("i[{0}],target[{1}],gaugeRatio[{2}]", i, target, gaugeRatio);
- }
- color1 = Sio.Gra.Color.Gauge.GetLightColor(gaugeRatio);
- color2 = Sio.Gra.Color.Gauge.GetHeatColor(gaugeRatio * 10 / 7);
- if (s_colorSwap)
- {
- LibDX.Wrap.DrawLineDouble(_points[i], _points[target], color1, color2, 3, 1);
- }
- else
- {
- LibDX.Wrap.DrawLineDouble(_points[i], _points[target], color2, color1, 3, 1);
- }
- LibDX.Blend.TempRevert();
- if (_isVanishing) { LibDX.Blend.Revert(); }
- _writeInfoOnce = false;
- }
- }
- public void Vanish()
- {
- _isVanishing = true;
- _isAppearing = false;
- }
- public void SetBlendParam(int param)
- {
- _blendParam = param;
- }
- public void Update()
- {
- if (_isAppearing)
- {
- _blendParam += BlendIncrement;
- if (_blendParam < BlendMax)
- {
- _isAppearing = false;
- _blendParam = BlendMax;
- }
- return;
- }
- if (_isVanishing) { _blendParam -= BlendDecrement; }
- }
- public void SetPointsAll(int addAngle)
- {
- for (int i = 0; i < _points.Length; i++)
- {
- float angle = PI2 * i / _max - addAngle;
- _points[i] = new(
- MathF.Sin(angle) * R + _center.X,
- -MathF.Cos(angle) * R + _center.Y
- );
- }
- }
- public bool IIGetRemoveFlag()
- {
- return _blendParam <= 0;
- }
- }
- }
Advertisement