Skip to content

Commit

Permalink
fix: color accepts floats, but casts to int; Line start and end impli…
Browse files Browse the repository at this point in the history
…citly converts to Position
  • Loading branch information
EdwardLu2018 committed Aug 3, 2023
1 parent 6a02410 commit 3684684
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions arena/attributes/color.py
Expand Up @@ -27,6 +27,11 @@ def __init__(self, red=0, green=0, blue=0):
else:
c = tuple(int(color[c:c+2], 16) for c in (0, 2, 4))
red, green, blue = c

if isinstance(red, float): red = int(red)
if isinstance(blue, float): blue = int(blue)
if isinstance(green, float): green = int(green)

super().__init__(red=red, green=green, blue=blue)

@property
Expand Down
2 changes: 1 addition & 1 deletion arena/attributes/data.py
Expand Up @@ -72,7 +72,7 @@ def update_data(cls, data, new_data):

# allow user to input tuples, lists, dicts, etc for specific Attributes.
# everything gets converted to corresponding attribute
if k == "position" and not isinstance(v, Position):
if (k == "position" or k == "start" or k == "end") and not isinstance(v, Position):
if isinstance(v, (list,tuple)):
data[k] = Position(*v[:3])
elif isinstance(v, dict):
Expand Down
2 changes: 1 addition & 1 deletion arena/objects/line.py
Expand Up @@ -7,6 +7,6 @@ class Line(Object):
"""
object_type = "line"

def __init__(self, start=Position(0,0,0), end=Position(10,10,10), **kwargs):
def __init__(self, start, end, **kwargs):
super().__init__(object_type=Line.object_type, start=start, end=end, **kwargs)

7 changes: 4 additions & 3 deletions examples/objects/line.py
Expand Up @@ -3,15 +3,16 @@
scene = Scene(host="arenaxr.org", scene="example")

start = (0,0,-3)
end = (10,10,-10)
end = (5,5,5)

@scene.run_once
def make_line():
line = Line(
object_id="my_line",
path=(start, end),
start=start,
end=end,
color=(0,255,0)
)
scene.add_object(line)
print(scene.add_object(line))

scene.run_tasks()

0 comments on commit 3684684

Please sign in to comment.