MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_context

Method set_context

lib/matplotlib/backends/backend_cairo.py:93–109  ·  view source on GitHub ↗
(self, ctx)

Source from the content-addressed store, hash-verified

91 super().__init__()
92
93 def set_context(self, ctx):
94 surface = ctx.get_target()
95 if hasattr(surface, "get_width") and hasattr(surface, "get_height"):
96 size = surface.get_width(), surface.get_height()
97 elif hasattr(surface, "get_extents"): # GTK4 RecordingSurface.
98 ext = surface.get_extents()
99 size = ext.width, ext.height
100 else: # vector surfaces.
101 ctx.save()
102 ctx.reset_clip()
103 rect, *rest = ctx.copy_clip_rectangle_list()
104 if rest:
105 raise TypeError("Cannot infer surface size")
106 _, _, *size = rect
107 ctx.restore()
108 self.gc.ctx = ctx
109 self.width, self.height = size
110
111 @staticmethod
112 def _fill_and_stroke(ctx, fill_c, alpha, alpha_overrides):

Callers 7

_saveMethod · 0.80
drawMethod · 0.80
paintEventMethod · 0.80
on_draw_eventMethod · 0.80
drawMethod · 0.80
on_draw_eventMethod · 0.80

Calls 5

saveMethod · 0.80
get_widthMethod · 0.45
get_heightMethod · 0.45
get_extentsMethod · 0.45
restoreMethod · 0.45

Tested by

no test coverage detected