reworked image generation

This commit is contained in:
weckyy702
2021-04-26 11:50:42 +02:00
parent 968bb53883
commit 4a8f3649c8
5 changed files with 69 additions and 18 deletions

View File

@@ -43,7 +43,8 @@ class NassiShneidermanDiagram:
height = scope.get_height()
with NSD_writer(output_path, width, height):
y = 0
for instruction in scope:
for instruction in scope:
print(instruction.instruction_text)
y = instruction.convert_to_image(0, y, width)
@staticmethod

View File

@@ -6,7 +6,7 @@ from enum import IntEnum
from typing import Union
NUMERIC_CONSTANT_PATTERN = re.compile(r"""([0-9]+)|(true)|(false)""")
KEYWORD_PATTERN = re.compile(r"""(return)|(continue)|(break)|(new)""")
KEYWORD_PATTERN = re.compile(r"""(return)$|(continue)$|(break)$|(new)$""")
STRING_LITERAL_PATTERN = re.compile(r"""('|\")(.*)(\"|')""")
MATH_OP_PATTERN = re.compile(r"""\+|-|\*|/|<|>""")

View File

@@ -15,10 +15,10 @@ class Function_scope(Iterable):
self.args = args
def get_height(self) -> int:
h = 0.0
h = 0
for inst in self.contents:
h += inst.get_block_height()
return int(h)
return max(h, 5) #a NSD has to be at least 5 pixels tall
def get_width(self) -> int:
w = 200 #minimum width for every block