decompose all the mess around the resistor symbol

This commit is contained in:
2018-03-05 15:15:51 -08:00
parent 04201932a8
commit 871825d60b

View File

@@ -1,16 +1,22 @@
Icon = require '../../default/common/icon'
#
# Resistor
#
class ResistorIcon extends Icon
class ResistorIcon
constructor: (symbol, element) ->
super symbol, element, width=10, height=4
@symbol=symbol
@element=element
width=10
height=4
@schematic = @element.schematic
@settings = @symbol.settings
@width = width * @settings.factor
@height = height * @settings.factor
@d =
w: @width
h: @height
d: @height/4
if @schematic.trimpot
if @schematic.trimpot || @schematic.potentiometer
@height = 2*@height + @d.d
@y1 = -@height/2 - @d.d
@y2 = @height/2
@@ -18,7 +24,6 @@ class ResistorIcon extends Icon
draw: (x, y) ->
settings = @symbol.settings
@symbol
.lineWidth @lineWidth/2
.center x, y # Set center to (x, y)
.line -@d.w/2, 0, (-@d.w/2)*(5/6), -@d.h/2
.line (-@d.w/2)*(5/6), -@d.h/2, (-@d.w/2)*(3/6), @d.h/2