ANSI resistor symbol added

This commit is contained in:
2018-03-05 12:07:07 -08:00
parent fc14109b1e
commit e8f597ac8f
3 changed files with 56 additions and 0 deletions

2
.gitignore vendored
View File

@@ -8,3 +8,5 @@ test/svg/*
test/library/*
*.bak
*-cache.lib
qeda-*.tgz
*~

View File

@@ -0,0 +1,43 @@
Icon = require '../../default/common/icon'
#
# Resistor
#
class ResistorIcon extends Icon
constructor: (symbol, element) ->
super symbol, element, width=10, height=4
@d =
w: @width
h: @height
d: @height/4
if @schematic.trimpot
@height = 2*@height + @d.d
@y1 = -@height/2 - @d.d
@y2 = @height/2
draw: (x, y) ->
settings = @symbol.settings
@symbol
.lineWidth @lineWidth
.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
.line (-@d.w/2)*(3/6), @d.h/2, (-@d.w/2)*(1/6), -@d.h/2
.line (-@d.w/2)*(1/6), -@d.h/2, (@d.w/2)*(1/6), @d.h/2
.line (@d.w/2)*(1/6), @d.h/2, (@d.w/2)*(3/6), -@d.h/2
.line (@d.w/2)*(3/6), -@d.h/2, (@d.w/2)*(5/6), @d.h/2
.line (@d.w/2)*(5/6), @d.h/2, (@d.w/2), 0
if @schematic.trimpot
@symbol
.line -@d.h, @d.h, @d.h, -@d.h
.line @d.h - @d.d, -@d.h - @d.d, @d.h + @d.d, -@d.h + @d.d
@symbol.center 0, 0 # Restore default center point
#
# Export object
#
Icons = {}
Icons.Resistor = ResistorIcon
module.exports = Icons

View File

@@ -0,0 +1,11 @@
Icons = require './common/icons'
twoSided = require '../default/common/two-sided'
module.exports = (symbol, element, icons = Icons) ->
element.refDes = 'R'
symbol.orientations = [0, 90, 180, 270]
icon = new icons.Resistor(symbol, element)
twoSided symbol, element, icon
[icon.width, icon.height]