Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def rectangle1(topleft, botright):
topleft = topleft["value"]
bottomright = botright["value"]
if (topleft >= bottomright).all():
topleft, bottomright = bottomright, topleft
topright = P(bottomright[0], topleft[1])
bottomleft = P(topleft[0], bottomright[1])
newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
p_topright=topright, p_botleft=bottomleft, children = [
Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
])
return newnode
def grab_point():
root = doc[doc["selection"]["root"]]
for child, transform in root.dfs():
if child.name == "point" and\
collide(child, doc["editor.mouse_xy"], transform=transform, tolerance=8):
doc["editor.drag_start"] = doc["editor.mouse_txy"]
doc["editor.grabbed"] = child["id"]
child.transforms["editor"] = Ex("('translate', `editor.mouse_txy - `editor.drag_start)", calc='on first read')
return True
return False
def add_line_start():
line = Node("line", p_start=doc["editor.mouse_txy"],
p_end=doc["editor.mouse_txy"])
doc["drawing"].append(Node("path", fill_color=None, children=[line]))
doc["editor.drag_start"] = doc["editor.mouse_txy"]
doc["editor.grabbed"] = line[1]["id"]
line[1].transforms["editor"] = Ex("('translate', `editor.mouse_txy - `editor.drag_start)", calc='on first read')
def rectangle1(topleft, botright):
topleft = topleft["value"]
bottomright = botright["value"]
if (topleft >= bottomright).all():
topleft, bottomright = bottomright, topleft
topright = P(bottomright[0], topleft[1])
bottomleft = P(topleft[0], bottomright[1])
newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
p_topright=topright, p_botleft=bottomleft, children = [
Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
])
return newnode
def rectangle1(topleft, botright):
topleft = topleft["value"]
bottomright = botright["value"]
if (topleft >= bottomright).all():
topleft, bottomright = bottomright, topleft
topright = P(bottomright[0], topleft[1])
bottomleft = P(topleft[0], bottomright[1])
newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
p_topright=topright, p_botleft=bottomleft, children = [
Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
])
return newnode
def add_visualize():
assert(len(doc["selection"]) == 1)
node = doc["selection.0.ref"]
pdocument.scope['visualize_cb'] = visualize_cb
doc['editor.callbacks.visualize'] = Ex('visualize_cb(`%s)' % node['id'])
def rectangle1(topleft, botright):
topleft = topleft["value"]
bottomright = botright["value"]
if (topleft >= bottomright).all():
topleft, bottomright = bottomright, topleft
topright = P(bottomright[0], topleft[1])
bottomleft = P(topleft[0], bottomright[1])
newnode = Node("path", skip_points=True, p_topleft=topleft, p_botright=bottomright,
p_topright=topright, p_botleft=bottomleft, children = [
Node("line", start=Ex("`self.parent.topleft", "reeval"), end=Ex("`self.parent.topright", "reeval")),
Node("line", start=Ex("`self.parent.topright", "reeval"), end=Ex("`self.parent.botright", "reeval")),
Node("line", start=Ex("`self.parent.botright", "reeval"), end=Ex("`self.parent.botleft", "reeval")),
Node("line", start=Ex("`self.parent.botleft", "reeval"), end=Ex("`self.parent.topleft", "reeval")),
])
return newnode