]> git.cworth.org Git - zombocom-ai/commitdiff
Drop unneeded semicolons from python code
authorCarl Worth <cworth@cworth.org>
Fri, 23 Dec 2022 15:52:18 +0000 (07:52 -0800)
committerCarl Worth <cworth@cworth.org>
Fri, 23 Dec 2022 19:51:10 +0000 (11:51 -0800)
Apparently, the javascript has been getting into my head the past few days.

Also, make the default drawing only hit the upper-left quadrant.

bus.html
interpret-cairo-to-svg.py

index df6f572ed27ca18708d1aea16b2a3d89819601b9..f16a509ae18bfea5b72955cf5a0f9d30be55c1d6 100644 (file)
--- a/bus.html
+++ b/bus.html
       </h1>
       <form id="form">
        <textarea id="code" rows="10" width="100%">def random_dot():
-  x = 512 * random()
-  y = 512 * random()
+  x = 200 * random()
+  y = 200 * random()
   radius = 4 + 6 * random()
-  circle(x, y, radius);
-  fill();
+  circle(x, y, radius)
+  fill()
 
-for i in range(1000):
+for i in range(100):
   if i %2 == 0:
     set_color('red')
   else:
     set_color('blue')
-  random_dot();</textarea>
+  random_dot()</textarea>
        <button type="submit">Run code</button>
       </form>
       <img id="output"></img>
index de296f5288d02a3d538a63fd06235ff772fc6538..bc0c6b1053ab8eaf406ea95f5c55d7f33a534bf3 100755 (executable)
@@ -24,7 +24,7 @@ if "import" in input:
 
 (fd, filename) = tempfile.mkstemp(suffix=".svg", prefix="busart", dir=OUTPUT_DIR);
 os.close(fd)
-os.chmod(filename, 0o644);
+os.chmod(filename, 0o644)
 
 # Also delete our import for some more safety
 del tempfile
@@ -789,33 +789,33 @@ COLORS = {
     'yellow3': (0xcd/0xff, 0xcd/0xff, 0x00/0xff),
     'yellow4': (0x8b/0xff, 0x8b/0xff, 0x00/0xff),
     'yellowgreen': (0x9a/0xff, 0xcd/0xff, 0x32/0xff)
-};
+}
 
 with cairo.SVGSurface(filename, 512, 512) as surface:
     cr = cairo.Context(surface);
     del cairo
 
     def arc(x, y, r, a1, a2):
-        cr.arc(x, y, r, a1, a2);
+        cr.arc(x, y, r, a1, a2)
 
     def circle(x, y, r):
-        cr.arc(x, y, r, 0, 2 * math.pi);
+        cr.arc(x, y, r, 0, 2 * math.pi)
 
     def fill():
-        cr.fill();
+        cr.fill()
 
     def set_color(color):
         if color in COLORS:
-            (r,g,b) = COLORS[color];
+            (r,g,b) = COLORS[color]
         else:
             (r,g,b) = (0,0,0)
         cr.set_source_rgb(r, g, b)
 
-    cr.set_line_width(6);
-    exec(input)
-
-web_file = filename.removeprefix(OUTPUT_DIR_PREFIX);
+    cr.set_line_width(6)
 
-print(web_file);
+    # Run the submitted code
+    exec(input)
 
+web_file = filename.removeprefix(OUTPUT_DIR_PREFIX)
 
+print(web_file)