Add initialization for attributes in ContextGraph class and basic graph semantics

This commit is contained in:
Kyler Olsen 2025-02-12 10:56:20 -07:00
parent 6e373cd04f
commit 02c10b48f4
1 changed files with 91 additions and 1 deletions

View File

@ -2350,6 +2350,36 @@ class ContextGraph:
_color_saturation: None | ContextFunction
_color_luminosity: None | ContextFunction
def __init__(
self,
x: None | ContextFunction | ContextAnimation,
y: None | ContextFunction | ContextAnimation,
t: None | ContextAnimation,
r: None | ContextFunction,
theta: None | ContextAnimation,
color_alpha: None | ContextFunction,
color_grey: None | ContextFunction,
color_red: None | ContextFunction,
color_green: None | ContextFunction,
color_blue: None | ContextFunction,
color_hue: None | ContextFunction,
color_saturation: None | ContextFunction,
color_luminosity: None | ContextFunction,
):
self._x = x
self._y = y
self._t = t
self._r = r
self._theta = theta
self._color_alpha = color_alpha
self._color_grey = color_grey
self._color_red = color_red
self._color_green = color_green
self._color_blue = color_blue
self._color_hue = color_hue
self._color_saturation = color_saturation
self._color_luminosity = color_luminosity
def step(self, context: ContextNamespace) -> tuple[
int | float,
int | float,
@ -2711,7 +2741,67 @@ def semantics_analyzer(file: File) -> Context:
child.direction,
)
elif isinstance(child, Graph):
pass
x = None
y = None
t = None
r = None
theta = None
color_alpha = None
color_grey = None
color_red = None
color_green = None
color_blue = None
color_hue = None
color_saturation = None
color_luminosity = None
if child.x is not None:
if isinstance(child.x, InlineAnimation):
pass
else:
x = _simplify_expression(
child.x, constants, functions, True)
if child.y is not None:
if isinstance(child.y, InlineAnimation):
pass
else:
y = _simplify_expression(
child.y, constants, functions, True)
if child.t is not None:
pass
if child.r is not None:
r = _simplify_expression(
child.r, constants, functions, True)
if child.theta is not None:
pass
if child.color_alpha is not None:
color_alpha = _simplify_expression(
child.color_alpha, constants, functions, True)
if child.color_grey is not None:
color_grey = _simplify_expression(
child.color_grey, constants, functions, True)
if child.color_red is not None:
color_red = _simplify_expression(
child.color_red, constants, functions, True)
if child.color_green is not None:
color_green = _simplify_expression(
child.color_green, constants, functions, True)
if child.color_blue is not None:
color_blue = _simplify_expression(
child.color_blue, constants, functions, True)
if child.color_hue is not None:
color_hue = _simplify_expression(
child.color_hue, constants, functions, True)
if child.color_saturation is not None:
color_saturation = _simplify_expression(
child.color_saturation, constants, functions, True)
if child.color_luminosity is not None:
color_luminosity = _simplify_expression(
child.color_luminosity, constants, functions, True)
graphs.append(ContextGraph(
x, y, t, r, theta, color_alpha, color_grey, color_red,
color_green, color_blue, color_hue, color_saturation,
color_luminosity,
))
if screen is None:
screen = Screen(file.file_info)