コード例 #1
0
ファイル: testECLUtil.py プロジェクト: Unicorn9504/Unicorn
    def testAdjustColour(self):
        """Test that a valid colour results are returned"""
        c = wx.Colour(125, 125, 125)

        # Check that the color was brightened
        c2 = eclib.AdjustColour(c, 50)
        self.assertTrue(
            sum(c.Get()) < sum(c2.Get()), "Failed to lighten colour")

        # Check that the color was darkened
        c2 = eclib.AdjustColour(c, -50)
        self.assertTrue(
            sum(c.Get()) > sum(c2.Get()), "Failed to darken colour")
コード例 #2
0
    def OnPaint(self, evt):
        dc = wx.PaintDC(self)
        gc = wx.GraphicsContext.Create(dc)
        col1 = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DSHADOW)
        col2 = eclib.AdjustColour(col1, -90)
        col1 = eclib.AdjustColour(col1, 90)
        rect = self.GetClientRect()
        grad = gc.CreateLinearGradientBrush(0, 1, 0, rect.height - 1, col2,
                                            col1)

        pen_col = tuple([min(190, x) for x in eclib.AdjustColour(col1, -60)])
        gc.SetPen(gc.CreatePen(wx.Pen(pen_col, 1)))
        gc.SetBrush(grad)
        gc.DrawRectangle(0, 1, rect.width - 0.5, rect.height - 0.5)

        evt.Skip()
コード例 #3
0
ファイル: util.py プロジェクト: wangdyna/wxPython
def AdjustColour(color, percent, alpha=wx.ALPHA_OPAQUE):
    """ Brighten/Darken input colour by percent and adjust alpha
    channel if needed. Returns the modified color.
    @param color: color object to adjust
    @type color: wx.Color
    @param percent: percent to adjust +(brighten) or -(darken)
    @type percent: int
    @keyword alpha: Value to adjust alpha channel to
    @note: DON'T USE THIS FUNCTION use the one in eclib instead
           this will be removed at some point.

    """
    return eclib.AdjustColour(color, percent, alpha)