(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
'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)