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

Method draw_ruler

imagepy/ui/canvas.py:219–233  ·  view source on GitHub ↗
(self, dc)

Source from the content-addressed store, hash-verified

217 self.buffer.SaveFile(path, wx.BITMAP_TYPE_PNG)
218
219 def draw_ruler(self, dc):
220 dc.SetPen(wx.Pen((255,255,255), width=2, style=wx.SOLID))
221 x1 = max(self.imgbox[0], self.box[0])+5
222 x2 = min(self.imgbox[2], self.box[2])+x1-10
223 pixs = (x2-x1+10)*self.ips.size[1]/10.0/self.imgbox[2]
224 h = min(self.imgbox[1]+self.imgbox[3],self.box[3])-5
225 dc.DrawLineList([(x1,h,x2,h)])
226 dc.DrawLineList([(i,h,i,h-8) for i in np.linspace(x1, x2, 3)])
227 dc.DrawLineList([(i,h,i,h-5) for i in np.linspace(x1, x2, 11)])
228
229 dc.SetTextForeground((255,255,255))
230 k, unit = self.ips.unit
231 text = 'Unit = %.1f %s'%(k*pixs, unit)
232 dw,dh = dc.GetTextExtent(text)
233 dc.DrawText(text, (x2-dw, h-10-dh))
234
235 def update(self, pix):
236 if self.ips == None: return

Callers 1

updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected