def draw_arrows(self):
        Diameter = self.ClockDiameter
        CenterX, CenterY = self.CenterX, self.CenterY
        current_time = datetime.now()
        A_Hour, A_Min, A_Sec = current_time.hour, current_time.minute, current_time.second

        # prepare to empty previously drawn stuff
        #~ gdiplus.GdipSetSmoothingMode(self.graphics, 1)   # turn off aliasing
        #~ gdiplus.GdipSetCompositingMode(self.graphics, 1) # set to overdraw

        # delete previous graphic and redraw background
        #~ Diameter = ceil(self.ClockDiameter - self.ClockDiameter*0.18)  # 18 % less than clock's outer diameter

        # delete whatever has been drawn here
        #~ status, pBrush = gdiplus.GdipCreateSolidFill(0x00000000) # fully transparent brush 'eraser'
        #~ gdiplus.GdipFillEllipse(self.graphics, pBrush, CenterX-(Diameter/2), CenterY-(Diameter/2), Diameter, Diameter)
        #~ gdiplus.GdipDeleteBrush(pBrush)

        #~ gdiplus.GdipSetCompositingMode(self.graphics, 0) # switch off overdraw
        #~ status, pBrush = gdiplus.GdipCreateSolidFill(0x66008000)
        #~ gdiplus.GdipFillEllipse(self.graphics, pBrush, CenterX-(Diameter/2), CenterY-(Diameter/2), Diameter, Diameter)
        #~ gdiplus.GdipDeleteBrush(pBrush)
        #~ status, pBrush = gdiplus.GdipCreateSolidFill(0x80008000)
        #~ gdiplus.GdipFillEllipse(self.graphics, pBrush, CenterX-(Diameter/2), CenterY-(Diameter/2), Diameter, Diameter)
        #~ gdiplus.GdipDeleteBrush(pBrush)

        # Draw HoursPointer
        gdiplus.GdipSetSmoothingMode(self.graphics, 4)  # turn on antialiasing
        t = A_Hour * 360 / 12 + (A_Min * 360 / 60) / 12 + 90
        R1 = self.ClockDiameter / 2 - ceil(
            (self.ClockDiameter / 2) * 0.5)  # outer position
        status, pPen = gdiplus.GdipCreatePen1(
            0xa0008000, floor((self.ClockDiameter / 100) * 3.5))
        gdiplus.GdipDrawLine(self.graphics, pPen, CenterX, CenterY,
                             ceil(CenterX - (R1 * cos(t * atan(1) * 4 / 180))),
                             ceil(CenterY - (R1 * sin(t * atan(1) * 4 / 180))))
        gdiplus.GdipDeletePen(pPen)

        # Draw MinutesPointer
        t = A_Min * 360 / 60 + 90
        R1 = self.ClockDiameter / 2 - ceil(
            (self.ClockDiameter / 2) * 0.25)  # outer position
        status, pPen = gdiplus.GdipCreatePen1(
            0xa0008000, floor((self.ClockDiameter / 100) * 2.7))
        gdiplus.GdipDrawLine(self.graphics, pPen, CenterX, CenterY,
                             ceil(CenterX - (R1 * cos(t * atan(1) * 4 / 180))),
                             ceil(CenterY - (R1 * sin(t * atan(1) * 4 / 180))))
        gdiplus.GdipDeletePen(pPen)

        # Draw SecondsPointer
        t = A_Sec * 360 / 60 + 90
        R1 = self.ClockDiameter / 2 - ceil(
            (self.ClockDiameter / 2) * 0.2)  # outer position
        status, pPen = gdiplus.GdipCreatePen1(
            0xa000FF00, floor((self.ClockDiameter / 100) * 1.2))
        gdiplus.GdipDrawLine(self.graphics, pPen, CenterX, CenterY,
                             ceil(CenterX - (R1 * cos(t * atan(1) * 4 / 180))),
                             ceil(CenterY - (R1 * sin(t * atan(1) * 4 / 180))))
        gdiplus.GdipDeletePen(pPen)
Пример #2
0
	def draw_hour_marks(self):
		Diameter = self.ClockDiameter
		R1 = Diameter/2-1                      # outer position
		R2 = Diameter/2-1-ceil(Diameter/2*0.1) # inner position
		Items = 12                             # we have 12 hours
		status, pPen = gdiplus.GdipCreatePen1(0xc0008000, ceil((self.ClockDiameter/100)*2.3)) # 2.3 % of total diameter is our pen width
		self.draw_clock_marks(pPen, Items, R1, R2)
Пример #3
0
	def draw_second_marks(self):
		Diameter = self.ClockDiameter
		R1 = Diameter/2-1                       # outer position
		R2 = Diameter/2-1-ceil(Diameter/2*0.05) # inner position
		Items = 60                              # we have 60 seconds
		status, pPen = gdiplus.GdipCreatePen1(0xff00a000, floor((self.ClockDiameter/100)*1.2)) # 1.2 % of total diameter is our pen width
		self.draw_clock_marks(pPen, Items, R1, R2)
Пример #4
0
 def draw(self, graphics, px, py, a, rad, level):
     cx = int(px + math.cos(a) * rad * self.trunkRatio)
     cy = int(py + math.sin(a) * rad * self.trunkRatio)
     status, pen = gdiplus.GdipCreatePen1(
         gdiplus.MakeARGB(100, 0, 100 + level * 3, 0), level)
     status = gdiplus.GdipDrawLineI(graphics, pen, px, py, cx, cy)
     if (level > 0):
         a = a + self.bendAngle
         level = level - 1
         self.draw(graphics, cx, cy, a - self.branchAngle,
                   rad * self.branchRatio, level)
         status = gdiplus.GdipDrawLineI(graphics, pen, px, py, cx, cy)
         self.draw(graphics, cx, cy, a + self.branchAngle,
                   rad * self.branchRatio, level)
         status = gdiplus.GdipDrawLineI(graphics, pen, px, py, cx, cy)
         self.draw(graphics, cx, cy, a, rad * self.antiTrunkRatio, level)
Пример #5
0
 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)
 def create_pen_points(self):
     if self.pen_points:
         status = gdiplus.GdipDeletePen(self.pen_points)
     status, self.pen_points = gdiplus.GdipCreatePen1(
         self.color_points, self.size_point)
     return status
 def create_pen_lines(self):
     if self.pen_lines:
         status = gdiplus.GdipDeletePen(self.pen_lines)
     status, self.pen_lines = gdiplus.GdipCreatePen1(
         self.color_line, self.width_line)
     return status
 def create_pen_cell(self):
     if self.pen_cell:
         status = gdiplus.GdipDeletePen(self.pen_cell)
     status, self.pen_cell = gdiplus.GdipCreatePen1(self.color_active_cell,
                                                    16.0)
     return status