MCPcopy Create free account
hub / github.com/Image-Py/imagepy / draw_rectangle

Function draw_rectangle

imagepy/core/mark/mark.py:203–238  ·  view source on GitHub ↗
(pts, dc, f, **key)

Source from the content-addressed store, hash-verified

201 dc.SetBrush(brush)
202
203def draw_rectangle(pts, dc, f, **key):
204 pen, brush = dc.GetPen(), dc.GetBrush()
205 width, color = pen.GetWidth(), pen.GetColour()
206 fcolor, style = brush.GetColour(), brush.GetStyle()
207
208 if 'color' in pts:
209 pen.SetColour(pts['color'])
210 if 'fcolor' in pts:
211 brush.SetColour(pts['fcolor'])
212 if 'lw' in pts:
213 pen.SetWidth(pts['lw'])
214 if 'fill' in pts:
215 brush.SetStyle((106,100)[pts['fill']])
216
217 dc.SetPen(pen)
218 dc.SetBrush(brush)
219
220 if pts['type'] == 'rectangle':
221 x, y, w, h = pts['body']
222 x, y = f(x, y)
223 w, h = w*key['k'], h*key['k']
224 dc.DrawRectangle(x-w/2, y-h/2, w, h)
225 if pts['type'] == 'rectangles':
226 lst = []
227 for x, y, w, h in pts['body']:
228 x, y = f(x, y)
229 w, h = w*key['k'], h*key['k']
230 lst.append((x-w/2, y-h/2, w, h))
231 dc.DrawRectangleList(lst)
232
233 pen.SetWidth(width)
234 pen.SetColour(color)
235 brush.SetColour(fcolor)
236 brush.SetStyle(style)
237 dc.SetPen(pen)
238 dc.SetBrush(brush)
239
240def draw_text(pts, dc, f, **key):
241 pen, brush, font = dc.GetPen(), dc.GetBrush(), dc.GetFont()

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected