Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
302 changes: 180 additions & 122 deletions FreeFrame/Components/Shapes/Path/DrawAttribute.cs

Large diffs are not rendered by default.

49 changes: 28 additions & 21 deletions FreeFrame/Components/Shapes/SVGCircle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenTK.Mathematics;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Mathematics;
using System;
using System.Collections.Generic;
using System.Drawing;
Expand All @@ -9,11 +10,6 @@ namespace FreeFrame.Components.Shapes
{
public class SVGCircle : Shape
{
#region Geometry properties
private int _cx;
private int _cy;
private int _r;
#endregion
public SVGCircle(XmlReader reader) : this(
Convert.ToInt32(reader["r"]),
Convert.ToInt32(reader["cx"]),
Expand All @@ -22,41 +18,52 @@ public SVGCircle(XmlReader reader) : this(
public SVGCircle() : this(0, 0, 0) { }
public SVGCircle(int r, int cx, int cy)
{
_cx = cx;
_cy = cy;
_r = r;
}
public override void Draw(Vector2i clientSize) => throw new NotImplementedException();
IsCornerRadiusChangeable = false;
X = cx - r;
Y = cy - r;
Height = r*2;
Width = Height;

public override string ToString() => $"cx: {_cx}, cy: {_cy}, r: {_r}";
ImplementObject();
}

public override float[] GetVertices() => new float[] { _cx - _r, _cy - _r, _cx + _r, _cy - _r, _cx + _r, _cy + _r, _cx - _r, _cy + _r }; // x, y, x, y, x, y, ... (clockwise)
public override string ToString() => $"cx: {X + Width / 2}, cy: {Y + Height / 2}, r: {Width / 2}";

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()
{
throw new NotImplementedException();
List<Vector2i> points = new();
points.Add(new Vector2i(X, Y));
points.Add(new Vector2i(X + Width, Y));
points.Add(new Vector2i(X + Width, Y + Height));
points.Add(new Vector2i(X, Y + Height));
return points;
}

public override void ImplementObject()
{
throw new NotImplementedException();
foreach (VertexArrayObject vao in _vaos)
vao.DeleteObjects();
_vaos.Clear();

_vaos.Add(new VertexArrayObject(GetVertices(), GetVerticesIndexes(), PrimitiveType.Triangles, this));
}

public override void Move(Vector2i position)
{
throw new NotImplementedException();
X = position.X;
Y = position.Y;
ImplementObject();
}

public override void Resize(Vector2i size)
{
throw new NotImplementedException();
Width = size.X;
Height = size.Y;
ImplementObject();
}
}
}
27 changes: 3 additions & 24 deletions FreeFrame/Components/Shapes/SVGLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ internal class SVGLine : Shape
const int DefaultY2 = 0;
#endregion

#region Geometry properties
#endregion

public SVGLine(XmlReader reader) : this(
Convert.ToInt32(reader["x1"]),
Convert.ToInt32(reader["y1"]),
Expand All @@ -31,6 +28,8 @@ public SVGLine(XmlReader reader) : this(
public SVGLine() : this(DefaultX1, DefaultY1, DefaultX2, DefaultY2) { }
public SVGLine(int x1, int y1, int x2, int y2)
{
IsCornerRadiusChangeable = false;

X = x1;
Y = y1;
Width = x2 - X;
Expand All @@ -40,49 +39,29 @@ public SVGLine(int x1, int y1, int x2, int y2)
}
public override float[] GetVertices() => new float[] { X, Y, Width + X, Height + Y }; // x, y, x, y, x, y, ... (clockwise)
public override uint[] GetVerticesIndexes() => new uint[] { 0, 1 }; // TODO: please dont hardcode

public override void Draw(Vector2i clientSize)
{
foreach (VertexArrayObject vao in _vaos)
vao.Draw(clientSize, Color); // Because that color doesnt depend of the shape TODO: Make it dependend
}
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()
{
List<Vector2i> points = new();
points.Add(new Vector2i(X, Y));
points.Add(new Vector2i(Width + X, Height + Y));
return points;
}


public override void ImplementObject()
{
foreach (VertexArrayObject vao in _vaos)
vao.DeleteObjects();
_vaos.Clear();

_vaos.Add(new VertexArrayObject(GetVertices(), GetVerticesIndexes(), PrimitiveType.Lines));
_vaos.Add(new VertexArrayObject(GetVertices(), GetVerticesIndexes(), PrimitiveType.Lines, this ));
}

public override void Move(Vector2i position)
{
X = position.X;
Y = position.Y;

ImplementObject();
}

public override void Resize(Vector2i size)
{
Width = size.X;
Expand Down
Loading