Browse Source

small update

Ethosa 3 năm trước cách đây
mục cha
commit
4f348d700a

+ 4 - 0
src/nodesnim/core/anchor.nim

@@ -14,6 +14,10 @@ proc Anchor*(x1, y1, x2, y2: float): AnchorObj {.inline.} =
 proc Anchor*(vec1, vec2: Vector2Obj): AnchorObj {.inline.} =
   AnchorObj(x1: vec1.x, y1: vec1.y, x2: vec2.x, y2: vec2.y)
 
+proc Anchor*(): AnchorObj {.inline.} =
+  ## Creates empty Anchor object.
+  AnchorObj(x1: 0, y1: 0, x2: 0, y2: 0)
+
 proc clear*(a: var AnchorObj) =
   a.x1 = 0
   a.x2 = 0

+ 9 - 10
src/nodesnim/core/circle.nim

@@ -9,10 +9,9 @@ import
 type
   CircleObj* = object
     x*, y*, r*: float
-  CircleRef* = ref CircleObj
 
 
-proc Circle*(x, y, r: float): CircleRef =
+proc Circle*(x, y, r: float): CircleObj =
   ## Creates a new Circle object.
   ##
   ## Arguments:
@@ -21,30 +20,30 @@ proc Circle*(x, y, r: float): CircleRef =
   ## - `r` is a circle radius.
   runnableExamples:
     var obj = Circle(10, 10, 5)
-  CircleRef(x: x, y: y, r: r)
+  CircleObj(x: x, y: y, r: r)
 
-proc Circle*(vec: Vector2Obj, r: float): CircleRef =
+proc Circle*(vec: Vector2Obj, r: float): CircleObj =
   ## Creates a new Circle object.
   ##
   ## Arguments:
   ## - `vec` is a circle center position.
   ## - `r` is a circle radius.
-  CircleRef(x: vec.x, y: vec.y, r: r)
+  CircleObj(x: vec.x, y: vec.y, r: r)
 
 
-proc contains*(self: CircleRef, x, y: float): bool =
+proc contains*(self: CircleObj, x, y: float): bool =
   ## Returns true, if `x`,`y` in the circle.
   let
     dx = x - self.x
     dy = y - self.y
   dx*dx + dy*dy <= self.r*self.r
 
-proc contains*(self: CircleRef, vec2: Vector2Obj): bool {.inline.} =
+proc contains*(self: CircleObj, vec2: Vector2Obj): bool {.inline.} =
   ## Returns true, if `vec2` in the circle.
   self.contains(vec2.x, vec2.y)
 
 
-proc contains*(self, other: CircleRef): bool =
+proc contains*(self, other: CircleObj): bool =
   ## Returns true, if `self` intersects with `other` circle.
   let
     dx = other.x - self.x
@@ -52,7 +51,7 @@ proc contains*(self, other: CircleRef): bool =
     r = other.r + self.r
   dx*dx + dy*dy <= r*r
 
-proc contains*(self: CircleRef, a, b: Vector2Obj): bool =
+proc contains*(self: CircleObj, a, b: Vector2Obj): bool =
   let
     dx = b.x - a.x
     dy = b.y - a.y
@@ -82,5 +81,5 @@ proc contains*(self: CircleRef, a, b: Vector2Obj): bool =
 
 
 # --- Operators --- #
-proc `$`*(self: CircleRef): string {.inline.} =
+proc `$`*(self: CircleObj): string {.inline.} =
   "Circle(x:" & $self.x & ", y:" & $self.y & ", r:" & $self.r & ")"

+ 1 - 1
src/nodesnim/core/polygon2.nim

@@ -92,7 +92,7 @@ proc intersects*(self: Polygon2Ref, r: Rect2Obj): bool =
     if r.contains(a, b):
       return true
 
-proc intersects*(self: Polygon2Ref, circle: CircleRef): bool =
+proc intersects*(self: Polygon2Ref, circle: CircleObj): bool =
   ## Returns true, if circle intersect with polygon.
   var next = 1
   let length = self.positions.len()

+ 1 - 0
src/nodesnim/graphics/drawable.nim

@@ -241,6 +241,7 @@ method setShadowOffset*(self: DrawableRef, offset: Vector2Obj) {.base.} =
   ## Changes shadow offset.
   self.shadow_offset = offset
 
+
 method setStyle*(self: DrawableRef, s: StyleSheetRef) {.base.} =
   ## Sets a new stylesheet.
   for i in s.dict: