This commit is contained in:
oleting
2020-12-21 11:51:02 +01:00
3 changed files with 4 additions and 4 deletions

View File

@@ -131,5 +131,5 @@ if __name__ == "__main__":
if_instruction("shouldNiet()", [ generic_instruction("hiet()") ], [generic_instruction("hiet()")]), if_instruction("shouldNiet()", [ generic_instruction("hiet()") ], [generic_instruction("hiet()")]),
]) ])
NSD_init(500, 500) NSD_init(500, 500)
test.to_image(0, 0, 250, 500) test.to_image(0, 0, 500, 500)
NSD_save("Iinstruction") NSD_save("Iinstruction")

View File

@@ -17,15 +17,15 @@ def NSD_init(x: float, y: float):
img = Image.new("RGB", (x, y), "white") img = Image.new("RGB", (x, y), "white")
output_img = ImageDraw.Draw(img) output_img = ImageDraw.Draw(img)
#font = ImageFont.load_default() #font = ImageFont.load_default()
font = ImageFont.truetype("res/fonts/NotoSans-Regular.ttf", 12) font = ImageFont.truetype("res/fonts/SpaceGrotesk-Light.ttf", 12)
def draw_generic_instruction(instruction: str, x, y, xsize, ysize) -> Iterable[float]: def draw_generic_instruction(instruction: str, x, y, xsize, ysize) -> Iterable[float]:
if not output_img: if not output_img:
raise Exception("Output image was not initialized! Make sure to call NSD_init first") raise Exception("Output image was not initialized! Make sure to call NSD_init first")
#size shit #size shit
text_y_size = font.getsize(instruction, direction="ltr")[1] #text_y_size = font.getsize(instruction, direction="ltr")[1]
ysize = max(text_y_size, ysize) # ensure it is alway at least big enought to fit the text #ysize = max(text_y_size, ysize) # ensure it is alway at least big enought to fit the text
#draw shit #draw shit
output_img.rectangle((x,y) + (x + xsize, y + ysize), outline=(0), width=1) output_img.rectangle((x,y) + (x + xsize, y + ysize), outline=(0), width=1)

Binary file not shown.