@@ -109,6 +109,42 @@ def plot(self) -> Self:
109
109
self .post_message (self .Plotted (self , monotonic () - start ))
110
110
return self
111
111
112
+ def set (
113
+ self ,
114
+ max_iteration : int | None = None ,
115
+ multibrot : float | None = None ,
116
+ x_position : float | None = None ,
117
+ y_position : float | None = None ,
118
+ zoom : float | None = None ,
119
+ colour_map : ColourMap | None = None ,
120
+ ) -> Self :
121
+ """Set one or more properties in one go.
122
+
123
+ Args:
124
+ max_iteration: The maximum iteration.
125
+ multibrot: The 'multibrot' value.
126
+ x_position: The X position of the middle of the plot.
127
+ y_position: The Y position of the middle of the plot.
128
+ zoom: The zoom value for the plot.
129
+ colour_map: The colour map to use for the plot.
130
+
131
+ Returns:
132
+ Self.
133
+ """
134
+ if max_iteration is not None :
135
+ self .set_reactive (Mandelbrot .max_iteration , max_iteration )
136
+ if multibrot is not None :
137
+ self .set_reactive (Mandelbrot .multibrot , multibrot )
138
+ if x_position is not None :
139
+ self .set_reactive (Mandelbrot .x_position , x_position )
140
+ if y_position is not None :
141
+ self .set_reactive (Mandelbrot .y_position , y_position )
142
+ if zoom is not None :
143
+ self .set_reactive (Mandelbrot .zoom , zoom )
144
+ if colour_map is not None :
145
+ self .set_reactive (Mandelbrot .colour_map , colour_map )
146
+ return self
147
+
112
148
def goto (self , x : float , y : float ) -> Self :
113
149
"""Move the centre of the plot to the given location.
114
150
@@ -119,25 +155,22 @@ def goto(self, x: float, y: float) -> Self:
119
155
Returns:
120
156
Self.
121
157
"""
122
- self .set_reactive (Mandelbrot .x_position , x )
123
- self .set_reactive (Mandelbrot .y_position , y )
124
- return self .plot ()
158
+ return self .set (x_position = x , y_position = y ).plot ()
125
159
126
160
def reset (self ) -> Self :
127
161
"""Reset the plot to its default state.
128
162
129
163
Returns:
130
164
Self.
131
165
"""
132
- self .set_reactive (Mandelbrot .max_iteration , 80 )
133
- self .set_reactive (Mandelbrot .multibrot , 2 )
134
- self .set_reactive (Mandelbrot .x_position , - 0.5 )
135
- self .set_reactive (Mandelbrot .y_position , 0 )
136
- self .set_reactive (Mandelbrot .zoom , 50 )
137
- # Setting an ignore in the following line. For some reason mypy
138
- # can't deal with this; pyright is fine though.
139
- self .set_reactive (Mandelbrot .colour_map , default_map ) # type:ignore
140
- return self .plot ()
166
+ return self .set (
167
+ max_iteration = 80 ,
168
+ multibrot = 2 ,
169
+ x_position = - 0.5 ,
170
+ y_position = 0 ,
171
+ zoom = 50 ,
172
+ colour_map = default_map ,
173
+ ).plot ()
141
174
142
175
def _validate_zoom (self , zoom : int ) -> int :
143
176
"""Ensure the zoom doesn't fall to 0.
0 commit comments