1- using OpenTK . Mathematics ;
1+ using OpenTK . Graphics . OpenGL4 ;
2+ using OpenTK . Mathematics ;
23using System ;
34using System . Collections . Generic ;
45using System . Drawing ;
@@ -9,11 +10,6 @@ namespace FreeFrame.Components.Shapes
910{
1011 public class SVGCircle : Shape
1112 {
12- #region Geometry properties
13- private int _cx ;
14- private int _cy ;
15- private int _r ;
16- #endregion
1713 public SVGCircle ( XmlReader reader ) : this (
1814 Convert . ToInt32 ( reader [ "r" ] ) ,
1915 Convert . ToInt32 ( reader [ "cx" ] ) ,
@@ -22,41 +18,52 @@ public SVGCircle(XmlReader reader) : this(
2218 public SVGCircle ( ) : this ( 0 , 0 , 0 ) { }
2319 public SVGCircle ( int r , int cx , int cy )
2420 {
25- _cx = cx ;
26- _cy = cy ;
27- _r = r ;
28- }
29- public override void Draw ( Vector2i clientSize ) => throw new NotImplementedException ( ) ;
21+ IsCornerRadiusChangeable = false ;
22+ X = cx - r ;
23+ Y = cy - r ;
24+ Height = r * 2 ;
25+ Width = Height ;
3026
31- public override string ToString ( ) => $ "cx: { _cx } , cy: { _cy } , r: { _r } ";
27+ ImplementObject ( ) ;
28+ }
3229
33- 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)
30+ public override string ToString ( ) => $ "cx: { X + Width / 2 } , cy: { Y + Height / 2 } , r: { Width / 2 } " ;
3431
32+ 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)
3533 public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 , 2 , 0 , 2 , 3 } ; // TODO: please dont hardcode
3634
37- public override Hitbox Hitbox ( )
38- {
39- throw new NotImplementedException ( ) ;
40- }
4135
4236 public override List < Vector2i > GetSelectablePoints ( )
4337 {
44- throw new NotImplementedException ( ) ;
38+ List < Vector2i > points = new ( ) ;
39+ points . Add ( new Vector2i ( X , Y ) ) ;
40+ points . Add ( new Vector2i ( X + Width , Y ) ) ;
41+ points . Add ( new Vector2i ( X + Width , Y + Height ) ) ;
42+ points . Add ( new Vector2i ( X , Y + Height ) ) ;
43+ return points ;
4544 }
4645
4746 public override void ImplementObject ( )
4847 {
49- throw new NotImplementedException ( ) ;
48+ foreach ( VertexArrayObject vao in _vaos )
49+ vao . DeleteObjects ( ) ;
50+ _vaos . Clear ( ) ;
51+
52+ _vaos . Add ( new VertexArrayObject ( GetVertices ( ) , GetVerticesIndexes ( ) , PrimitiveType . Triangles , this ) ) ;
5053 }
5154
5255 public override void Move ( Vector2i position )
5356 {
54- throw new NotImplementedException ( ) ;
57+ X = position . X ;
58+ Y = position . Y ;
59+ ImplementObject ( ) ;
5560 }
5661
5762 public override void Resize ( Vector2i size )
5863 {
59- throw new NotImplementedException ( ) ;
64+ Width = size . X ;
65+ Height = size . Y ;
66+ ImplementObject ( ) ;
6067 }
6168 }
6269}
0 commit comments