fixed + completed type hints
This commit is contained in:
27
renderer.py
27
renderer.py
@@ -16,17 +16,23 @@ if TYPE_CHECKING:
|
||||
|
||||
class Renderer:
|
||||
def __init__(self, config: Config, display: bool = False) -> None:
|
||||
self.config = config
|
||||
self.display = display
|
||||
self.config: Config = config
|
||||
self.display: bool = display
|
||||
pygame.init()
|
||||
if self.display:
|
||||
self.win = pygame.display.set_mode([self.config.WIDTH, self.config.HEIGHT])
|
||||
self.win: pygame.Surface = pygame.display.set_mode([self.config.WIDTH, self.config.HEIGHT])
|
||||
|
||||
self.surf = pygame.Surface([self.config.WIDTH, self.config.HEIGHT], pygame.SRCALPHA)
|
||||
self.font = pygame.font.SysFont(self.config.DEFAULT_FONT_FAMILY, self.config.DEFAULT_FONT_SIZE)
|
||||
self.italicFont = pygame.font.SysFont(self.config.ITALIC_FONT_FAMILY, self.config.ITALIC_FONT_SIZE, italic=True)
|
||||
self.surf: pygame.Surface = pygame.Surface([self.config.WIDTH, self.config.HEIGHT], pygame.SRCALPHA)
|
||||
|
||||
self.font: pygame.font.Font = pygame.font.SysFont(
|
||||
self.config.DEFAULT_FONT_FAMILY,
|
||||
self.config.DEFAULT_FONT_SIZE)
|
||||
|
||||
self.italicFont: pygame.font.Font = pygame.font.SysFont(
|
||||
self.config.ITALIC_FONT_FAMILY,
|
||||
self.config.ITALIC_FONT_SIZE, italic=True)
|
||||
|
||||
self.margins = self.config.MARGINS
|
||||
self.margins: list[int, int, int, int] = self.config.MARGINS
|
||||
|
||||
def render(self, schema: InstructionSetSchema) -> None:
|
||||
self.surf.fill(self.config.BACKGROUND_COLOR)
|
||||
@@ -206,8 +212,7 @@ class Renderer:
|
||||
|
||||
def drawDependency(self,
|
||||
struct: Structure,
|
||||
structures: dict[str,
|
||||
Structure],
|
||||
structures: dict[str, Structure],
|
||||
bitsX: float,
|
||||
bitsY: float,
|
||||
range_: Range,
|
||||
@@ -274,7 +279,7 @@ class Renderer:
|
||||
descY + bitH - arrowMargin)
|
||||
|
||||
prevDependY = descY + bitH*2 + arrowMargin
|
||||
prevRangeY =prevDependY
|
||||
prevRangeY = prevDependY
|
||||
dependRange.lastValueY = prevDependY
|
||||
descY = self.drawStructure(structures[data["structure"]], structures, rStartX, descY)
|
||||
|
||||
@@ -315,4 +320,4 @@ class Renderer:
|
||||
self.surf.blit(txt, [
|
||||
(start.x + end.x - txt.get_width())/2,
|
||||
(start.y + end.y)/2 + arrowLabelDist
|
||||
])
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user