chiark / gitweb /
visdebug: introduce vdbg().circle() (nfc)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Dec 2017 12:55:49 +0000 (12:55 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Dec 2017 12:55:49 +0000 (12:55 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
moedebug.py
visual

index 634ff4562701c0a1ffe23b9b6f75536f2a94007c..f5e039eb758699b73229ae6cb15f97624519cee6 100644 (file)
@@ -31,6 +31,7 @@ class BaseVisdebug():
 class NullVisdebug():
   def curve(*a, **kw): pass
   def line(*a, **kw): pass
+  def circle(*a, **kw): pass
   def arrow(*a, **kw): pass
   def basis(*a, **kw): pass
   def crashing(*a, **kw): pass
@@ -41,6 +42,10 @@ class MatrixVisdebug(BaseVisdebug):
     m._matrix = matrix
   def curve(m, fn, **kw):
     m._b.curve(lambda t: moenp.augmatmultiply(m._matrix, fn(t)), **kw)
+  def circle(m, c, axis, **kw):
+    m._b.circle(moenp.augmatmultiply(m._matrix, c),
+                moenp.augmatmultiply(m._matrix, axis, 0),
+                **kw)
   def arrow(m, p, d, **kw):
     m._b.arrow(moenp.augmatmultiply(m._matrix, p),
                moenp.augmatmultiply(m._matrix, d, 0),
diff --git a/visual b/visual
index 27c22eb234d7392fa972045b74d86b5902224616..490a4b96252f4fecf90a7e220f3b11991527fd49 100755 (executable)
--- a/visual
+++ b/visual
@@ -26,13 +26,15 @@ class Visdebug(BaseVisdebug):
     ps = [ fn(t) for t in np.linspace(0,1,11) ]
     #dbg('Visdebug', ps)
     curve(pos = ps, color=color)
+  def circle(vd, c, axis, **kw):
+    ring(pos=c, axis=axis, radius=0.25, thickness=0.005, **kw)
   def arrow(vd, p, d, **kw):
     print('arrow %s' % repr(kw), file=sys.stderr)
     bodge_color = kw.get('color', (1,0,0))
     try: del kw['color']
     except KeyError: pass
     vd.line(p, p+d, color=bodge_color, **kw)
-    ring(pos=p, axis=d, radius=0.25, thickness=0.005, color=bodge_color, **kw)
+    vd.circle(p, d, color=bodge_color, **kw)
   def crashing(vd, msg):
     print("CRASHING - VISDEBUG", msg, file=sys.stderr)
     rate(1E-8)