Added image textures in Windows

This commit is contained in:
Skyler Lehmkuhl
2013-01-19 19:57:44 -05:00
parent 0b6ef387e9
commit 63c59d220e
4 changed files with 48 additions and 16 deletions
+5 -1
View File
@@ -119,7 +119,11 @@ class Canvas(GCanvas):
def set_fillcolor(self, c):
state = self._state
state.fillcolor = c
state.win_fill_brush = gdip.SolidBrush(c._win_argb)
if self.fillcolor.image:
tb = gdip.TextureBrush(self.fillcolor.image)
state.win_fill_brush = tb
else:
state.win_fill_brush = gdip.SolidBrush(c._win_argb)
def get_textcolor(self):
return self._state.textcolor
+18 -14
View File
@@ -7,21 +7,25 @@
import win32con as wc, win32api as api
from GUI import Color
def rgb(red, green, blue, alpha = 1.0):
def rgb(red, green, blue, alpha = 1.0, image = False, im = ''):
color = Color()
color._red = red
color._green = green
color._blue = blue
color._alpha = alpha
color._win_color = (
int(red * 255) |
int(green * 255) << 8 |
int(blue * 255) << 16)
color._win_argb = (
int(blue * 255) |
int(green * 255) << 8 |
int(red * 255) << 16 |
int(alpha * 255) << 24)
color.image = image
if image:
color.image = im._win_image
else:
color._red = red
color._green = green
color._blue = blue
color._alpha = alpha
color._win_color = (
int(red * 255) |
int(green * 255) << 8 |
int(blue * 255) << 16)
color._win_argb = (
int(blue * 255) |
int(green * 255) << 8 |
int(red * 255) << 16 |
int(alpha * 255) << 24)
return color
selection_forecolor = Color._from_win_color(
+15
View File
@@ -159,6 +159,21 @@ class SolidBrush(object):
#--------------------------------------------------------------------
class TextureBrush(object):
def __init__(self, image):
ptr = c_void_p()
wg.GdipCreateTexture(image.ptr, 4, byref(ptr))
self.ptr = ptr
def __del__(self, wg = wg):
wg.GdipDeleteBrush(self.ptr)
def __str__(self):
return "<TextureBrush>"
#--------------------------------------------------------------------
class Font(object):
def __init__(self, family, size, style):