2
2
"""
3
3
__version__ = '0.1'
4
4
5
- from ..dynamic import ffi , raylib as rl
5
+ from ..static import ffi , rl
6
+ #from ..dynamic import ffi, raylib as rl
6
7
from ..colors import *
7
8
8
9
import sys
@@ -44,16 +45,58 @@ def z(self):
44
45
def z (self , value ):
45
46
self [2 ] = value
46
47
48
+ @property
49
+ def w (self ):
50
+ return self [3 ]
51
+
52
+ @w .setter
53
+ def w (self , value ):
54
+ self [3 ] = value
55
+
56
+ class Color (list ):
57
+ def __init__ (self , s ):
58
+ if isinstance (s , str ):
59
+ super ().__init__ (globals ()[s .upper ()])
60
+ else :
61
+ super ().__init__ (s )
62
+ if len (self ) == 3 :
63
+ self .append (255 )
64
+
65
+ @property
66
+ def r (self ):
67
+ return self [0 ]
68
+
69
+ @r .setter
70
+ def r (self , value ):
71
+ self [0 ] = value
72
+
73
+ @property
74
+ def g (self ):
75
+ return self [1 ]
47
76
48
- def make_color (c ):
49
- if isinstance (c , str ):
50
- return globals ()[c .upper ()]
51
- else :
52
- return c
77
+ @g .setter
78
+ def g (self , value ):
79
+ self [1 ] = value
80
+
81
+ @property
82
+ def b (self ):
83
+ return self [2 ]
84
+
85
+ @b .setter
86
+ def b (self , value ):
87
+ self [2 ] = value
88
+
89
+ @property
90
+ def a (self ):
91
+ return self [3 ]
92
+
93
+ @a .setter
94
+ def a (self , value ):
95
+ self [3 ] = value
53
96
54
97
55
98
def clear (color = BLACK ):
56
- rl .ClearBackground (color )
99
+ rl .ClearBackground (Color ( color ) )
57
100
58
101
59
102
class Shape :
@@ -63,10 +106,7 @@ def color(self):
63
106
64
107
@color .setter
65
108
def color (self , value ):
66
- if isinstance (value , str ):
67
- self ._color = globals ()[value .upper ()]
68
- else :
69
- self ._color = value
109
+ self ._color = Color (value )
70
110
71
111
@property
72
112
def pos (self ):
@@ -82,10 +122,7 @@ def wire_color(self):
82
122
83
123
@wire_color .setter
84
124
def wire_color (self , value ):
85
- if isinstance (value , str ):
86
- self ._wire_color = globals ()[value .upper ()]
87
- else :
88
- self ._wire_color = value
125
+ self ._wire_color = Color (value )
89
126
90
127
@property
91
128
def x (self ):
@@ -117,7 +154,7 @@ def __init__(self, position, size, color=RED, wires=True, wire_color=DARKGRAY):
117
154
self .pos = position
118
155
self .size = size
119
156
self .color = color
120
- self .wire_color = wire_color # make_color(wire_color)
157
+ self .wire_color = wire_color
121
158
self .wires = wires
122
159
123
160
# def __getattr__(self, item):
@@ -150,6 +187,7 @@ def get_bounding_box(self):
150
187
)
151
188
152
189
def draw (self ):
190
+ #print("draw color ",self.color)
153
191
rl .DrawCubeV (self .pos , self .size , self .color )
154
192
if self .wires :
155
193
rl .DrawCubeWiresV (
0 commit comments