Пример #1
0
 def __init__(self, text, fill, width, height, connectors=0):
   """
   |text|: label for this pin.
   |fill|: color for this pin.
   """
   Drawable.__init__(self, width, height, connectors)
   self.text = text
   self.fill = fill
Пример #2
0
 def __init__(self, board, width=RESISTOR_HORIZONTAL_WIDTH,
     height=RESISTOR_HORIZONTAL_HEIGHT,
     connectors=CONNECTOR_LEFT | CONNECTOR_RIGHT, init_resistance='1.0K'):
   """
   |board|: the board on which this Resistor_Drawable is placed.
   |init_resistance|: the initial resistance for this resistor.
   """
   Drawable.__init__(self, width, height, connectors)
   self.board = board
   self.init_resistance = init_resistance
   # for automated tests
   self.get_resistance = lambda: init_resistance
Пример #3
0
 def __init__(self, on_signal_file_changed, width=RESISTOR_HORIZONTAL_WIDTH,
     height=RESISTOR_HORIZONTAL_HEIGHT, direction=DIRECTION_UP,
     signal_file=None):
   """
   |on_signal_file_changed|: function to be called when pot signal file is
       changed.
   |direction|: the direction of this pot, one of DIRECTION_DOWN,
       DIRECTION_LEFT, DIRECTION_RIGHT, or DIRECTION_UP.
   |signal_file|: the signal file (containing alpha) associated with this pot.
   """
   assert is_callable(on_signal_file_changed), ('on_signal_file_changed must '
       'be callable')
   Drawable.__init__(self, width, height)
   self.on_signal_file_changed = on_signal_file_changed
   self.direction = direction
   self.signal_file = signal_file
Пример #4
0
 def __init__(self, board, vertices=OP_AMP_RIGHT_VERTICES, signs=OP_AMP_PN,
     jfet=False):
   """
   |board|: the board on which this Op_Amp_Drawable lives.
   |vertices|: the vertices of the triangle for this op amp.
   |signs|: order of signs for this op amp, to allow two configurations.
   |jfet|: True if this is a JFET Op Amp, False otherwise (Power).
   """
   assert vertices in (OP_AMP_RIGHT_VERTICES, OP_AMP_DOWN_VERTICES,
       OP_AMP_LEFT_VERTICES, OP_AMP_UP_VERTICES), 'invalid op amp vertices'
   assert signs in (OP_AMP_PN, OP_AMP_NP), 'invalid op amp signs'
   self.board = board
   self.signs = signs
   self.vertices = vertices
   self.jfet = jfet
   x1, y1, x2, y2, x3, y3 = vertices
   min_x, max_x = [f(x1, x2, x3) for f in min, max]
   min_y, max_y = [f(y1, y2, y3) for f in min, max]
   Drawable.__init__(self, max_x - min_x, max_y - min_y)