sync pyglet update (shape)
This commit is contained in:
parent
f87ae43a10
commit
a46b46ead6
@ -527,7 +527,7 @@ class Arc(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
vertices = (0,) * (self._segments + 1) * 4
|
vertices = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x = -self._anchor_x
|
x = -self._anchor_x
|
||||||
y = -self._anchor_y
|
y = -self._anchor_y
|
||||||
@ -659,7 +659,7 @@ class BezierCurve(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
vertices = (0,) * self._segments * 4
|
vertices = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x = -self._anchor_x
|
x = -self._anchor_x
|
||||||
y = -self._anchor_y
|
y = -self._anchor_y
|
||||||
@ -762,7 +762,7 @@ class Circle(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
vertices = (0,) * self._segments * 6
|
vertices = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x = -self._anchor_x
|
x = -self._anchor_x
|
||||||
y = -self._anchor_y
|
y = -self._anchor_y
|
||||||
@ -858,7 +858,7 @@ class Ellipse(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
vertices = (0,) * self._num_verts * 6
|
vertices = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x = -self._anchor_x
|
x = -self._anchor_x
|
||||||
y = -self._anchor_y
|
y = -self._anchor_y
|
||||||
@ -989,7 +989,7 @@ class Sector(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
vertices = (0,) * self._segments * 6
|
vertices = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x = -self._anchor_x
|
x = -self._anchor_x
|
||||||
y = -self._anchor_y
|
y = -self._anchor_y
|
||||||
@ -1114,11 +1114,11 @@ class Line(ShapeBase):
|
|||||||
|
|
||||||
def __contains__(self, point):
|
def __contains__(self, point):
|
||||||
assert len(point) == 2
|
assert len(point) == 2
|
||||||
vec_AB = Vec2(self._x2 - self._x, self._y2 - self._y)
|
vec_ab = Vec2(self._x2 - self._x, self._y2 - self._y)
|
||||||
vec_BA = Vec2(self._x - self._x2, self._y - self._y2)
|
vec_ba = Vec2(self._x - self._x2, self._y - self._y2)
|
||||||
vec_AP = Vec2(point[0] - self._x - self._anchor_x, point[1] - self._y + self._anchor_y)
|
vec_ap = Vec2(point[0] - self._x - self._anchor_x, point[1] - self._y + self._anchor_y)
|
||||||
vec_BP = Vec2(point[0] - self._x2 - self._anchor_x, point[1] - self._y2 + self._anchor_y)
|
vec_bp = Vec2(point[0] - self._x2 - self._anchor_x, point[1] - self._y2 + self._anchor_y)
|
||||||
if vec_AB.dot(vec_AP) * vec_BA.dot(vec_BP) < 0:
|
if vec_ab.dot(vec_ap) * vec_ba.dot(vec_bp) < 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
a, b = point[0] + self._anchor_x, point[1] - self._anchor_y
|
a, b = point[0] + self._anchor_x, point[1] - self._anchor_y
|
||||||
@ -1137,7 +1137,7 @@ class Line(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
self._vertex_list.position[:] = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
self._vertex_list.position[:] = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x1 = -self._anchor_x
|
x1 = -self._anchor_x
|
||||||
y1 = self._anchor_y - self._width / 2
|
y1 = self._anchor_y - self._width / 2
|
||||||
@ -1158,6 +1158,15 @@ class Line(ShapeBase):
|
|||||||
|
|
||||||
self._vertex_list.position[:] = (ax, ay, bx, by, cx, cy, ax, ay, cx, cy, dx, dy)
|
self._vertex_list.position[:] = (ax, ay, bx, by, cx, cy, ax, ay, cx, cy, dx, dy)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def width(self):
|
||||||
|
return self._width
|
||||||
|
|
||||||
|
@width.setter
|
||||||
|
def width(self, width):
|
||||||
|
self._width = width
|
||||||
|
self._update_vertices()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def x2(self):
|
def x2(self):
|
||||||
"""Second X coordinate of the shape.
|
"""Second X coordinate of the shape.
|
||||||
@ -1242,7 +1251,7 @@ class Rectangle(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
self._vertex_list.position[:] = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
self._vertex_list.position[:] = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x1 = -self._anchor_x
|
x1 = -self._anchor_x
|
||||||
y1 = -self._anchor_y
|
y1 = -self._anchor_y
|
||||||
@ -1386,7 +1395,7 @@ class BorderedRectangle(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
self._vertex_list.position[:] = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
self._vertex_list.position[:] = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
bx1 = -self._anchor_x
|
bx1 = -self._anchor_x
|
||||||
by1 = -self._anchor_y
|
by1 = -self._anchor_y
|
||||||
@ -1565,7 +1574,7 @@ class Triangle(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
self._vertex_list.position[:] = (0, 0, 0, 0, 0, 0)
|
self._vertex_list.position[:] = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x1 = -self._anchor_x
|
x1 = -self._anchor_x
|
||||||
y1 = -self._anchor_y
|
y1 = -self._anchor_y
|
||||||
@ -1693,7 +1702,7 @@ class Star(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
vertices = (0, 0) * self._num_spikes * 6
|
vertices = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
x = -self._anchor_x
|
x = -self._anchor_x
|
||||||
y = -self._anchor_y
|
y = -self._anchor_y
|
||||||
@ -1808,7 +1817,7 @@ class Polygon(ShapeBase):
|
|||||||
|
|
||||||
def _update_vertices(self):
|
def _update_vertices(self):
|
||||||
if not self._visible:
|
if not self._visible:
|
||||||
self._vertex_list.position[:] = tuple([0] * ((len(self._coordinates) - 2) * 6))
|
self._vertex_list.position[:] = (0, 0) * self._num_verts
|
||||||
else:
|
else:
|
||||||
# Adjust all coordinates by the anchor.
|
# Adjust all coordinates by the anchor.
|
||||||
trans_x, trans_y = self._coordinates[0]
|
trans_x, trans_y = self._coordinates[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user