2011-02-11 18:37:00 +01:00
|
|
|
-- Symbol names
|
2011-02-09 14:18:22 +01:00
|
|
|
local names =
|
2010-12-10 23:27:45 +01:00
|
|
|
{
|
|
|
|
en = "Diode",
|
2011-03-04 17:47:04 +01:00
|
|
|
cs = "Dioda",
|
2011-03-06 21:34:21 +01:00
|
|
|
sk = "Dióda",
|
2011-03-07 06:11:44 +01:00
|
|
|
pl = "Dioda",
|
|
|
|
de = "Diode"
|
2010-12-10 23:27:45 +01:00
|
|
|
}
|
|
|
|
|
2011-02-11 18:37:00 +01:00
|
|
|
local names_zener =
|
|
|
|
{
|
|
|
|
en = "Zener diode",
|
2011-03-04 17:47:04 +01:00
|
|
|
cs = "Zenerova dioda",
|
2011-03-06 21:34:21 +01:00
|
|
|
sk = "Zenerova dióda",
|
2011-03-07 06:11:44 +01:00
|
|
|
pl = "Dioda Zenera",
|
|
|
|
de = "Zenerdiode"
|
2011-02-11 18:37:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
local names_led =
|
|
|
|
{
|
|
|
|
en = "Light-emitting diode",
|
2011-03-04 17:47:04 +01:00
|
|
|
cs = "Svítivá dioda",
|
2011-03-06 21:34:21 +01:00
|
|
|
sk = "Svietivá dióda",
|
2011-03-07 06:11:44 +01:00
|
|
|
pl = "Dioda świecąca",
|
|
|
|
de = "Lichtemittierende Diode"
|
2011-02-11 18:37:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
local names_photo =
|
|
|
|
{
|
|
|
|
en = "Photodiode",
|
2011-03-04 17:47:04 +01:00
|
|
|
cs = "Fotodioda",
|
2011-03-06 21:34:21 +01:00
|
|
|
sk = "Fotodióda",
|
2011-03-07 06:11:44 +01:00
|
|
|
pl = "Fotodioda",
|
|
|
|
de = "Fotodiode"
|
2011-02-11 18:37:00 +01:00
|
|
|
}
|
|
|
|
|
2010-12-10 23:27:45 +01:00
|
|
|
-- Render area in base units (X1, Y1, X2, Y2)
|
2011-02-11 18:37:00 +01:00
|
|
|
local area = {-2, -1, 2, 1}
|
|
|
|
local area_rad = {-2, -2.5, 2, 1}
|
2010-12-10 23:27:45 +01:00
|
|
|
|
2011-02-11 18:37:00 +01:00
|
|
|
-- Terminal points
|
2011-02-09 14:18:22 +01:00
|
|
|
local terminals = {{-2, 0}, {2, 0}}
|
2010-12-10 23:27:45 +01:00
|
|
|
|
|
|
|
-- Rendering
|
2011-02-11 18:37:00 +01:00
|
|
|
local render = function (cr)
|
2010-12-10 23:27:45 +01:00
|
|
|
-- The triangle
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:move_to (-1, -1)
|
|
|
|
cr:line_to (1, 0)
|
|
|
|
cr:line_to (-1, 1)
|
|
|
|
cr:line_to (-1, -1)
|
2010-12-10 23:27:45 +01:00
|
|
|
|
|
|
|
-- The vertical line
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:move_to (1, 1)
|
|
|
|
cr:line_to (1, -1)
|
2010-12-10 23:27:45 +01:00
|
|
|
|
2011-02-11 18:37:00 +01:00
|
|
|
-- The terminals
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:move_to (-2, 0)
|
|
|
|
cr:line_to (2, 0)
|
2011-02-11 18:37:00 +01:00
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:stroke ()
|
2011-02-11 18:37:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local render_zener = function (cr)
|
|
|
|
render (cr)
|
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:move_to (1, 1)
|
|
|
|
cr:line_to (0.5, 1)
|
2010-12-10 23:27:45 +01:00
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:stroke ()
|
2010-12-10 23:27:45 +01:00
|
|
|
end
|
|
|
|
|
2011-02-11 18:37:00 +01:00
|
|
|
local render_arrow = function (cr)
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:move_to (0, 0)
|
|
|
|
cr:line_to (0, -1.5)
|
2011-02-11 18:37:00 +01:00
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:stroke ()
|
2011-02-11 18:37:00 +01:00
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:move_to (-0.3, -0.7)
|
|
|
|
cr:line_to (0, -1.5)
|
|
|
|
cr:line_to (0.3, -0.7)
|
|
|
|
cr:close_path ()
|
2011-02-11 18:37:00 +01:00
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:fill ()
|
2011-02-11 18:37:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local render_radiation = function (cr)
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:save ()
|
|
|
|
cr:translate (-0.4, 0)
|
2011-02-11 18:37:00 +01:00
|
|
|
render_arrow (cr)
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:restore ()
|
2011-02-11 18:37:00 +01:00
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:save ()
|
|
|
|
cr:translate (0.4, 0)
|
2011-02-11 18:37:00 +01:00
|
|
|
render_arrow (cr)
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:restore ()
|
2011-02-11 18:37:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local render_led = function (cr)
|
|
|
|
render (cr)
|
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:save ()
|
|
|
|
cr:translate (-0.3, -1.0)
|
|
|
|
cr:rotate (math.atan2 (1, 1))
|
2011-02-11 18:37:00 +01:00
|
|
|
|
|
|
|
render_radiation (cr)
|
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:restore ()
|
2011-02-11 18:37:00 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local render_photo = function (cr)
|
|
|
|
render (cr)
|
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:save ()
|
|
|
|
cr:translate (0.75, -2.05)
|
|
|
|
cr:rotate (math.atan2 (-1, -1))
|
2011-02-11 18:37:00 +01:00
|
|
|
|
|
|
|
render_radiation (cr)
|
|
|
|
|
2012-08-12 06:10:27 +02:00
|
|
|
cr:restore ()
|
2011-02-11 18:37:00 +01:00
|
|
|
end
|
|
|
|
|
2010-12-10 23:27:45 +01:00
|
|
|
-- Register the symbol
|
2011-02-11 18:37:00 +01:00
|
|
|
logdiag.register ("Diode", names, area, terminals, render)
|
|
|
|
logdiag.register ("DiodeZener", names_zener, area, terminals, render_zener)
|
|
|
|
logdiag.register ("DiodeLED", names_led, area_rad, terminals, render_led)
|
|
|
|
logdiag.register ("DiodePhoto", names_photo, area_rad, terminals, render_photo)
|
2010-12-10 23:27:45 +01:00
|
|
|
|
|
|
|
|