def OnPaint_1(hwnd, msg, wp, lp): dc, ps = win32gui.BeginPaint(hwnd) win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED) br = win32gui.CreateSolidBrush(win32api.RGB(255, 0, 0)) win32gui.SelectObject(dc, br) angle = win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA) win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle + 2) r_angle = angle * (math.pi / 180) win32gui.SetWorldTransform( dc, { 'M11': math.cos(r_angle), 'M12': math.sin(r_angle), 'M21': math.sin(r_angle) * -1, 'M22': math.cos(r_angle), 'Dx': 250, 'Dy': 250 }) win32gui.MoveToEx(dc, 250, 250) win32gui.BeginPath(dc) win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10) win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10) win32gui.LineTo(dc, 300, 300) win32gui.LineTo(dc, 100, 20) win32gui.LineTo(dc, 20, 100) win32gui.LineTo(dc, 400, 0) win32gui.LineTo(dc, 0, 400) win32gui.EndPath(dc) win32gui.StrokeAndFillPath(dc) win32gui.EndPaint(hwnd, ps) return 0
def drawRightArc(self, hdc, pos, radius, width, span, percent, color=ColorCode.BLACK): if percent > 0.0: # Get arc center coordinates xc = pos[0] yc = pos[1] # Calculate a2 a1 = math.radians(span / 2) a2 = math.asin(radius * math.sin(a1) / (radius + width)) # calculate displacement on x and y axis dx = radius * math.cos(a2) dy = radius * math.sin(a2) # calculate starting point coordinates xs = int(xc + dx) ys = int(yc + dy) a2d = math.degrees(a2) # determines arc span span = 2 * a2d # sets the percentage to be drawn n = percent # sets arc fill color sb = win32gui.CreateSolidBrush(color) win32gui.SelectObject(hdc, sb) # sets arc stroke sp = win32gui.CreatePen(win32con.PS_SOLID, 1, ColorCode.BLACK) win32gui.SelectObject(hdc, sp) # draws the outline of the arc win32gui.BeginPath(hdc) win32gui.MoveToEx(hdc, xs, ys) win32gui.AngleArc(hdc, xc, yc, radius + width, -a2d, int(n * span)) win32gui.AngleArc(hdc, xc, yc, radius, int(a2d - (1 - n) * span), -int(n * span)) win32gui.EndPath(hdc) # fills the arc with outer stroke win32gui.StrokeAndFillPath(hdc) # returns the next arc span and radius return span, (radius + width) else: # if its not drawn, returns original arc span and radius return span, radius