MCPcopy Create free account
hub / github.com/daft-dev/daft / render

Method render

daft.py:362–455  ·  view source on GitHub ↗

Render the :class:`Plate`, :class:`Edge` and :class:`Node` objects in the model. This will create a new figure with the correct dimensions and plot the model in this area. :param dpi: (optional) The DPI value to use for rendering.

(self, dpi=None)

Source from the content-addressed store, hash-verified

360 return None
361
362 def render(self, dpi=None):
363 """
364 Render the :class:`Plate`, :class:`Edge` and :class:`Node` objects in
365 the model. This will create a new figure with the correct dimensions
366 and plot the model in this area.
367
368 :param dpi: (optional)
369 The DPI value to use for rendering.
370
371 """
372
373 if dpi is None:
374 self._ctx.dpi = self._dpi
375 else:
376 self._ctx.dpi = dpi
377
378 def get_max(maxsize, artist):
379 if isinstance(artist, Ellipse):
380 maxsize = np.maximum(
381 maxsize,
382 artist.center
383 + np.array([artist.width, artist.height]) / 2,
384 dtype=np.float64,
385 )
386 elif isinstance(artist, Rectangle):
387 maxsize = np.maximum(
388 maxsize,
389 np.array([artist._x0, artist._y0], dtype=np.float64)
390 + np.array([artist._width, artist._height]),
391 dtype=np.float64,
392 )
393 return maxsize
394
395 def get_min(minsize, artist):
396 if isinstance(artist, Ellipse):
397 minsize = np.minimum(
398 minsize,
399 artist.center
400 - np.array([artist.width, artist.height]) / 2,
401 dtype=np.float64,
402 )
403 elif isinstance(artist, Rectangle):
404 minsize = np.minimum(
405 minsize,
406 np.array([artist._x0, artist._y0], dtype=np.float64),
407 )
408 return minsize
409
410 # Auto-set shape
411 # We pass through each object once to find the maximum coordinates
412 if self.shape is None:
413
414 maxsize = np.copy(self._ctx.origin)
415
416 for plate in self._plates:
417 artist = plate.render(self._ctx)
418 maxsize = get_max(maxsize, artist)
419

Callers 15

showMethod · 0.95
savefigMethod · 0.95
test_bcaFunction · 0.95
test_classicFunction · 0.95
test_deconvolutionFunction · 0.95
test_exoplanetsFunction · 0.95
test_fixedFunction · 0.95
test_gaiaFunction · 0.95
test_galexFunction · 0.95
test_huey_p_newtonFunction · 0.95
test_logoFunction · 0.95
test_mrfFunction · 0.95

Calls 3

reset_shapeMethod · 0.80
reset_originMethod · 0.80
reset_figureMethod · 0.80

Tested by 15

test_bcaFunction · 0.76
test_classicFunction · 0.76
test_deconvolutionFunction · 0.76
test_exoplanetsFunction · 0.76
test_fixedFunction · 0.76
test_gaiaFunction · 0.76
test_galexFunction · 0.76
test_huey_p_newtonFunction · 0.76
test_logoFunction · 0.76
test_mrfFunction · 0.76
test_no_circlesFunction · 0.76
test_no_grayFunction · 0.76