Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render_base(self):
# Render for base
if not self.active and not self.hover:
return False
gr = self.graphics
self.cw, self.ch = self.w // 2, self.h // 2
if self.problem:
if not gr['error']:
gr['error'] = Quad(self.batch, True)
gr['error'].redraw(self.x, self.y, self.cw + self.put_size,
self.ch + self.put_size,
(190, 20, 20))
elif gr['error']:
gr['error'].id.delete()
gr['error'] = None
gr['base'].redraw(self.x, self.y, self.cw, self.ch,
self.draw_color)
self.pin_color = color_select(self.draw_color)
for input in self.put_pos(self.inputs):
put_name = self.selectedInput['name']
self.id = self.id_counter
self.x, self.y = x, y
self.w, self.h = 70, 30
self.cw, self.ch = self.w // 2, self.h // 2
self.offset = 20
self.put_size = 5
self.pin_color = color_select(color)
self.color = color
self.draw_color = color
self.er_color = (230, 20, 20)
self.active = True
self.batch = batch
self.graphics = dict(inputs=dict(), outputs=dict(), connections=list(),
error=None, base=Quad(self.batch))
self.er_label = pyglet.text.Label('error', font_name=font,
bold=True, font_size=12,
color=self.er_color + (255,),
anchor_x='right', anchor_y='center')
self.inputs = ()
self.outputs = ()
self.in_labels = []
self.connected_to = []
self.out_labels = []
self.child = []
self.selected = False # 714848
self.selectedInput = {'name': 'none', 'pos': 0}
self.selectedOutput = {'name': 'none', 'pos': 0}
self.hover = False
[put.delete() for put in gr['inputs'].values()]
[put.delete() for put in gr['outputs'].values()]
self.in_labels = []
gr['inputs'] = dict()
for input in self.inputs:
gr['inputs'][input] = Quad(self.batch)
self.in_labels.append(pyglet.text.Label(input, x=0, y=0,
font_name=font,
bold=True,
color=(255,255,255,200),
font_size=12))
self.out_labels = []
gr['outputs'] = dict()
for output in self.outputs:
gr['outputs'][output] = Quad(self.batch)
self.out_labels.append(pyglet.text.Label(output, x=0, y=0,
font_name=font,
bold=True,
color=(255,255,255,200),
font_size=12,
anchor_x='right'))
if self.is_number:
if not self.graphics['scroll']:
self.graphics['scroll'] = Quad(self.batch, frontdrop=True)
self.graphics['scroll'].redraw(self.x - self.cw + 10,
self.y, 10, self.ch,
(172, 150, 83))
elif self.graphics['scroll']:
self.graphics['scroll'].delete()
self.graphics['scroll'] = None
if self.hover:
if not self.graphics['corner']:
self.graphics['corner'] = Quad(self.batch, frontdrop=True)
self.graphics['corner'].redraw(self.x + self.cw - 5,
self.y - self.ch + 5,
5, 5, (50, 50, 50))
elif self.graphics['corner']:
self.graphics['corner'].delete()
self.graphics['corner'] = None