Skip to content

Commit ae2d61a

Browse files
committed
fix some animations and older profile imports
1 parent 29a69a3 commit ae2d61a

12 files changed

Lines changed: 105 additions & 212 deletions

Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationCircle.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@ namespace Aurora.EffectsEngine.Animations
77
public class AnimationCircle : AnimationFrame
88
{
99
[Newtonsoft.Json.JsonProperty]
10-
internal float _radius = 0.0f;
10+
internal float _radius;
1111

1212
public float Radius => _radius;
13-
public PointF Center => _center;
13+
public PointF Center => _dimension.Location;
1414

1515
public AnimationFrame SetRadius(float radius)
1616
{
1717
_radius = radius;
18-
_dimension = new RectangleF(_center.X - _radius, _center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
19-
_center = new PointF(_dimension.X + _radius, _dimension.Y + _radius);
18+
_dimension = new RectangleF(_dimension.X - _radius, _dimension.Y - _radius, 2.0f * _radius, 2.0f * _radius);
2019
_invalidated = true;
2120

2221
return this;
2322
}
2423

2524
public AnimationFrame SetCenter(PointF center)
2625
{
27-
_center = center;
28-
_dimension = new RectangleF(_center.X - _radius, _center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
26+
_dimension = new RectangleF(center.X - _radius, center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
2927
_invalidated = true;
3028

3129
return this;
@@ -34,8 +32,7 @@ public AnimationFrame SetCenter(PointF center)
3432
public AnimationCircle()
3533
{
3634
_radius = 0;
37-
_center = new PointF(0, 0);
38-
_dimension = new RectangleF(_center.X - _radius, _center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
35+
_dimension = new RectangleF(- _radius, - _radius, 2.0f * _radius, 2.0f * _radius);
3936
_color = Utils.ColorUtils.GenerateRandomColor();
4037
_width = 1;
4138
_duration = 0.0f;
@@ -44,32 +41,27 @@ public AnimationCircle()
4441
public AnimationCircle(AnimationFrame frame, float radius) : base(frame)
4542
{
4643
_radius = radius;
47-
_center = new PointF(_dimension.X + _radius, _dimension.Y + _radius);
4844
}
4945

5046
public AnimationCircle(AnimationCircle animationCircle) : base(animationCircle)
5147
{
5248
_radius = animationCircle.Radius;
53-
_center = animationCircle.Center;
5449
}
5550

5651
public AnimationCircle(Rectangle dimension, Color color, int width = 1, float duration = 0.0f) : base(dimension, color, width, duration)
5752
{
5853
_radius = dimension.Width / 2.0f;
59-
_center = new PointF(dimension.X + _radius, dimension.Y + _radius);
6054
}
6155

6256
public AnimationCircle(RectangleF dimension, Color color, int width = 1, float duration = 0.0f) : base(dimension, color, width, duration)
6357
{
6458
_radius = dimension.Width / 2.0f;
65-
_center = new PointF(dimension.X + _radius, dimension.Y + _radius);
6659
}
6760

6861
public AnimationCircle(PointF center, float radius, Color color, int width = 1, float duration = 0.0f)
6962
{
7063
_radius = radius;
71-
_center = center;
72-
_dimension = new RectangleF(_center.X - _radius, _center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
64+
_dimension = new RectangleF(center.X - _radius, center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
7365
_color = color;
7466
_width = width;
7567
_duration = duration;
@@ -78,8 +70,7 @@ public AnimationCircle(PointF center, float radius, Color color, int width = 1,
7870
public AnimationCircle(float x, float y, float radius, Color color, int width = 1, float duration = 0.0f)
7971
{
8072
_radius = radius;
81-
_center = new PointF(x, y);
82-
_dimension = new RectangleF(_center.X - _radius, _center.Y - _radius, 2.0f * _radius, 2.0f * _radius);
73+
_dimension = new RectangleF(x - _radius, y - _radius, 2.0f * _radius, 2.0f * _radius);
8374
_color = color;
8475
_width = width;
8576
_duration = duration;
@@ -91,8 +82,8 @@ public override void Draw(Graphics g)
9182
{
9283
_pen = new Pen(_color);
9384
_pen.Width = _width;
94-
//_pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
95-
//_pen.ScaleTransform(Scale, Scale);
85+
_pen.Alignment = PenAlignment.Center;
86+
_pen.ScaleTransform(Scale, Scale);
9687

9788
virtUpdate();
9889
_invalidated = false;

Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationEllipse.cs

Lines changed: 15 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,76 @@
11
using System;
22
using System.Drawing;
33
using System.Drawing.Drawing2D;
4+
using Aurora.Utils;
45

56
namespace Aurora.EffectsEngine.Animations
67
{
7-
public class AnimationEllipse : AnimationFrame
8+
public class AnimationEllipse : AnimationCircle
89
{
910
[Newtonsoft.Json.JsonProperty]
10-
private float _radius_x = 0.0f;
11+
private float _radius_x;
1112
[Newtonsoft.Json.JsonProperty]
12-
private float _radius_y = 0.0f;
13-
[Newtonsoft.Json.JsonProperty]
14-
private PointF _center = new PointF();
15-
16-
public float RadiusHorizontal { get { return _radius_x; } }
17-
public float RadiusVertical { get { return _radius_y; } }
18-
public PointF Center { get { return _center; } }
19-
20-
21-
public AnimationFrame SetRadiusHorizontal(float radius)
22-
{
23-
_radius_x = radius;
24-
_dimension = new RectangleF(_center.X - _radius_x, _center.Y - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
25-
_invalidated = true;
26-
27-
return this;
28-
}
29-
30-
public AnimationFrame SetRadiusVertical(float radius)
31-
{
32-
_radius_y = radius;
33-
_dimension = new RectangleF(_center.X - _radius_x, _center.Y - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
34-
_invalidated = true;
35-
36-
return this;
37-
}
38-
39-
public AnimationFrame SetCenter(PointF center)
40-
{
41-
_center = center;
42-
_dimension = new RectangleF(_center.X - _radius_x, _center.Y - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
43-
_invalidated = true;
44-
45-
return this;
46-
}
13+
private float _radius_y;
4714

4815
public AnimationEllipse()
4916
{
5017
_radius_x = 0;
5118
_radius_y = 0;
52-
_center = new PointF(0, 0);
53-
_dimension = new RectangleF(_center.X - _radius_x, _center.Y - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
54-
_color = Utils.ColorUtils.GenerateRandomColor();
19+
_dimension = new RectangleF(- _radius_x, - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
20+
_color = ColorUtils.GenerateRandomColor();
5521
_width = 1;
5622
_duration = 0.0f;
5723
}
5824

59-
public AnimationEllipse(AnimationFrame frame, float radiusX, float radiusY) : base(frame)
25+
public AnimationEllipse(AnimationFrame frame, float radiusX, float radiusY) : base(frame, radiusX)
6026
{
6127
_radius_x = radiusX;
6228
_radius_y = radiusY;
63-
_center = new PointF(_dimension.X + _radius_x, _dimension.Y + _radius_y);
6429
}
6530

6631
public AnimationEllipse(AnimationEllipse animationEllipse) : base(animationEllipse)
6732
{
6833
_radius_x = animationEllipse._radius_x;
6934
_radius_y = animationEllipse._radius_y;
70-
_center = animationEllipse._center;
7135
}
7236

7337
public AnimationEllipse(Rectangle dimension, Color color, int width = 1, float duration = 0.0f) : base(dimension, color, width, duration)
7438
{
7539
_radius_x = dimension.Width / 2.0f;
7640
_radius_y = dimension.Height / 2.0f;
77-
_center = new PointF(dimension.X + _radius_x, dimension.Y + _radius_y);
7841
}
7942

8043
public AnimationEllipse(RectangleF dimension, Color color, int width = 1, float duration = 0.0f) : base(dimension, color, width, duration)
8144
{
8245
_radius_x = dimension.Width / 2.0f;
8346
_radius_y = dimension.Height / 2.0f;
84-
_center = new PointF(dimension.X + _radius_x, dimension.Y + _radius_y);
8547
}
8648

87-
public AnimationEllipse(PointF center, float x_axis, float y_axis, Color color, int width = 1, float duration = 0.0f)
49+
public AnimationEllipse(PointF center, float xAxis, float yAxis, Color color, int width = 1, float duration = 0.0f)
8850
{
89-
_radius_x = x_axis;
90-
_radius_y = y_axis;
91-
_center = new PointF(center.X + _radius_x, center.Y + _radius_y);
92-
_dimension = new RectangleF(_center.X - _radius_x, _center.Y - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
51+
_radius_x = xAxis;
52+
_radius_y = yAxis;
53+
_dimension = new RectangleF(center.X , center.Y, 2.0f * _radius_x, 2.0f * _radius_y);
9354
_color = color;
9455
_width = width;
9556
_duration = duration;
9657
}
9758

98-
public AnimationEllipse(float x, float y, float x_axis, float y_axis, Color color, int width = 1, float duration = 0.0f)
59+
public AnimationEllipse(float x, float y, float xAxis, float yAxis, Color color, int width = 1, float duration = 0.0f)
9960
{
100-
_radius_x = x_axis;
101-
_radius_y = y_axis;
102-
_center = new PointF(x + _radius_x, y + _radius_y);
103-
_dimension = new RectangleF(_center.X - _radius_x, _center.Y - _radius_y, 2.0f * _radius_x, 2.0f * _radius_y);
61+
_radius_x = xAxis;
62+
_radius_y = yAxis;
63+
_dimension = new RectangleF(x , y, 2.0f * _radius_x, 2.0f * _radius_y);
10464
_color = color;
10565
_width = width;
10666
_duration = duration;
10767
}
10868

109-
protected override void virtUpdate()
110-
{
111-
base._center = new PointF(_center.X * Scale, _center.Y * Scale);
112-
113-
base.virtUpdate();
114-
}
115-
116-
public override void Draw(Graphics g)
117-
{
118-
if (_pen == null || _invalidated)
119-
{
120-
_pen = new Pen(_color);
121-
_pen.Width = _width;
122-
_pen.Alignment = System.Drawing.Drawing2D.PenAlignment.Center;
123-
_pen.ScaleTransform(Scale, Scale);
124-
125-
virtUpdate();
126-
_invalidated = false;
127-
}
128-
129-
g.ResetTransform();
130-
g.DrawEllipse(_pen, _dimension);
131-
}
132-
133-
public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
134-
{
135-
if (!(otherAnim is AnimationEllipse))
136-
{
137-
throw new FormatException("Cannot blend with another type");
138-
}
139-
140-
amount = GetTransitionValue(amount);
141-
142-
RectangleF newrect = new RectangleF((float)CalculateNewValue(_dimension.X, otherAnim._dimension.X, amount),
143-
(float)CalculateNewValue(_dimension.Y, otherAnim._dimension.Y, amount),
144-
(float)CalculateNewValue(_dimension.Width, otherAnim._dimension.Width, amount),
145-
(float)CalculateNewValue(_dimension.Height, otherAnim._dimension.Height, amount)
146-
);
147-
148-
int newwidth = (int)CalculateNewValue(_width, otherAnim._width, amount);
149-
float newAngle = (float)CalculateNewValue(_angle, otherAnim._angle, amount);
150-
151-
return new AnimationEllipse(newrect, Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount), newwidth).SetAngle(newAngle);
152-
}
153-
15469
public override AnimationFrame GetCopy()
15570
{
15671
return new AnimationEllipse(this);
15772
}
15873

159-
public override bool Equals(object obj)
160-
{
161-
if (ReferenceEquals(null, obj)) return false;
162-
if (ReferenceEquals(this, obj)) return true;
163-
if (obj.GetType() != this.GetType()) return false;
164-
return Equals((AnimationEllipse)obj);
165-
}
166-
167-
public bool Equals(AnimationEllipse p)
168-
{
169-
return _color.Equals(p._color) &&
170-
_dimension.Equals(p._dimension) &&
171-
_width.Equals(p._width) &&
172-
_duration.Equals(p._duration) &&
173-
_angle.Equals(p._angle);
174-
}
175-
17674
public override int GetHashCode()
17775
{
17876
unchecked

Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationFilledGradientRectangle.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class AnimationFilledGradientRectangle : AnimationFilledRectangle
99
[Newtonsoft.Json.JsonProperty]
1010
internal EffectBrush _gradientBrush;
1111

12+
private readonly Brush _drawingBrush;
13+
1214
public EffectBrush GradientBrush => _gradientBrush;
1315

1416
public AnimationFilledGradientRectangle()
@@ -18,21 +20,25 @@ public AnimationFilledGradientRectangle()
1820
public AnimationFilledGradientRectangle(AnimationFilledGradientRectangle animationFilledGradientRectangle) : base(animationFilledGradientRectangle)
1921
{
2022
_gradientBrush = animationFilledGradientRectangle.GradientBrush;
23+
_drawingBrush = _gradientBrush.GetDrawingBrush();
2124
}
2225

2326
public AnimationFilledGradientRectangle(AnimationFrame animationFrame, EffectBrush effectBrush) : base(animationFrame)
2427
{
2528
_gradientBrush = effectBrush;
29+
_drawingBrush = _gradientBrush.GetDrawingBrush();
2630
}
2731

2832
public AnimationFilledGradientRectangle(RectangleF dimension, EffectBrush brush, float duration = 0.0f) : base(dimension, Color.Transparent, duration)
2933
{
3034
_gradientBrush = brush;
35+
_drawingBrush = _gradientBrush.GetDrawingBrush();
3136
}
3237

3338
public AnimationFilledGradientRectangle(float x, float y, float rect_width, float rect_height, EffectBrush brush, float duration = 0.0f) : base(x, y, rect_width, rect_height, Color.Transparent, duration)
3439
{
3540
_gradientBrush = brush;
41+
_drawingBrush = _gradientBrush.GetDrawingBrush();
3642
}
3743

3844
public override void Draw(Graphics g)
@@ -45,8 +51,9 @@ public override void Draw(Graphics g)
4551

4652
g.ResetTransform();
4753
g.Transform = _transformationMatrix;
48-
//g.FillRectangle(_gradientBrush.GetDrawingBrush(), _scaledDimension);
49-
g.FillRectangle(_gradientBrush.GetDrawingBrush(), _dimension);
54+
float drawX = _dimension.X - _dimension.Width/2;
55+
float drawY = _dimension.Y - _dimension.Height/2;
56+
g.FillRectangle(_drawingBrush, drawX, drawY, _dimension.Width, _dimension.Height);
5057
}
5158

5259
public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)

Project-Aurora/Project-Aurora/EffectsEngine/Animations/AnimationFilledRectangle.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public override void Draw(Graphics g)
2626
{
2727
if (_invalidated)
2828
{
29-
_pen = new Pen(_color);
30-
_pen.Width = _width;
31-
_pen.Alignment = PenAlignment.Center;
29+
_brush = new SolidBrush(_color);
3230

3331
virtUpdate();
3432
_invalidated = false;
3533
}
3634

3735
g.ResetTransform();
3836
g.Transform = _transformationMatrix;
39-
g.FillRectangle(_brush, _dimension);
37+
float drawX = _dimension.X - _dimension.Width/2;
38+
float drawY = _dimension.Y - _dimension.Height/2;
39+
g.FillRectangle(_brush, drawX, drawY, _dimension.Width, _dimension.Height);
4040
}
4141

4242
public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)

0 commit comments

Comments
 (0)