1. leaf corcoran
  2. lovekit

Commits

leaf corcoran  committed 83bc909

vector direction_name

  • Participants
  • Parent commits 8f9dc5c
  • Branches master

Comments (0)

Files changed (1)

File lovekit/geometry.moon

View file
       self[1] = self[1] / l * max_len
       self[2] = self[2] / l * max_len
 
+  direction_name:(names={"up", "right", "down", "left"}) =>
+    if math.abs(self[1]) > math.abs(self[2])
+      if self[1] < 0
+        names[4]
+      else
+        names[2]
+    else
+      if self[2] < 0
+        names[1]
+      else
+        names[3]
+
   __mul: (left, right) ->
     if type(left) == "number"
       if type(right) == "number"