improved interpreter and added support for doWhile
This commit is contained in:
@@ -130,13 +130,9 @@ class while_instruction_back(while_instruction_front):
|
||||
while_instruction_front.__init__(self, condition, instructions)
|
||||
|
||||
def to_image(self, x:int, y:int, x_sz: int):
|
||||
children_x, children_y, children_sz_x, children_sz_y = cti.draw_while_loop_back(self.instruction_text, x, y, x_sz, y_sz)
|
||||
blk_size = self.draw_children(children_x, children_y, children_sz_x)
|
||||
return x
|
||||
|
||||
def draw_children(self, x:float, y:float, x_sz:float):
|
||||
for instruction in self.child_instructions:
|
||||
x, y = instruction.to_image(x, y, x_sz)
|
||||
children_x, children_y, children_sz_x = cti.draw_while_loop_back(self.instruction_text, x, y, x_sz, self.getblksize())
|
||||
self.draw_children(children_x, children_y, children_sz_x)
|
||||
return x, y + self.getblksize()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -90,21 +90,21 @@ def draw_while_loop_back(condition: str, x: int, y: int, xsize: int, ysize: int)
|
||||
if not output_img:
|
||||
raise Exception("Output image was not initialized! Make sure to call NSD_init first")
|
||||
|
||||
#ole #TODO
|
||||
text_y_sz = get_text_size(condition)[1]
|
||||
|
||||
#the box
|
||||
output_img.line((x,y) + (x + xsize * .1, y), fill=0)
|
||||
output_img.line((x + xsize * .1, y) + (x + xsize * .1, y + ysize * .9), fill=0)
|
||||
output_img.line((x + xsize * .1, y + ysize * .9) + (x + xsize, y + ysize * .9), fill=0)
|
||||
output_img.line((x + xsize, y + ysize * .9) + (x + xsize, y + ysize), fill=0)
|
||||
output_img.line((x + xsize * .1, y) + (x + xsize * .1, y + ysize - text_y_sz), fill=0)
|
||||
output_img.line((x + xsize * .1, y + ysize - text_y_sz) + (x + xsize, y + ysize - text_y_sz), fill=0)
|
||||
output_img.line((x + xsize, y + ysize - text_y_sz) + (x + xsize, y + ysize), fill=0)
|
||||
output_img.line((x,y + ysize) + (x + xsize, y + ysize), fill=0)
|
||||
output_img.line((x,y) + (x, y + ysize), fill=0)
|
||||
|
||||
#the text
|
||||
output_img.text((x + xsize * .1, y + ysize * .95), condition, font = font, fill = (0), anchor="lm")
|
||||
output_img.text((x + xsize * .1, y + ysize - text_y_sz * .5), condition, font = font, fill = (0), anchor="lm")
|
||||
|
||||
#the x, y offset then the x,y draw size (the canvas)
|
||||
return x + xsize * .1, y, xsize * .9, ysize * .9
|
||||
return x + xsize * .1, y, xsize * .9
|
||||
|
||||
def NSD_save(filename: str):
|
||||
"""Save the created file"""
|
||||
|
||||
Reference in New Issue
Block a user