GLE Example:

PDF file

size 7 9

include "/subroutines/"

! this example illustrates begin/end object with named points

! draw a line to a named point

sub jointo n$
   aline ptx(n$) pty(n$)
end sub

! a transistor has four named points: base, emitter, collector and cc
! cc is a point on the same vertical line as the emitter/collector, 
! but in the middle (this is useful for positioning)
begin object transistor name$
   local s = 0.6
   circle s
   set arrowsize 0.25 arrowangle 18 just br
   amove 0 0; pmove s -45; name "emitter"
   amove 0 0; pmove s +45; name "collector"
   amove ptx("emitter") 0; name "cc"  
   amove -s/2.5 -s*1.1/2; box s/7 s*1.1 fill black
   amove -s/2.5 +s/6; jointo "collector"
   amove -s/2.5 -s/6; aline ptx(emitter) pty(emitter) arrow end
   amove -s 0; name "base"; aline -s/2.5 0
   amove 0 0; pmove s*1.2 135; write name$
end object

! a vertical resistor has three named points: c1, c2, and cc
! c1 and c2 are its connections; cc is its midpoint 

begin object resistor_v name$
   set just rc
   local s = 0.4
   name "c1"
   amove -s/2 0;  box s 3*s
   amove 0 1.5*s; name "cc"
   amove 0 3*s;   name "c2"
   amove -s/2-0.15 1.5*s; write name$
end object

! draw a connector dot

sub connector
   circle 0.05 fill black
end sub

! draw the ground and power lines

begin name ground
   amove 1 1; rline 5 0
end name

begin name power
   amove 1 8; rline 5 0
end name

! draw the resistor and the two transistors

amove 5 6.25; draw        name R_1
amove 5 2.72; draw        name T_2
amove 3 4.5;  draw transistor.collector name T_1

! draw all connections

join T_2.emitter   - ground.v; connector
join T_2.collector - R_1.c1
join R_1.c2        - power.v; connector
join T_1.collector - T_2.collector.h; connector
join T_1.emitter   - T_2.base.v; jointo T_2.base 
move T_1.base; aline 1 ypos()

return to examples page