Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: remove dead code
  • Loading branch information
JeremyMeissner committed May 5, 2022
commit 3a67d41f8311620507875bbb3f8fbbf12f664407
4 changes: 0 additions & 4 deletions FreeFrame/Components/Shapes/SVGCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public override void Draw(Vector2i clientSize)
public override float[] GetVertices() => new float[] { X, Y, X + Width, Y, X + Width, Y + Height, X, Y + Height }; // x, y, x, y, x, y, ... (clockwise)
public override uint[] GetVerticesIndexes() => new uint[] { 0, 1, 2, 0, 2, 3 }; // TODO: please dont hardcode

public override Hitbox Hitbox()
{
throw new NotImplementedException();
}

public override List<Vector2i> GetSelectablePoints()
{
Expand Down
8 changes: 0 additions & 8 deletions FreeFrame/Components/Shapes/SVGLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ public override void Draw(Vector2i clientSize)
}
public override string ToString() => $"x1: {X}, y1: {Y}, x2: {Width + X}, y2: {Height + Y}";

public override Hitbox Hitbox()
{
Hitbox hitbox = new Hitbox();

//hitbox.Areas.Add(new Hitbox.Area(X, Y, X2, Y2));

return hitbox;
}

public override List<Vector2i> GetSelectablePoints()
{
Expand Down
221 changes: 3 additions & 218 deletions FreeFrame/Components/Shapes/SVGPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,6 @@ namespace FreeFrame.Components.Shapes
{
public class SVGPath : Shape
{
private int _x, _y, _width, _height;
public override int X
{
get => _x; // GetSelectablePoints().Min(i => i.X);
set
{
_x = value;
//Move(new Vector2i(_x, Y));
}
}
public override int Y
{
get => _y; // GetSelectablePoints().Min(i => i.Y);
set
{
_y = value;
//Move(new Vector2i(X, _y));
}
}
public override int Width
{
get
{
return _width;
}
set
{
_width = value;
}
}
public override int Height
{
get
{
return _height;
}
set
{
_height = value;
}
}

readonly Dictionary<char, Regex> _dAttributesRegex = new()
{
Expand Down Expand Up @@ -80,8 +39,6 @@ public override int Height

List<DrawAttribute> _drawAttributes = new();

List<uint> _indexes = new();

public List<DrawAttribute> DrawAttributes { get => _drawAttributes; set => _drawAttributes = value; }

public SVGPath(XmlReader reader) //: this()
Expand Down Expand Up @@ -159,163 +116,15 @@ public SVGPath(XmlReader reader) //: this()
public override void ImplementObject()
{
Move(new Vector2i(X, Y));

//foreach (VertexArrayObject vao in _vaos)
// vao.DeleteObjects();
//_vaos.Clear();

////DrawAttribute previousAttribute = new MoveTo(0, 0);
//foreach (DrawAttribute attr in DrawAttributes)
//{
// if (attr.GetType() == typeof(CurveTo) ||
// attr.GetType() == typeof(SmoothCurveTo) ||
// attr.GetType() == typeof(QuadraticBezierCurveTo) ||
// attr.GetType() == typeof(SmoothQuadraticBezierCurveTo) ||
// attr.GetType() == typeof(EllipticalArc))
// {
// _vaos.Add(new VertexArrayObject(attr.GetVertices(), attr.GetVerticesIndexes(), PrimitiveType.LineStrip));
// }
// else
// {
// _vaos.Add(new VertexArrayObject(attr.GetVertices(), attr.GetVerticesIndexes(), PrimitiveType.Lines));
// }
// //previousAttribute = attr;
//}
}

public override void Draw(Vector2i clientSize)
{
foreach (VertexArrayObject vao in _vaos)
vao.Draw(clientSize, Color, this);
}
public override float[] GetVertices()
{
return new float[] { };
}
//public override float[] GetVertices()
//{
// // Delaunator polygon = new Delaunator(new IPoint[] { new Point(0.0, 0.0) });

// // Edges
// List<float> vertices = new List<float>();
// DrawAttribute? previous = null;
// DrawAttribute.LastX = 0;
// DrawAttribute.LastY = 0;
// DrawAttribute.LastControlPointX = 0;
// DrawAttribute.LastControlPointY = 0;

// foreach (DrawAttribute current in DrawAttributes)
// {
// if (current.GetType() == typeof(LineTo) ||
// current.GetType() == typeof(HorizontalLineTo) ||
// current.GetType() == typeof(VerticalLineTo) ||
// current.GetType() == typeof(CurveTo) ||
// current.GetType() == typeof(SmoothCurveTo) ||
// current.GetType() == typeof(QuadraticBezierCurveTo) ||
// current.GetType() == typeof(SmoothQuadraticBezierCurveTo)) // TODO: Add EllipticalArc support
// {
// int previousLength = vertices.Count;

// int i = 0;
// int count = 0;
// foreach (float item in current.GetVertices(null))
// {
// vertices.Add(item);
// i++;
// }
// if (_indexes.Count > 0)
// count = (int)_indexes.Last();
// _indexes.AddRange(Enumerable.Range(count, i / 2).Select(i => (uint)i).ToArray());

// //i++;
// }

// if (current.GetType() == typeof(MoveTo))
// {
// if (previous != null)
// {
// if (previous.GetType() != typeof(MoveTo))
// {
// _indexes.Add(_indexes.Last());
// }
// }
// if (((MoveTo)current).IsRelative)
// {
// DrawAttribute.LastX += ((MoveTo)current).X; // Update last x and y (for relatives attributes points)
// DrawAttribute.LastY += ((MoveTo)current).Y;
// }
// else
// {
// DrawAttribute.LastX = ((MoveTo)current).X; // Update last x and y (for relatives attributes points)
// DrawAttribute.LastY = ((MoveTo)current).Y;
// }
// }
// else
// {
// DrawAttribute.LastX = (int)vertices[^2]; // Update last x and y (for relatives attributes points)
// DrawAttribute.LastY = (int)vertices[^1];
// }

// if (current.GetType() == typeof(CurveTo)) // Cubic Bézier Curves
// {
// if (((CurveTo)current).X > ((CurveTo)current).X2) // Control end point on the left
// DrawAttribute.LastControlPointX = ((CurveTo)current).X + ((CurveTo)current).X2;
// else if (((CurveTo)current).X < ((CurveTo)current).X2) // Control end point on the right
// DrawAttribute.LastControlPointX = ((CurveTo)current).X - ((CurveTo)current).X2;
// else // On the middle
// DrawAttribute.LastControlPointX = ((CurveTo)current).X;

// if (((CurveTo)current).Y > ((CurveTo)current).Y2) // Control end point on the top
// DrawAttribute.LastControlPointY = ((CurveTo)current).Y + ((CurveTo)current).Y2;
// else if (((CurveTo)current).Y < ((CurveTo)current).Y2) // Control end point on the bottom
// DrawAttribute.LastControlPointY = ((CurveTo)current).Y - ((CurveTo)current).Y2;
// else // On the middle
// DrawAttribute.LastControlPointY = ((CurveTo)current).Y;
// }
// else if (current.GetType() == typeof(QuadraticBezierCurveTo)) // Quadratic Bézier Curves
// {
// DrawAttribute.LastControlPointX = ((QuadraticBezierCurveTo)current).X1;
// DrawAttribute.LastControlPointY = ((QuadraticBezierCurveTo)current).Y1;
// }
// else if (current.GetType() != typeof(SmoothCurveTo) && current.GetType() != typeof(SmoothQuadraticBezierCurveTo)) // Only reset if we're done with bézier curves
// {
// (DrawAttribute.LastControlPointX, DrawAttribute.LastControlPointY) = (0, 0);
// }

// previous = current;
// }

// return vertices.ToArray();
//}

public override uint[] GetVerticesIndexes()
{
/*
List<uint> indexes = new List<uint>();

foreach (DrawAttribute attr in DrawAttributes)
{
if (attr.GetType() == typeof(LineTo))
{
foreach (uint attrIndexes in ((LineTo)attr).GetVerticesIndexes())
{
indexes.Add(attrIndexes);
}
}
}
return indexes.ToArray();
*/

//uint[] indexes = Enumerable.Range(0, GetVertices().Length / 2).Select(i => (uint)i).ToArray();

//return indexes;

//_indexes = new List<uint>();
//GetVertices();
//return _indexes.ToArray();

return new uint[] { };
}
public override float[] GetVertices() => new float[] { };
public override uint[] GetVerticesIndexes() => new uint[] { };

public override List<Vector2i> GetSelectablePoints()
{
Expand Down Expand Up @@ -346,17 +155,6 @@ public override List<Vector2i> GetSelectablePoints()
return points;
}

public override Hitbox Hitbox()
{
Hitbox hitbox = new Hitbox();

hitbox.Areas.Add(new Hitbox.Area(0, 0, 0, 0)); // TODO: please dont hardcode

return hitbox;
}



public override void Move(Vector2i position)
{
foreach (VertexArrayObject vao in _vaos)
Expand Down Expand Up @@ -413,20 +211,7 @@ public override void Move(Vector2i position)
// ImplementObject();
}

public override void Resize(Vector2i size)
{
//List<Vector2i> points = GetSelectablePoints();
//Properties = new DefaultProperties()
//{
// x = points.Min(i => i.X),
// y = points.Min(i => i.Y),
// width = points.Max(i => i.X) - points.Min(i => i.X),
// height = points.Max(i => i.Y) - points.Min(i => i.Y),
// color = Properties.color
//};

//ImplementObject();
}
public override void Resize(Vector2i size) => throw new NotImplementedException("Can't resize a path");

public override string ToString()
{
Expand Down
5 changes: 0 additions & 5 deletions FreeFrame/Components/Shapes/SVGPolygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public override uint[] GetVerticesIndexes()
throw new NotImplementedException();
}

public override Hitbox Hitbox()
{
throw new NotImplementedException();
}

public override void ImplementObject()
{
throw new NotImplementedException();
Expand Down
12 changes: 0 additions & 12 deletions FreeFrame/Components/Shapes/SVGRectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,5 @@ public override void Resize(Vector2i size)
Height = size.Y;
ImplementObject();
}

public override Hitbox Hitbox()
{
Hitbox hitbox = new Hitbox();

hitbox.Areas.Add(new Hitbox.Area(X, Y, Width, Height));


return hitbox;
}


}
}
1 change: 0 additions & 1 deletion FreeFrame/Components/Shapes/Shape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public Shape Clone()
public abstract void ImplementObject();
public abstract void Move(Vector2i position);
public abstract void Resize(Vector2i size);
public abstract Hitbox Hitbox();
public abstract override string ToString();
}

Expand Down
14 changes: 1 addition & 13 deletions FreeFrame/Shaders/circle.frag
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ uniform vec4 u_Color;
uniform vec2 u_Position;
uniform float u_Radius;

vec3 rgb(float r, float g, float b) {
return vec3(r / 255.0, g / 255.0, b / 255.0);
}

/**
* Draw a circle at vec2 `pos` with radius `rad` and
* color `color`.
*/
// Draw a circle at position with radius and color
vec4 circle(vec2 uv, vec2 pos, float rad, vec4 color) {
float d = length(pos - uv) - rad;
float t = clamp(d, 0.0, 1.0);
Expand All @@ -24,16 +17,11 @@ vec4 circle(vec2 uv, vec2 pos, float rad, vec4 color) {
void main() {

vec2 uv = gl_FragCoord.xy;
// vec2 center = u_Resolution.xy * 0.5;
// float radius = 0.25 * u_Resolution.y;

// Background layer

vec2 position = vec2(u_Position.x, u_Resolution.y - u_Position.y); // Invert y axis

// Circle
vec4 layer2 = circle(uv, position, u_Radius, u_Color);

// Blend the two
color = layer2;
}
Loading