def update_buffer(self, page): width, height = max(self.min_width, page.svg_width * self.zoom), \ max(self.min_height, page.svg_height * self.zoom + 100) width, height = int(width), int(height) #if self.buffer: # print (self.buffer.GetWidth(), self.buffer.GetHeight()), '->' #print (width, height), '->' if self.buffer: # if size has decreased by less than 250 pixels, then don't change size if 0 <= self.buffer.GetWidth() - width < 250: width = self.buffer.GetWidth() if 0 <= self.buffer.GetHeight() - height < 250: height = self.buffer.GetHeight() # if size has increased, then resize and add some extra pixels so that we won't # have to resize quickly again if the note image grows just slightly if self.buffer.GetWidth() < width: width += 250 if self.buffer.GetHeight() < height: height += 250 if self.buffer is None or width != self.buffer.GetWidth() or height != self.buffer.GetHeight(): #print 'create new buffer!!!!!!!!', (width, height) self.buffer = wx_bitmap(width, height, 32)
new_xy = matrix.TransformPoint(x, y) return new_xy class MyApp(wx.App): def OnInit(self): self.SetAppName('EasyABC') return True def matrix_to_str(m): return '(%s)' % ', '.join(['%.3f' % f for f in m.Get()]) if __name__ == "__main__": import os.path app = MyApp(0) buffer = wx_bitmap(200, 200, 32) dc = wx.MemoryDC(buffer) dc.SetBackground(wx.WHITE_BRUSH) dc.Clear() dc = wx.GraphicsContext.Create(dc) dc.SetBrush(dc.CreateBrush(wx.BLACK_BRUSH)) print('default matrix %s' % dc.GetTransform().Get()) import math original_matrix = dc.GetTransform() path = dc.CreatePath() path.AddEllipse(0, 20, 40, 20) path.MoveToPoint(0, 0) path.AddLineToPoint(10, 10) path.AddLineToPoint(20, 0) path.CloseSubpath()