def OnPaint(self, event): ps = PAINTSTRUCT() ps.fErase = True hdc = self.BeginPaint(ps) rect = self.GetClientRect() status, graphics = gdiplus.GdipCreateFromHDC(hdc) status = gdiplus.GdipGraphicsClear(graphics, self.color_background) self.grid.draw(graphics) gdiplus.GdipDeleteGraphics(graphics) self.EndPaint(ps)
def OnMouseMove(self, event): self.grid.current_point = GET_POINT_LPARAM(event.lParam) if self.grid.is_cell_changed(): hdc = self.GetDC() status, graphics = gdiplus.GdipCreateFromHDC(hdc) clip_rect = self.grid.current_cell + self.grid.old_cell status = gdiplus.GdipSetClipRectI(graphics, clip_rect.left, clip_rect.top, clip_rect.width, clip_rect.height, gdiplus.CombineModeReplace) status = gdiplus.GdipGraphicsClear(graphics, self.color_background) self.grid.draw(graphics) gdiplus.GdipDeleteGraphics(graphics) self.ReleaseDC(hdc)
def redraw(self, hdc, rect): w, h = rect.width, rect.height status, graphics = gdiplus.GdipCreateFromHDC(hdc) if graphics: self.bendAngle = self.initBendAngle * math.pi / 180 self.branchAngle = self.initBranchAngle * math.pi / 180 self.lastMaxLevels = self.maxLevels self.antiTrunkRatio = 1 - self.trunkRatio self.startAngle = -math.pi / 2 px = w / 2 py = h - 5 #~ gdiplus.GdipSetCompositingMode(graphics, 1) gdiplus.GdipSetSmoothingMode(graphics, 4) # turn on antialiasing self.draw(graphics, px, py, self.startAngle, (h - 100) * self.heightScale, self.maxLevels) self.redrawing = not self.redrawing
def OnPaint(self, event): ps = PAINTSTRUCT() ps.fErase = True hdc = self.BeginPaint(ps) rect = self.GetClientRect() self.ClockDiameter = rect.width if self.ClockDiameter > rect.height: self.ClockDiameter = rect.height self.Width = self.Height = self.ClockDiameter + 2 self.CenterX = self.CenterY = floor(self.ClockDiameter / 2) # redraw background with new color self.Drawing_a_Shaded_Rectangle(hdc, rect) status, self.graphics = gdiplus.GdipCreateFromHDC(hdc) #~ status = gdiplus.GdipSetSmoothingMode(self.graphics, 4) #~ if self.full_redraw_counter == 0: #~ self.draw_outer_circle() #~ self.draw_inner_circle() self.draw_second_marks() self.draw_hour_marks() self.draw_arrows() self.EndPaint(ps)
def OnPaint(self, event): ps = PAINTSTRUCT() ps.fErase = True hdc = self.BeginPaint(ps) rect = self.GetClientRect() self.Drawing_a_Shaded_Rectangle(hdc, rect) status, graphics = gdiplus.GdipCreateFromHDC(hdc) status, pen = gdiplus.GdipCreatePen1( gdiplus.MakeARGB(100, randint(0, 255), randint(0, 255), randint(0, 255)), 30.0) status = gdiplus.GdipDrawLineI(graphics, pen, 0, 0, rect.width, rect.height) status = gdiplus.GdipDrawLineI(graphics, pen, rect.width, 0, 0, rect.height) points = [(rect.width / 2, 0), (rect.width / 2, rect.height), (0, rect.height), (0, rect.height / 2), (rect.width, rect.height / 2)] lines = (POINT * len(points))(*points) status = gdiplus.GdipDrawLinesI(graphics, pen, lines, len(lines)) x, y = rect.width / 3, rect.height / 3 status = gdiplus.GdipDrawEllipseI(graphics, pen, x, y, x, y) status = gdiplus.GdipDrawRectangleI(graphics, pen, rect.left, rect.top, rect.right, rect.bottom) self.EndPaint(ps)