diff options
author | Norbert Preining <norbert@preining.info> | 2022-02-12 03:00:39 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-02-12 03:00:39 +0000 |
commit | 5656f95d1f5070edb430085a49ca8cd1f6f6f064 (patch) | |
tree | bfadc14c9b4a3c051099eadb6eb4a6dd302005af /graphics/circuit_macros/examples | |
parent | 4eb178c7cffedf8da4dc598b6d187a142e5ad93d (diff) |
CTAN sync 202202120300
Diffstat (limited to 'graphics/circuit_macros/examples')
43 files changed, 2148 insertions, 1729 deletions
diff --git a/graphics/circuit_macros/examples/Arrester.m4 b/graphics/circuit_macros/examples/Arrester.m4 deleted file mode 100644 index 791a2f2162..0000000000 --- a/graphics/circuit_macros/examples/Arrester.m4 +++ /dev/null @@ -1,28 +0,0 @@ -.PS -# Arrester.m4 -cct_init - -divert(-1) - -divert(0)dnl - -movewid = movewid/2 - M: arrester - {"\tt arr{}ester()" at last [].s below} - N: arrester(,D) with .A at M.end+(movewid,0) - {"\strut\tt $\cdots$(,D)" at last [].s below} - P: arrester(,LD) with .A at N.B+(movewid,0) - {"\tt (,LD)" at last [].s below} - move; H: arrester(,S) - {"\tt (,S)" at last [].s below} - move; Q: arrester(,E) - {"\tt (,E)" at last [].s below} - R: arrester(,ED) with .A at Q.end+(movewid,0) - {"\tt $\cdots$(,ED)" at last [].s below} - thinlines_ - Loopover_(`X', - `spline <- from X.A up 8bp__ then up 6bp__ right 4bp__; "\sl A" ljust - spline <- from X.B up 8bp__ then up 6bp__ left 4bp__; "\sl B" rjust - arrow <- from X.G right 12bp__ up 2bp__; "\sl G" ljust',N,R) - -.PE diff --git a/graphics/circuit_macros/examples/Arresters.m4 b/graphics/circuit_macros/examples/Arresters.m4 new file mode 100644 index 0000000000..25dd8a8e33 --- /dev/null +++ b/graphics/circuit_macros/examples/Arresters.m4 @@ -0,0 +1,75 @@ +.PS +# Arresters.m4 +cct_init + + sep = 0.2 + +R1: [ + arrester + {`"\tt arrester"' at last line.c+(0,-0.2)} + move sep + arrester(,G) + {`"\tt arrester(,G)"' at last line.c+(0,-0.2)} + move sep + arrester(,g) + {`"\tt ...(,g)"' at last line.c+(0,-0.2)} + move sep + arrester(,M) + {`"\tt \ldots(,M)"' at last line.c+(0,-0.2)} + move sep + arrester(,C) + {`"\tt \ldots(,C)"' at last line.c+(0,-0.2)} + move sep + arrester(,A) + {`"\tt \ldots(,A)"' at last line.c+(0,-0.2)} + ] + +R2: [ + arrester(,H) + {`"\tt \ldots(,H)"' at last line.c+(0,-0.2)} + move sep + arrester(,HR) + {`"\tt \ldots(,HR)"' at last line.c+(0,-0.2)} + move sep + arrester(,P) + {`"\tt \ldots(,P)"' at last line.c+(0,-0.2)} + move sep + arrester(,s) + {`"\tt \ldots(,s)"' at last line.c+(0,-0.2)} + move sep + arrester(,F) + {`"\tt \ldots(,F)"' at last line.c+(0,-0.2)} + move sep + arrester(,S) + {`"\tt \ldots(,S)"' at last line.c+(0,-0.2)} + + ] with .nw at R1.sw+(0,-0.2) + + define(`Dlabels', + `{ thinlines_ + arrow <- from A.A up 0.1 left 0.1; "\sl A" rjust + arrow <- from A.B up 0.1 right 0.1; "\sl B" ljust + arrow <- from A.G up 0.05 right 0.15; "\sl G" ljust + thicklines_ }') +[ + arrester(,E) + {`"\tt \ldots(,E)"' at last line.c+(0,-0.25)} + move sep + A: arrester(,DE) + {`"\tt \ldots(,DE)"' at last [].s+(0,-0.1)} + Dlabels + move sep*3 + A: arrester(,DS) + {`"\tt \ldots(,DS)"' at last [].s+(0,-0.1)} + Dlabels + move sep*3 + A: arrester(,DEL) + {`"\tt \ldots(,DEL)"' at last [].s+(0,-0.1)} + Dlabels + move sep*3 + A: arrester(,DSL) + {`"\tt \ldots(,DSL)"' at last [].s+(0,-0.1)} + Dlabels + ] with .nw at R2.sw+(0,-0.2) + +.PE diff --git a/graphics/circuit_macros/examples/Consumption.m4 b/graphics/circuit_macros/examples/Consumption.m4 new file mode 100644 index 0000000000..3b165abb7f --- /dev/null +++ b/graphics/circuit_macros/examples/Consumption.m4 @@ -0,0 +1,524 @@ +.PS +# Consumption+.m4 +gen_init +{\sf +sinclude(examples.dim) +sinclude(tst.dim) +s_init(test) + +#nl raw data ranges + rxmin=1.76665, rxmax=5.87332, rymin=1.49164, rymax=4.00836 + +#nl horiz range + yearmin = 1850 + yearmax = 2040 +#nl data ranges + tonsmin = 0 + tonsmax = 2.0 + popmin = 0 + popmax = 10 +#nl page graph size + minx = 0 + maxx = 4.5 + maxx = 4.566 + miny = 0 + maxy = 3.5 + +define dtop {(minx + ($1-yearmin)/(yearmax-yearmin)*(maxx-minx), \ + miny + ($2-tonsmin)/(tonsmax-tonsmin)*(maxy-miny))} +define ptop {(minx + ($1-yearmin)/(yearmax-yearmin)*(maxx-minx), \ + miny + ($2-popmin)/(popmax-popmin)*(maxy-miny))} + +define(`rtod',`yearmin + (`$1'-rxmin)/(rxmax-rxmin)*(2010-yearmin), \ + tonsmin + (`$2'-rymin)/(rymax-rymin)*1.8') + +[ +nD = 0 +define data { nD+=1 + yr[nD]=$1; pop[nD]=$2/1e9; wood[nD]=$3; other[nD]=$4; hydro[nD]=$5 + coal[nD]=$6; oil[nD]=$7; gas[nD]=$8; nuclear[nD]=$9 } + +data(1850,1241000000,0.238506368,0.238506368,0.238506368,0.274220157,0.274220157,0.276138711,0.276138711) +data(1851,1247847137,0.238701076,0.238701076,0.238701076,0.2788137,0.2788137,0.280785327,0.280785327) +data(1852,1254732053,0.238886465,0.238886465,0.238886465,0.287918165,0.287918165,0.289942225,0.289942225) +data(1853,1261654955,0.239062633,0.239062633,0.239062633,0.290097546,0.290097546,0.292173405,0.292173405) +data(1854,1268616055,0.239229675,0.239229675,0.239229675,0.289984551,0.289984551,0.292111579,0.292111579) +data(1855,1275615561,0.239387687,0.239387687,0.239387687,0.289864062,0.289864062,0.292041635,0.292041635) +data(1856,1282653687,0.239651345,0.239651345,0.239651345,0.301026039,0.301026039,0.303253538,0.303253538) +data(1857,1289730646,0.239904902,0.239904902,0.239904902,0.298720029,0.298720029,0.300996841,0.300996841) +data(1858,1296846651,0.24014846,0.24014846,0.24014846,0.303062054,0.303062054,0.30538757,0.30538757) +data(1859,1304001918,0.240382123,0.240382123,0.240382123,0.309545901,0.309914765,0.312288384,0.312288384) +data(1860,1311196664,0.24060599,0.24060599,0.24060599,0.309390256,0.310123937,0.312545059,0.312545059) +data(1861,1318431107,0.240590657,0.240590657,0.240590657,0.319869525,0.320964008,0.323432041,0.323432041) +data(1862,1325705465,0.240568247,0.240568247,0.240568247,0.308599723,0.310051026,0.312565381,0.312565381) +data(1863,1333019958,0.24053884,0.24053884,0.24053884,0.318950063,0.320754238,0.323314334,0.323314334) +data(1864,1340374810,0.240502511,0.240502511,0.240502511,0.327038715,0.329191844,0.331797103,0.331797103) +data(1865,1347770241,0.240459339,0.240459339,0.240459339,0.328647778,0.331145979,0.333795828,0.333795828) +data(1866,1347770241,0.242191279,0.242191279,0.242191279,0.330379718,0.333234804,0.335943539,0.335943539) +data(1867,1362683739,0.241253672,0.241253672,0.241253672,0.336892133,0.340068952,0.342806283,0.342806283) +data(1868,1370202258,0.24163346,0.24163346,0.24163346,0.336747138,0.340257568,0.3430378,0.3430378) +data(1869,1377762260,0.242001817,0.242001817,0.242001817,0.33659359,0.340433875,0.343256455,0.343256455) +data(1870,1385363974,0.242358855,0.242358855,0.242358855,0.348847699,0.353014113,0.355878493,0.355878493) +data(1871,1393007630,0.24215233,0.24215233,0.24215233,0.358346838,0.362835686,0.365741322,0.365741322) +data(1872,1400693459,0.241940775,0.241940775,0.241940775,0.365684522,0.37049214,0.373438493,0.373438493) +data(1873,1408421694,0.24172425,0.24172425,0.24172425,0.360718048,0.365840803,0.368827338,0.368827338) +data(1874,1416192570,0.241502816,0.241502816,0.241502816,0.363892286,0.369326575,0.372352763,0.372352763) +data(1875,1424006320,0.241276535,0.241276535,0.241276535,0.362994434,0.368736684,0.371802,0.371802) +data(1876,1431863183,0.240604702,0.240604702,0.240604702,0.369663316,0.375709983,0.378813907,0.378813907) +data(1877,1439763395,0.239932976,0.239932976,0.239932976,0.368283426,0.374630997,0.377773011,0.377773011) +data(1878,1447707196,0.239261379,0.239261379,0.239261379,0.366907548,0.373552539,0.376732133,0.376732133) +data(1879,1455694826,0.238589927,0.238589927,0.238589927,0.373413172,0.380352127,0.383568794,0.383568794) +data(1880,1463726528,0.23791864,0.23791864,0.23791864,0.383753486,0.390982979,0.394236217,0.394236217) +data(1881,1471802544,0.237570608,0.237570608,0.237570608,0.392344331,0.399860965,0.403150275,0.403150275) +data(1882,1479923119,0.237219231,0.237219231,0.237227977,0.396963826,0.404764232,0.40808912,0.40808912) +data(1883,1488088499,0.236864558,0.236864558,0.236881953,0.403447314,0.411528151,0.414888128,0.414888128) +data(1884,1496298931,0.236506634,0.236506634,0.236532584,0.406015836,0.414373792,0.417768372,0.417768372) +data(1885,1504554663,0.236145507,0.236145507,0.236179917,0.404733187,0.413364978,0.416793681,0.416793681) +data(1886,1512855946,0.235261191,0.235261191,0.235303968,0.40293236,0.411834727,0.415297076,0.415297076) +data(1887,1521203030,0.23437947,0.23437947,0.23443052,0.406792802,0.415962519,0.419458041,0.419458041) +data(1888,1529596169,0.233500342,0.233500342,0.233559574,0.423718314,0.433152176,0.436680404,0.436680404) +data(1889,1538035617,0.232623805,0.232623805,0.232691127,0.425534315,0.435229149,0.438789617,0.438789617) +data(1890,1546521628,0.231749857,0.231749857,0.231825179,0.431025052,0.44097771,0.444569959,0.444569959) +data(1891,1555054461,0.23057828,0.23057828,0.230661512,0.436142504,0.446349864,0.449973439,0.449973439) +data(1892,1563634373,0.229412583,0.229412583,0.229503635,0.439357394,0.449816361,0.453470809,0.453470809) +data(1893,1572261624,0.228252736,0.228252736,0.228351521,0.431583686,0.442291192,0.445976065,0.445976065) +data(1894,1580936476,0.22709871,0.22709871,0.22720514,0.436575574,0.447528576,0.45124343,0.45124343) +data(1895,1589659190,0.225950477,0.225950477,0.226064464,0.441499685,0.452695166,0.456439562,0.456439562) +data(1896,1598430032,0.225392144,0.225392144,0.225513603,0.450527775,0.461962746,0.465736247,0.465736247) +data(1897,1607249265,0.224833135,0.224833135,0.224961981,0.457659825,0.469331318,0.473133492,0.473133492) +data(1898,1616117159,0.224273475,0.224273475,0.224409622,0.473569462,0.48547454,0.489304958,0.489304958) +data(1899,1625033980,0.223713188,0.223713188,0.223856553,0.494583176,0.506718923,0.510577162,0.510577162) +data(1900,1634000000,0.223152296,0.223152296,0.223302795,0.504825195,0.51718872,0.521074359,0.521074359) +data(1901,1648219401,0.221510378,0.221510378,0.221677629,0.505816316,0.519528083,0.5237969,0.5237969) +data(1902,1662562543,0.219880182,0.219880182,0.220068436,0.508573752,0.523333498,0.527978592,0.527978592) +data(1903,1677030501,0.218261627,0.218261627,0.218478353,0.530583699,0.546223844,0.551238406,0.551238406) +data(1904,1691624363,0.216654634,0.216654634,0.216900192,0.527887731,0.545298807,0.550676116,0.550676116) +data(1905,1706345223,0.215059124,0.215059124,0.215337131,0.547716584,0.564693219,0.570426643,0.570426643) +data(1906,1721194188,0.214836225,0.214836225,0.215148552,0.563118074,0.579880854,0.585963848,0.585963848) +data(1907,1736172371,0.214601167,0.214601167,0.214954035,0.596547339,0.617095414,0.62352152,0.62352152) +data(1908,1751280897,0.214354174,0.214354174,0.214752998,0.574277169,0.596299335,0.60306218,0.60306218) +data(1909,1766520901,0.214095471,0.214095471,0.214542936,0.586977877,0.609919015,0.61701231,0.61701231) +data(1910,1781893526,0.213825278,0.213825278,0.214318488,0.603352348,0.628089516,0.635693908,0.635693908) +data(1911,1797399927,0.212500054,0.212500054,0.213041248,0.605588411,0.631564823,0.639504319,0.639504319) +data(1912,1813041268,0.211181781,0.211181781,0.211751647,0.620130467,0.646297549,0.654565803,0.654565803) +data(1913,1828818723,0.209870438,0.209870438,0.210513435,0.644310839,0.672912362,0.681503109,0.681503109) +data(1914,1844733476,0.208566004,0.208566004,0.209324315,0.595307622,0.624513467,0.633420528,0.633420528) +data(1915,1860786724,0.207268457,0.207268457,0.208098411,0.584702733,0.615780985,0.624998263,0.624998263) +data(1916,1876979669,0.204485426,0.204485975,0.205402589,0.605882504,0.638934007,0.648455487,0.648455487) +data(1917,1893313529,0.201734987,0.201735896,0.202715085,0.616179081,0.652399178,0.662218924,0.662218924) +data(1918,1909789530,0.199016787,0.199017732,0.200115349,0.602687652,0.638337653,0.648449811,0.648449811) +data(1919,1926408908,0.196330472,0.196331097,0.196945715,0.535439366,0.575689906,0.586088699,0.586088699) +data(1920,1943172912,0.193675695,0.193676005,0.195243412,0.579848388,0.630973534,0.641653264,0.641653264) +data(1921,1960082799,0.192957547,0.192958381,0.194440762,0.512833825,0.567705487,0.578660532,0.578660532) +data(1922,1977139839,0.192237376,0.192238246,0.193895625,0.527050727,0.587771773,0.599365431,0.599365431) +data(1923,1994345313,0.19151527,0.191516348,0.193525554,0.578230714,0.649426509,0.662893064,0.662893064) +data(1924,2011700513,0.190791315,0.190792469,0.192986897,0.564368556,0.634750802,0.650057077,0.650057077) +data(1925,2029206742,0.190065598,0.190066911,0.192579912,0.561692328,0.634850472,0.651963721,0.651963721) +data(1926,2046865313,0.189342426,0.18934419,0.192313939,0.556598403,0.631036129,0.649924035,0.649924035) +data(1927,2064677552,0.188617585,0.188619709,0.191901916,0.581066305,0.66532014,0.685950808,0.685950808) +data(1928,2082644798,0.187891159,0.187893595,0.191560967,0.570524051,0.658240401,0.680582356,0.680582356) +data(1929,2082644798,0.188791962,0.188794439,0.19317309,0.596191895,0.694524554,0.718247863,0.718247863) +data(1930,2119049713,0.186433874,0.186436187,0.190385499,0.552331717,0.644491424,0.668934944,0.668934944) +data(1931,2137490116,0.185921585,0.185923717,0.190113868,0.506565457,0.594964462,0.620348577,0.620348577) +data(1932,2156090991,0.185404259,0.185406253,0.189724679,0.468661357,0.552304395,0.578611056,0.578611056) +data(1933,2174853735,0.184882022,0.184885026,0.189466471,0.478973885,0.569521584,0.596732983,0.596732983) +data(1934,2193779755,0.184354996,0.184357857,0.189137885,0.50231919,0.597048389,0.625146959,0.625146959) +data(1935,2212870475,0.183823303,0.183826489,0.189391253,0.513244919,0.615346693,0.6443151,0.6443151) +data(1936,2232127325,0.183422624,0.183426207,0.189292235,0.541976812,0.652213355,0.6820345,0.6820345) +data(1937,2251551752,0.183015177,0.183016132,0.189691455,0.557024422,0.681411525,0.713128315,0.713128315) +data(1938,2271145215,0.182601109,0.182608794,0.189219601,0.528985648,0.649365004,0.682755166,0.682755166) +data(1939,2290909184,0.182180563,0.182198879,0.189050477,0.544855454,0.669193862,0.704673928,0.704673928) +data(1940,2310845143,0.181753683,0.181773628,0.188817984,0.577859192,0.705095325,0.742626751,0.742626751) +data(1941,2330954589,0.180256141,0.180280081,0.187681608,0.587475315,0.717410922,0.756955672,0.756955672) +data(1942,2351239032,0.17877091,0.178803567,0.18636161,0.589499673,0.710751063,0.752271606,0.752271606) +data(1943,2371699993,0.17729789,0.177330845,0.185849103,0.596589637,0.725948747,0.769408049,0.769408049) +data(1944,2392339011,0.17583698,0.175847008,0.183932936,0.574921594,0.722215099,0.767576618,0.767576618) +data(1945,2413157633,0.174388081,0.174391359,0.182283924,0.493293215,0.63914527,0.68637295,0.68637295) +data(1946,2434157423,0.173522919,0.173531361,0.182267965,0.514250229,0.668057865,0.717384008,0.717384008) +data(1947,2455339957,0.172659705,0.172683238,0.181755468,0.551547112,0.719518964,0.773619655,0.773619655) +data(1948,2476706827,0.17179847,0.171828917,0.181742644,0.560535238,0.749010917,0.809647204,0.809647204) +data(1949,2498259635,0.170939245,0.17097559,0.181133719,0.538171636,0.723949765,0.788183962,0.788183962) +data(1950,2557628654,0.167579756,0.167622721,0.178408185,0.559396293,0.762977841,0.834822272,0.834822272) +data(1951,2594938936,0.167032664,0.167085184,0.179115513,0.574723533,0.802272625,0.886283415,0.886283415) +data(1952,2636770386,0.166215588,0.166275557,0.178905263,0.565999791,0.801386992,0.890443027,0.890443027) +data(1953,2682050452,0.165211328,0.165271599,0.178153454,0.56040182,0.805094458,0.897685967,0.897685967) +data(1954,2730224110,0.164066346,0.164125585,0.177552809,0.548214509,0.799870041,0.895277726,0.895277726) +data(1955,2782093851,0.162744571,0.162802026,0.177062242,0.572289721,0.849071541,0.950920777,0.950920777) +data(1956,2835293441,0.161343608,0.161397559,0.176802814,0.586639897,0.882197665,0.990604979,0.990610309) +data(1957,2891342302,0.159836585,0.159890471,0.176313385,0.589494533,0.894932945,1.010584994,1.010622753) +data(1958,2948128605,0.158347259,0.158403549,0.176092897,0.594122165,0.901178987,1.023306716,1.023348608) +data(1959,3000706677,0.157134282,0.157194027,0.175092878,0.60075882,0.926301469,1.060278841,1.060403012) +data(1960,3042990271,0.156490706,0.156555865,0.175795691,0.61309257,0.958977014,1.102738263,1.102971765) +data(1961,3084007286,0.155724141,0.155801371,0.175847845,0.582341401,0.945610971,1.097964839,1.098333034) +data(1962,3140187350,0.154229357,0.154309778,0.175037739,0.583886676,0.970894477,1.134494733,1.135032498) +data(1963,3209978774,0.152139251,0.152229147,0.173552486,0.585699084,0.991892736,1.166953505,1.167858812) +data(1964,3281412257,0.150062967,0.150160837,0.171811855,0.592867755,1.021995792,1.209049525,1.210281169) +data(1965,3350699989,0.14816998,0.148271574,0.171655685,0.592192206,1.043069039,1.239349435,1.241269627) +data(1966,3421015609,0.147131043,0.14723349,0.171776593,0.589397107,1.068586677,1.275452622,1.27813231) +data(1967,3490735455,0.146158896,0.14626543,0.170803075,0.56557596,1.069927556,1.288070014,1.291237119) +data(1968,3562786611,0.145129793,0.1452355,0.170411047,0.568040201,1.107666962,1.34146315,1.345320724) +data(1969,3637707956,0.14402776,0.144141478,0.170254838,0.567570209,1.136409991,1.38786865,1.392325229) +data(1970,3713327898,0.142943308,0.143053274,0.169862261,0.574604634,1.187424472,1.460093809,1.4656198) +data(1971,3790980082,0.141867123,0.1419725,0.169518561,0.562377273,1.199174341,1.484731543,1.492185663) +data(1972,3867242256,0.14088476,0.141006603,0.169241956,0.55299154,1.211873977,1.508449967,1.518429829) +data(1973,3942790520,0.139965732,0.140098019,0.168229646,0.551337808,1.256519325,1.5637256,1.576827076) +data(1974,4017323955,0.139116394,0.139264313,0.169566501,0.548855283,1.243354913,1.55159078,1.568155026) +data(1975,4088810897,0.138401041,0.13856795,0.16866321,0.563492361,1.21131787,1.515162671,1.537578295) +data(1976,4158888836,0.137644673,0.137823056,0.167542119,0.566773642,1.257660106,1.569161684,1.594857237) +data(1977,4229748034,0.136888084,0.137068744,0.166990254,0.571441309,1.275256046,1.610533422,1.641644931) +data(1978,4300631215,0.136155668,0.136323913,0.168223987,0.572181835,1.27205561,1.591706702,1.627562741) +data(1979,4374349678,0.135359212,0.13557451,0.168367796,0.588798681,1.303224877,1.642092677,1.678738222) +data(1980,4445423675,0.13466922,0.135694224,0.169018612,0.535103352,1.264795628,1.575204786,1.612060086) +data(1981,4526817917,0.134213008,0.135336361,0.168515198,0.530410164,1.209074468,1.518426926,1.559512282) +data(1982,4607193353,0.133802494,0.135342954,0.168753641,0.536996737,1.176267133,1.47980709,1.52463367) +data(1983,4688582743,0.133377208,0.135246041,0.169576319,0.532088682,1.158420925,1.46002144,1.510279864) +data(1984,4767669177,0.133030663,0.135364454,0.170242063,0.54694641,1.180279911,1.506703536,1.566412047) +data(1985,4849860549,0.132610473,0.135051242,0.169658748,0.552747513,1.171095757,1.504285752,1.573424331) +data(1986,4934211409,0.131291387,0.133685377,0.168393392,0.554194404,1.186400652,1.520044231,1.593296333) +data(1987,5021085089,0.129951317,0.132539382,0.166722644,0.554231496,1.181208808,1.524791298,1.603295671) +data(1988,5108736553,0.128637242,0.13125772,0.166140318,0.556210491,1.195203161,1.549641815,1.633219996) +data(1989,5195979089,0.127377522,0.13079373,0.164881748,0.553926742,1.193159265,1.553390392,1.638232703) +data(1990,5284252039,0.126134805,0.129737215,0.164632138,0.553384674,1.190735096,1.553386431,1.640350219) +data(1991,5367488662,0.125428663,0.12928236,0.164254982,0.528423389,1.154980396,1.516498613,1.613399159) +data(1992,5452187873,0.124710625,0.128643771,0.163153115,0.518552304,1.13735672,1.494240768,1.590566106) +data(1993,5534418049,0.12406988,0.128046593,0.163990775,0.50470235,1.119339298,1.477198192,1.575200738) +data(1994,5614530098,0.123494469,0.127690239,0.163473418,0.506216459,1.12531413,1.481458633,1.580083078) +data(1995,5695823105,0.122909758,0.127213893,0.164248122,0.510641048,1.135855904,1.49167459,1.592774524) +data(1996,5776327747,0.12216812,0.12649691,0.163557636,0.510522671,1.141850345,1.503121808,1.606488473) +data(1997,5854841500,0.121488167,0.12619452,0.163583023,0.524945344,1.167177534,1.523679854,1.624760285) +data(1998,5932024858,0.120853308,0.125593429,0.162567495,0.521014085,1.167330383,1.52595967,1.627688406) +data(1999,6008646651,0.120245994,0.125081498,0.162173341,0.512693203,1.14325022,1.505666716,1.609442579) +data(2000,6084703879,0.119665076,0.124729832,0.16178992,0.513011266,1.158715327,1.529969497,1.634878653) +data(2001,6160890093,0.119894056,0.125258541,0.161095098,0.524198822,1.1611659,1.535602425,1.642047723) +data(2002,6237154134,0.118903979,0.124921559,0.160784753,0.529942594,1.153921617,1.530689162,1.637033401) +data(2003,6313942570,0.117913902,0.124642773,0.160192176,0.546832827,1.182503339,1.566938847,1.670839416) +data(2004,6390636309,0.116923825,0.12432827,0.161759107,0.565673251,1.221114221,1.610936278,1.717713694) +data(2005,6467431499,0.115933748,0.124259776,0.162887647,0.604148825,1.263290753,1.659620623,1.765386482) +data(2006,6545218993,0.114943672,0.124695239,0.164252513,0.623509498,1.274460793,1.680457898,1.786351327) +data(2007,6623523655,0.113953595,0.125629532,0.165251003,0.637952129,1.279256584,1.68820381,1.790810594) +data(2008,6702159402,0.112963518,0.127142703,0.167940953,0.64989848,1.292105043,1.710278853,1.811269586) +data(2009,6780833881,0.111973441,0.127858368,0.168866486,0.654393109,1.282816573,1.686869485,1.785251313) +data(2010,6858584755,0.110983364,0.12921584,0.172117414,0.680609275,1.328410794,1.756431211,1.856334479) +data(2011,6935999491,0.109993287,0.130385385,0.173636892,0.704216284,1.348176864,1.785673581,1.880255695) +data(2012,7013871313,0.10900321,0.130975574,0.175672274,0.688388925,1.341250864,1.785302272,1.872409847) +data(2013,7092128094,0.108013133,0.132480909,0.177353971,0.688378378,1.336238537,1.781754888,1.868322734) +data(2014,7169968185,0.107023056,0.133567224,0.177755023,0.681107631,1.336758872,1.78693987,1.874787234) +data(2015,7247892788,0,0,0,0,0,0,0) +data(2016,7325996709,0,0,0,0,0,0,0) +data(2017,7405107650,0,0,0,0,0,0,0) +nD0=nD-3 + +define yrdata { nyd +=1; yrd[nyd]=$1; ypop[nyd]=$2/1e9 } + +nyd = 0 +yrdata(1850,1169923623) +yrdata(1851,1177298999) +yrdata(1852,1184724181) +yrdata(1853,1192199527) +yrdata(1854,1199725401) +yrdata(1855,1207302168) +yrdata(1856,1214930197) +yrdata(1857,1222609858) +yrdata(1858,1230341525) +yrdata(1859,1238125576) +yrdata(1860,1245962390) +yrdata(1861,1253852349) +yrdata(1862,1261795840) +yrdata(1863,1269793250) +yrdata(1864,1277844972) +yrdata(1865,1285951399) +yrdata(1866,1294112930) +yrdata(1867,1302329966) +yrdata(1868,1310602910) +yrdata(1869,1318932168) +yrdata(1870,1327318152) +yrdata(1871,1335761275) +yrdata(1872,1344261952) +yrdata(1873,1352820603) +yrdata(1874,1361437653) +yrdata(1875,1370113525) +yrdata(1876,1379548537) +yrdata(1877,1389051752) +yrdata(1878,1398623687) +yrdata(1879,1408264863) +yrdata(1880,1417975804) +yrdata(1881,1427757042) +yrdata(1882,1437609109) +yrdata(1883,1447532543) +yrdata(1884,1457527886) +yrdata(1885,1467595685) +yrdata(1886,1477736490) +yrdata(1887,1487950857) +yrdata(1888,1498239345) +yrdata(1889,1508602518) +yrdata(1890,1519040944) +yrdata(1891,1529555197) +yrdata(1892,1540145854) +yrdata(1893,1550813497) +yrdata(1894,1561558712) +yrdata(1895,1572382092) +yrdata(1896,1583284233) +yrdata(1897,1594265734) +yrdata(1898,1605327202) +yrdata(1899,1616469247) +yrdata(1900,1630171098) +yrdata(1901,1644554295) +yrdata(1902,1659067684) +yrdata(1903,1673712471) +yrdata(1904,1688489874) +yrdata(1905,1703401122) +yrdata(1906,1718447458) +yrdata(1907,1733630134) +yrdata(1908,1748950415) +yrdata(1909,1764409579) +yrdata(1910,1780008913) +yrdata(1911,1795749721) +yrdata(1912,1811633314) +yrdata(1913,1827661021) +yrdata(1914,1843834178) +yrdata(1915,1860154139) +yrdata(1916,1876622267) +yrdata(1917,1893239939) +yrdata(1918,1910008546) +yrdata(1919,1926929491) +yrdata(1920,1944419089) +yrdata(1921,1962566145) +yrdata(1922,1980884876) +yrdata(1923,1999376931) +yrdata(1924,2018043972) +yrdata(1925,2023803913) +yrdata(1926,2043462180) +yrdata(1927,2063406322) +yrdata(1928,2082689730) +yrdata(1929,2103850414) +yrdata(1930,2124167500) +yrdata(1931,2143802732) +yrdata(1932,2164157870) +yrdata(1933,2184604692) +yrdata(1934,2205534997) +yrdata(1935,2226530597) +yrdata(1936,2247993326) +yrdata(1937,2268545035) +yrdata(1938,2290267593) +yrdata(1939,2312702889) +yrdata(1940,2350947590) +yrdata(1941,2373554827) +yrdata(1942,2396382640) +yrdata(1943,2419433211) +yrdata(1944,2442708748) +yrdata(1945,2466211477) +yrdata(1946,2489943650) +yrdata(1947,2513907539) +yrdata(1948,2538105439) +yrdata(1949,2562539670) +yrdata(1950,2579434878) +yrdata(1951,2653954580) +yrdata(1952,2692712961) +yrdata(1953,2732388944) +yrdata(1954,2772909569) +yrdata(1955,2814390135) +yrdata(1956,2856675848) +yrdata(1957,2899864004) +yrdata(1958,2943689748) +yrdata(1959,2987555529) +yrdata(1960,3030709021) +yrdata(1961,3090453463) +yrdata(1962,3137151355) +yrdata(1963,3211786601) +yrdata(1964,3270671214) +yrdata(1965,3330055803) +yrdata(1966,3401169329) +yrdata(1967,3463250974) +yrdata(1968,3526647458) +yrdata(1969,3591511933) +yrdata(1970,3657420066) +yrdata(1971,3724116214) +yrdata(1972,3791497136) +yrdata(1973,3859732004) +yrdata(1974,3928723212) +yrdata(1975,3998320921) +yrdata(1976,4080634693) +yrdata(1977,4156349026) +yrdata(1978,4233151108) +yrdata(1979,4311785729) +yrdata(1980,4391777096) +yrdata(1981,4472736872) +yrdata(1982,4555816222) +yrdata(1983,4640588050) +yrdata(1984,4726272158) +yrdata(1985,4813567478) +yrdata(1986,4902566593) +yrdata(1987,4985904892) +yrdata(1988,5070443631) +yrdata(1989,5156030340) +yrdata(1990,5219191372) +yrdata(1991,5304659362) +yrdata(1992,5390911229) +yrdata(1993,5477320137) +yrdata(1994,5564356643) +yrdata(1995,5652711036) +yrdata(1996,5738516173) +yrdata(1997,5824945702) +yrdata(1998,5912061676) +yrdata(1999,5999735497) +yrdata(2000,6088144560) +yrdata(2001,6173932167) +yrdata(2002,6250016823) +yrdata(2003,6326520742) +yrdata(2004,6403805522) +yrdata(2005,6481944062) +yrdata(2006,6525559210) +yrdata(2007,6602274812) +yrdata(2008,6789771253) +yrdata(2009,6873741054) +yrdata(2010,6958169159) +yrdata(2011,7043008586) +yrdata(2012,7128176935) +yrdata(2013,7213426452) +yrdata(2014,7298453033) +yrdata(2015,7383008820) +yrdata(2016,7466964280) +yrdata(2017,7550262101) + + +thinlines_ +Left: line from dtop(yearmin,tonsmin) to dtop(yearmin,tonsmax) + htic = 8pt__ +# htic = maxy + vtic = 13pt__/2 +# vtic = maxy + s_box(0) at dtop(yearmin,tonsmin) rjust above + for y=0.2 to 2 by 0.2 do { + move to dtop(yearmin,y) + if y<2 then {{ line right htic }} + s_box("%g",y) rjust } + rs_box(`Tonnes of oil equivalent per capita') with .e at Left-(0.3,0) + +Right: line from dtop(yearmax,tonsmin) to dtop(yearmax,tonsmax) + for p=0 to popmax do { + move to ptop(yearmax,p) + if p>0 && p<popmax then {{ line left htic }} + s_box("%g",p) ljust } + rs_box(`World population (billions)') with .w at Right+(0.2,0) + +Bot: line from Left.start to Right.start + for t=yearmin+10 to yearmax-10 by 10 do { + line up vtic from dtop(t,tonsmin) } + for t=yearmin to yearmax by 50 do { + s_box("%g",t) at dtop(t,tonsmin) below } + s_box(Year) at Bot+(0,-0.15) below + +Top: line from Left.end to Right.end + +thicklines_ + +# Population to 2017 +linethick_(2.5) +#Population: \ +# spline ctension_ dotted 1.5pt__ from ptop(yr[1],pop[1]) to ptop(yr[2],pop[2]) +# for y=3 to nD do { continue to ptop(yr[y],pop[y]) } + +#linethick_(0.6) +# arrow <- from last spline.end left 1.25 chop 3pt__ chop 0 +# s_box(`577\,\% of 1850 population') rjust +# arrow <- from Population.end left 1.25 chop 3pt__ chop 0 +# s_box(`577\,\% of 1850 population') rjust + +# nPopulation to 2017 +NPopulation: \ + spline ctension_ dotted 1.5pt__ from ptop(yrd[1],ypop[1]) \ + to ptop(yrd[2],ypop[2]) + for y=3 to nyd by 10 do { continue to ptop(yrd[y],ypop[y]) } + for yy=y-10+1 to nyd do { continue to ptop(yrd[yy],ypop[yy]) } + +thicklines_ +# Wood + spline ctension_ from dtop(yr[1],wood[1]) to dtop(yr[2],wood[2]) + for y=3 to nD0 do { continue to dtop(yr[y],wood[y]) } + +# Other + spline ctension_ from dtop(yr[1],other[1]) to dtop(yr[2],other[2]) + for y=3 to nD0 do { continue to dtop(yr[y],other[y]) } + +# Hydro + spline ctension_ from dtop(yr[1],hydro[1]) to dtop(yr[2],hydro[2]) + for y=3 to nD0 do { continue to dtop(yr[y],hydro[y]) } + +# Coal + spline ctension_ from dtop(yr[1],coal[1]) to dtop(yr[2],coal[2]) + for y=3 to nD0 do { continue to dtop(yr[y],coal[y]) } + +# Oil + spline ctension_ from dtop(yr[1],oil[1]) to dtop(yr[2],oil[2]) + for y=3 to nD0 do { continue to dtop(yr[y],oil[y]) } + +# Gas + spline ctension_ from dtop(yr[1],gas[1]) to dtop(yr[2],gas[2]) + for y=3 to nD0 do { continue to dtop(yr[y],gas[y]) } + +# Total +linethick_(2.5) +Total: \ + spline ctension_ from dtop(yr[1],nuclear[1]) to dtop(yr[2],nuclear[2]) + for y=3 to nD0 do { continue to dtop(yr[y],nuclear[y]) } + +thicklines_ + +#f_box(invis fill_(1) with .s at dtop(2000,0)+(0,2pt__),Wood) +Cl: s_box(Coal) at dtop(2000,0.36+3pt__) + s_box(Oil) at dtop(2000,0.9) + s_box(Gas) at dtop(2000,1.41) + s_box(Wood) at dtop(1889,0.15) + define(`text_ang',50) + rs_box(Population) at dtop(1975,0.9) + define(`text_ang',90) + +brpos = 2016 +Q:s_box(`$\left.\vbox to 1.50in{}\right\}$') with .w at dtop(brpos,1.04) + Label: rs_box(`\shortstack{90\,\%\\ nonrenewable}') with .w at Q.e + + s_box(`$\left.\vbox to 0.2in{}\right\}$') with .w at dtop(brpos+0.5,0.1) + + rs_box(`\shortstack[l]{10\,\%\\ renewable}') \ + with .sw at (Label.w,dtop(brpos,0.05)) + + linethick_(0.6) + arrow <- from dtop(1998,1.55) left 0.15 up 0.2 + s_box(Nuclear) above + + arrow <- from dtop(1960,1.09) left 0.5 + s_box(Total energy consumption) rjust + + spline ctension_ <- \ + from dtop(2014,1.89) left 0.5 up 0.2 then left 0.5 down 0.2 + s_box(`680\,\% of 1850 energy consumption') rjust + +H: s_box(Hydro) with .w at (Cl.w.x,Cl.c.y-17pt__) +R: dtop(yr[nD0]-2,0.16) + spline from H.e+(2pt__,0) to (R.x+0.11,H.y) then to (R.x+0.11,R.y) \ + then to R -> + + spline <- from dtop(yr[nD0]-1,0.12) left 0.2 up 0.1 then left 0.55 up 0.05 + s_box(Other renewables) with .b at Here+(-0.4,2pt__) + +# arrow <- from Population.end left 1.25 chop 3pt__ chop 0 +# s_box(`577\,\% of 1850 population') rjust +# arrow <- from NPopulation.end left 1.25 chop 3pt__ chop 0 +Q: NPopulation.end + (-1.25,-0.1) + spline ctension_ <- \ + from NPopulation.end+(-3pt__,0) left 0.3 down 0.1 then left 0.45 then to Q + s_box(`"%g\,\%% of 1850 population"',round_(ypop[nyd]/ypop[1]*10)*10) rjust + +# average growth rates per decade +# print ((ypop[nyd]/ypop[1])^(1/((yrd[nyd]-1850)/10))-1)*100 +# print ((pop[nD]/pop[1])^(1/((yr[nD]-1850)/10))-1)*100 +# print ((nuclear[nD0]/nuclear[1])^(1/((yr[nD0]-1850)/10))-1)*100 + +] +# maxx +#print maxpswid-(last [].wid-maxx) + +#print (last [].wid,last [].ht) +showbox_ +} +.PE diff --git a/graphics/circuit_macros/examples/Diodes.m4 b/graphics/circuit_macros/examples/Diodes.m4 index 360d8e9d9e..d08a032253 100644 --- a/graphics/circuit_macros/examples/Diodes.m4 +++ b/graphics/circuit_macros/examples/Diodes.m4 @@ -1,7 +1,9 @@ .PS -# `Diodes.m4' +# Diodes.m4 cct_init + movewid = 2pt__ + { {diode ; move ; "`{\tt diode}'" ljust} move down 0.2; right_ {diode(,S) ; move ; "`{\tt diode(,S)}'" ljust} @@ -15,6 +17,8 @@ movewid = 2pt__ {diode(,B) ; move ; "`{\tt diode(,B)}'" ljust} move down 0.2; right_ {diode(,G) ; move ; "`{\tt diode(,G)}'" ljust} + move down 0.2; right_ + {diode(,D) ; move ; "`{\tt diode(,D)}'" ljust} } move right_ 2.0 @@ -30,11 +34,15 @@ movewid = 2pt__ move down 0.2; right_ {diode(,Sh) ; move ; "`{\tt diode(,Sh)}'" ljust} move down 0.2; right_ - {diode(,D) ; move ; "`{\tt diode(,D)}'" ljust} + {diode(,M) ; move ; "`{\tt diode(,M)}'" ljust} + move down 0.2; right_ + {diode(,MK) ; move ; "`{\tt diode(,MK)}'" ljust} } move right_ 2.0 { {diode(,Z,RE) ; move ; "`{\tt diode(,Z,RE)}'" ljust} + move down 0.30; right_ + {diode(,U) ; move ; "`{\tt diode(,U)}'" ljust} move down 0.25; right_ {diode(,T) ; move ; "`{\tt diode(,T)}'" ljust} move down 0.30; right_ diff --git a/graphics/circuit_macros/examples/EEP.m4 b/graphics/circuit_macros/examples/EEP.m4 new file mode 100644 index 0000000000..e4130a83a3 --- /dev/null +++ b/graphics/circuit_macros/examples/EEP.m4 @@ -0,0 +1,112 @@ +.PS +# EEP.m4 +cct_init +include(libSLD.m4) + +command "{\sf" + +Pic1: [ + T: dot + switch(up_ elen_); {"Public supply" above} + Bus1: sl_busbar(right_ 5*dimen_,6,port=D) with .c at T + {"{\scriptsize 20$\,$kV}" at Bus1.Start above ljust} + S1: switch(from Bus1.P1-(0,elen_) up_ elen_) + S2: switch(from Bus1.P2-(0,elen_) up_ elen_) + TRF1: sl_transformer(from Bus1.P3 down_ elen_,type=S,,,Delta,Y) + arrow down_ dimen_/3 + TRF2: sl_transformer(from Bus1.P4 down_ elen_,type=S,,,Delta,Y) + arrow down_ dimen_/3 + TRF3: sl_transformer(from Bus1.P5 down_ elen_,type=S,,,Delta,Y) + arrow down_ dimen_/3 + S3: switch(from Bus1.P6-(0,elen_) up_ elen_) + Bus2: sl_busbar(right_ 1.5*dimen_,3,port=D) with .c at Bus1.P1+(0,-dimen_*3) + {"{\scriptsize 20$\,$kV}" at Bus2.Start above ljust} + {"{\scriptsize 1.25$\,$MVA}" at Bus2.P2 below} + S4: switch(from Bus2.P2 to S1.start) + TRF4: sl_transformer(from Bus2.P1 down_ elen_,type=S,,,Delta,Y) + S4: switch(from Bus2.P3+(0,-elen_) to Bus2.P3) +] + +command "\definecolor{cornflowerblue}{rgb}{0.39, 0.58, 0.93}" +command "\definecolor{goldenrod}{rgb}{0.85, 0.65, 0.13}" +command "\definecolor{colorA}{rgb}{0.79, 0.59, 0.57}" +command "\definecolor{colorB}{rgb}{0.2, 0.8, 0.2}" +command "\definecolor{colorC}{rgb}{0.21, 0.47, 0.86}" +command "\definecolor{colorD}{rgb}{0.2, 0.6, 0.8}" +command "\definecolor{colorE}{rgb}{0.2, 0.63, 0.8}" +command "\definecolor{colorF}{rgb}{0.78, 0.36, 0.3}" +Pic2: [ +# https://tex.stackexchange.com/questions/597643/draw-a-power-system-network + B1: sl_busbar(up_ dimen_*4/3,3) + sl_transformer(right_ 2*dimen_ from last [].P2, + type=S;body=shaded "lightgray"); variable(,,,dimen_*3/2) + B2: sl_busbar(up_ dimen_*4/3,3) + { line left_ dimen_/2 from B2.P1 + C1: capacitor(down_ dimen_/2); ground(,T) } + line right_ dimen_/2 + { line to (Here,C1.start); C2: capacitor(to (Here,C1.end)); ground(,T) } + ebox(right_ 3.5*dimen_, 2.5*dimen_, dimen_/5, 0.75) + { line to (Here,C1.start); C3: capacitor(to (Here,C1.end)); ground(,T) } + line right_ dimen_/2 + B3: sl_busbar(up_ dimen_*4.5,6) + line right_ dimen_*3/4 from B3.P1; box wid dimen_*3 ht dimen_*.6 \ + shaded "goldenrod" "Static Load" + line right_ dimen_*3/4 from B3.P2; box wid dimen_*3 ht dimen_*.6 \ + shaded "colorA" "Electronic Load" + sl_disk(right_ dimen_ from B3.P3, + text="A/C";circle=shaded "colorB";diam=dimen_*3/4) + sl_disk(right_ dimen_ from B3.P4, + text="M";circle=shaded "colorC";diam=dimen_*3/4) + sl_disk(right_ dimen_ from B3.P5, + text="M";circle=shaded "colorD";diam=dimen_*3/4) + sl_disk(right_ dimen_ from B3.P6, + text="M";circle=shaded "colorE";diam=dimen_*3/4) + sl_disk(left_ dimen_ from 1/2 between B3.P1 and B3.P2, + text="\scriptsize DER\_A"; circle=shaded "colorF";diam=dimen_*3/4) +] with .nw at last [].sw + (100bp__,120bp__) + +Pic3: [ +define(`shadedb',shaded "cornflowerblue") +Loopover_(`LR', # loop to take advantage of symmetry + `define(`opposite',`ifelse(LR,left,right,left)')dnl + ifelse(LR,left,L,R)`'side: [ + sl_generator(LR dimen_/2,type=B;name=G1;circle=shadedb,box=shadedb) + { move from G1 opposite last circle.rad*3/2 down_ last circle.rad + ifelse(LR,left,`Delta',`Wye')symbol(,size=sourcerad_*2/3) } + T1: sl_transformer(opposite dimen_*3/2,name=Tx) + Bus1: sl_busbar(up_ dimen_*3/2,3,) with .P2 at Here + Br1: sl_breaker(from Bus1.P3 opposite elen_,box=shadedb) + line opposite dimen_*4/3 + Br2: sl_breaker(from Bus1.P1 opposite elen_,box=shadedb) + Br3: sl_breaker(down_ dimen_,box=shadedb) + Bus2: sl_busbar(opposite dimen_,3) with .P2 at Here + T2: sl_transformer(down_ dimen_ from Bus2.P2,name=X2) + sl_disk(down_ dimen_/2,type=B;text="SM";name=SM1;circle=shadedb,box=shadedb) + { move from last circle opposite sourcerad_*3 + Wyesymbol(,type=G`'ifelse(LR,right,L);size=sourcerad_*2/3) } + ]', + left,right) + "Bus 1" at Lside.Bus1.top above + "Bus 2" at Rside.Bus1.top above + "Bus 3" at Lside.Bus2.w above + "Bus 4" at Rside.Bus2.e above + "TL$_1$ 50$\,$km 69$\,$kV" at 1/2 between Lside.Br1 and Rside.Br1 above + "TL$_2$ 30$\,$km" ljust "69$\,$kV" ljust at Lside.Br2.end + (-18bp__,12bp__) + "TL$_2$ 20$\,$km" ljust "69$\,$kV" ljust at Rside.Br2.end + (-18bp__,12bp__) + "G$_1$ 50$\,$MVA" ljust "13.8$\,$kV" ljust at Lside.G1.w+(-25bp__,-32bp__) + "G$_2$ 30$\,$MVA" ljust "13.8$\,$kV" ljust at Rside.G1.w+(10bp__,-28bp__) + "T$_1$ 50$\,$MVA" "13.8/69$\,$kV $\Delta$/Y" \ + at Lside.Tx.s+(-2bp__,-25bp__) below + "T$_2$ 30$\,$MVA" "69/13.8$\,$kV Y/$\Delta$" \ + at Rside.Tx.s+(2bp__,-27bp__) below + "T$_3$ 50$\,$MVA" rjust "13.8/69$\,$kV Y/$\Delta$" rjust \ + at Lside.X2.w+(-4bp__,0) + "T$_4$ 20$\,$MVA" ljust "69/6.9$\,$kV Y/$\Delta$" ljust \ + at Rside.X2.e+(4bp__,0) + "SM$_1$ 30$\,$MVA" rjust "13.8$\,$kV" rjust at Lside.SM1.w+(-4bp__,0) + "SM$_2$ 20$\,$MVA" ljust "6.9$\,$kV" ljust at Rside.SM1.e+( 4bp__,0) +] with .nw at (Pic1.w,last [].sw + (0,-15bp__)) + + command "}%" + +.PE diff --git a/graphics/circuit_macros/examples/Escher.m4 b/graphics/circuit_macros/examples/Escher.m4 index f8bae7f728..fad743d028 100644 --- a/graphics/circuit_macros/examples/Escher.m4 +++ b/graphics/circuit_macros/examples/Escher.m4 @@ -2,6 +2,8 @@ # Escher.m4 # https://tex.stackexchange.com/questions/129274/showcase-of-optical-illusions-made-with-tex-latex-luatex-context threeD_init +[] +ifelse(1,1,` [ u=1/2.54 # unit size; could use scale for this @@ -107,82 +109,67 @@ define dorgb { gg = $2 to last line.end-UX*(weststeps+1) then to last line.end \ then to proj(eaststeps+1,0,-f) then to proj(eaststeps+1,0,eb*f) ] +') ifelse(1,1,` +define(`DPL',`(project(`$1',`$2',`$3'))') +define(`ISL',` + S1: `$2'; E1: `$2' + `$3' + S2: `$4'; E2: `$4' + `$5' + `$1': line from S2 to intersect_(S1,E1,S2,E2) ') + [ - setview(-45,20) - bwid = 2.8 - bh = 1.5 bdp = 1.8 - bth = 0.3 - A: Project(0,0,0) - AA: A+Project(bth,bth,-bth) - B: Project(0,bwid,0) - BB: B+Project(bth,-bth,-bth) - C: Project(bdp,bwid,0) - D: Project(bdp,0,0) - E: Project(0,0,-bh) - F: Project(bdp,0,-bh) - G: Project(bdp,bwid,-bh) - H: B + Project(0,0,-bh) - - line from A to B then to C then to D then to A then to E then to F \ - then to G then to H then to E - line from C to G - line from A+Project(bth,bth,0) to B+Project(bth,-bth,0) \ - then to C+Project(-bth,-bth,0) - L1: line to D+Project(-bth,bth,0) - L2: line to A+Project(bth,bth,0) - L4: line from E+Project(bth,bth,0) to H+Project(bth,-bth,0) - L3: line to C+Project(-bth,-bth,-bh) - line to F+Project(-bth,bth,0) then to A+Project(bth,bth,-bh) - - L5: line from D+Project(-bth,0,-bth) to A+Project(bth,0,-bth) - line to E+Project(bth,0,bth) - L6: line to Here+Project(0,bwid-2*bth,0) - L7: line from D+Project(0,bth,-bth) to C+Project(0,-bth,-bth) - line to G+Project(0,-bth,bth) - L8: line to Here+Project(-bdp+2*bth,0,0) - Tmp: line invis from L8.start+Project(-bth,0,0) up bh - line from Tmp.start to Intersect_(Tmp,L7) - Tmp: line invis from L8.end up bh - line from L8.end to Intersect_(Tmp,L7) - line from Intersect_(Tmp,L1) to BB+Project(bth,0,0) - Tmp: line invis to Here+Project(bdp,0,0) - line from Tmp.start to Intersect_(Tmp,L1) - - Tmp: line invis from H up bh - line from H to Intersect_(Tmp,L7) - line from Intersect_(Tmp,L1) to B+Project(bth,-bth,0) - - Tmp: line invis from AA to AA+Project(0,bwid,0) - Tmp2: line invis up bh from L6.end - line from Intersect_(Tmp,L2) to Intersect_(Tmp2,Tmp) \ - then to Intersect_(Tmp2,L1) - line from L6.end to Intersect_(Tmp2,L7) - - Tmp: line invis down bh from AA - line from Intersect_(Tmp,L6) to Intersect_(Tmp,L5) - - Tmp: line invis down bh from D - line from D to Intersect_(Tmp,L6) - line from Intersect_(Tmp,L4) to F+Project(-bth,bth,0) - - Tmp: line invis from L5.start to L5.start+Project(0,0,-bh) - move to E+Project(0,2*bth,0) - Tmp2: line invis to Here+Project(bdp,0,0) - line from L5.start to Intersect_(Tmp,L6) - line from Intersect_(Tmp,L4) to Intersect_(Tmp,Tmp2) \ - then to Intersect_(Tmp2,L4) - - Tmp: line invis from L7.start to L7.start+Project(0,0,-(bh-bth)) - line from L7.start to Intersect_(Tmp,L6) - - move to G+Project(-2*bth,0,0) - Tmp2: line invis to Here+Project(0,-bwid,0) - line from Intersect_(Tmp2,L3) to Intersect_(Tmp,Tmp2) - line from Intersect_(Tmp,L4) to Intersect_(Tmp2,Tmp) - + bwd = 2.8 + bht = 1.5 + bth = bwd/10 + setview(-45,20,0) + + L1: line from DPL(0,0,0) to DPL(0,0,bht) \ + then to DPL(0,bwd,bht) \ + then to DPL(bdp,bwd,bht) \ + then to DPL(bdp,bwd,0) \ + then to DPL(bdp,0,0) \ + then to DPL(0,0,0) + L2: line from DPL(bth,bth,bht) to DPL(bth,bwd-bth,bht) \ + then to DPL(bdp-bth,bwd-bth,bht) \ + then to DPL(bdp-bth,bth,bht) \ + then to DPL(bth,bth,bht) + L3: line from DPL(bth,bth,0) to DPL(bth,bwd-bth,0) \ + then to DPL(bdp-bth,bwd-bth,0) \ + then to DPL(bdp-bth,bth,0) \ + then to DPL(bth,bth,0) + L4: line from DPL(bdp,bth,bht-bth) to DPL(bdp,bwd-bth,bht-bth) \ + then to DPL(bdp,bwd-bth,bth) \ + then to DPL(bth+bth,bwd-bth,bth) + L5: line from DPL(bdp-bth,0,bht-bth) to DPL(bth,0,bht-bth) \ + then to DPL(bth,0,bth) \ + then to DPL(bth,bwd-bth-bth,bth) + L6: line from DPL(0,0,bht) to DPL(bdp,0,bht) \ + then to DPL(bdp,bwd,bht) + L7: line from DPL(0,0,0) to DPL(0,bwd,0) \ + then to DPL(bdp,bwd,0) + ISL(L8,L4.start,UPy_,L4.end,UPz_) + ISL(L9,L4.start,UPy_,DPL(0,bwd,0),UPz_) + ISL(L10,L4.start,UPy_,L5.end,UPz_) + ISL(L11,L5.end,UPy_,L4.start,UPz_) + ISL(L12,L5.end,UPy_,DPL(bdp,0,bht),UPz_) + ISL(L13,L5.end,UPy_,L5.start,UPz_) + ISL(L14,DPL(bdp-bth,bth,bht),UPy_,DPL(bth,bwd-bth-bth,bht-bth),UPz_) + ISL(L15,L2.start,UPx_,DPL(bth,bwd-bth-bth,bht-bth),UPy_) + ISL(L16,DPL(bdp-bth,bth,bht),UPy_,DPL(bth,bwd-bth,bht),UPz_) + ISL(L17,DPL(bdp-bth,bth,bht),UPy_,DPL(bth+bth,bwd-bth,bht-bth),UPz_) + ISL(L18,DPL(bdp-bth,bth,bht),UPy_,DPL(bth+bth,bwd-bth,bht-bth),UPx_) + ISL(L19,L3.start,UPy_,L5.start+DPL(0,0,-bht+bth+bth),UPx_) + ISL(L20,L3.start,UPy_,L5.start+DPL(0,0,-bht+bth+bth),UPz_) + ISL(L21,L3.start,UPy_,DPL(bdp-bth,bth,0),UPz_) + ISL(L22,L3.start,UPy_,L4.start+DPL(0,0,-bht+bth+bth),UPz_) + ISL(L23,DPL(bth,bwd-bth,0),UPx_,L4.start+DPL(0,0,-bht+bth+bth),UPy_) + ISL(L24,L5.start,UPx_,DPL(bth,bth,bth),UPz_) + ISL(L25,L4.start,UPy_,DPL(bdp-bth,bwd-bth,bth),UPz_) + +ifelse(0,1,`for i=1 to 7 do { exec sprintf("\"L%g.s\" at L%g.start",i,i) } + for i=8 to 10 do { exec sprintf("\"L%g\" at L%g",i,i) }') ] with .sw at last [].se+(0.2,0) ') .PE diff --git a/graphics/circuit_macros/examples/Eye.m4 b/graphics/circuit_macros/examples/Eye.m4 new file mode 100644 index 0000000000..50a62c389e --- /dev/null +++ b/graphics/circuit_macros/examples/Eye.m4 @@ -0,0 +1,55 @@ +.PS +# Eye.m4 +gen_init + +define(`eye',`[ u = `$1'; v = 0.47*u; w = 0.25*u + shade(1, + arc thick 0 from (u/2,0) to (-u/2,0) with .c at (0,-u/3) + arc thick 0 to (u/2,0) with .c at (0,u/3) ) + circle diam v fill_(0.25) at (0,0) + circle diam w fill_(0) at (0,0) + circle thick 0 diam last circle.diam/2 fill_(1) at last circle.nw + circle diam last circle.diam-lthick at last circle outlined graystring(0.9) + ] ') + + skale = 2/3 + Bx: box wid 11*skale ht 8.5*skale fill_(0) at (0,0) + ane = atan2(Bx.ht,Bx.wid)*rtod_ + d[5] = 0.92*Bx.ht + d[4] = 0.78*Bx.ht + d[3] = 0.62*Bx.ht + d[2] = 0.40*Bx.ht + d[1] = 0.25*Bx.ht + da = 1 + dax = 360/64 + C[0]: Bx.se; C[1]: Bx.nw + for a=-int(ane/dax)*dax to 180-ane by dax do { + T1: (Rect_(1,a+da)); T1: intersect_(Bx.ne,C[(a>ane)],Bx,T1) + T2: (Rect_(1,a)); T2: intersect_(Bx.ne,C[(a>ane)],Bx,T2) + line outlined "white" shaded "white" from Bx to T1 then to T2 then to Bx + line outlined "white" shaded "white" from Bx to T1*(-1) \ + then to T2*(-1) then to Bx + } + for i=5 to 2 by -1 do { + C[i]: circle diam d[i] fill_(0) at Bx + for a=0 to 359 by dax do { + T1: (Rect_(d[i]/2,a)) + T2: (Rect_(d[i]/2,a-da*2)) + shade(1, + arc cw thick 0 from T1 to T2 with .c at Bx + spline 0.55 thick 0 to 0.8 between Bx and T2 \ + then to (Rect_(d[i]/4,a+30)) + arc cw thick 0 to (Rect_(d[i]/4,a+32)) with .c at Bx + spline 0.55 thick 0 to 0.8 between Bx and T1 then to T1 ) + } + } + C[1]: circle thick 2 diam d[1] at Bx fill_(0.1) + eye(d[1]-4bp__) at (0,0) + for a=0 to 359 by dax do { + T1: (Rect_(d[1]/2-1bp__,a)) + T2: (Rect_(d[1]/2-1bp__,a+dax/2)) + line thick 0 from T1 to T2 then to 0.5 between Bx and T2 \ + then to 0.5 between Bx and T1 then to T1 shaded "white" #outlined "white" + } + +.PE diff --git a/graphics/circuit_macros/examples/Flow.m4 b/graphics/circuit_macros/examples/Flow.m4 index f0f8a842f0..f117c082c3 100644 --- a/graphics/circuit_macros/examples/Flow.m4 +++ b/graphics/circuit_macros/examples/Flow.m4 @@ -64,7 +64,7 @@ Repeatuntil: Frepeatuntil("$n \geq 5$",,,Fbox("Task"), "\sl .N" at Repeatuntil.N rjust above; "\sl .S" at Repeatuntil.S rjust below "\sl .E" at Repeatuntil.E ljust; "\sl .W" at Repeatuntil.W rjust - "\tt F{}repeatuntil" below at Repeatuntil.se +(-0.0,0.2) + "\tt F{}repeatuntil" below at Repeatuntil.se +(-0.0,0.1) Ifthenelse: Fifthenelse("$A<B$",,, Fbox("False"), diff --git a/graphics/circuit_macros/examples/Geometry.m4 b/graphics/circuit_macros/examples/Geometry.m4 index 771f4a6b7c..b5a59a0f10 100644 --- a/graphics/circuit_macros/examples/Geometry.m4 +++ b/graphics/circuit_macros/examples/Geometry.m4 @@ -1,5 +1,6 @@ .PS # Geometry.m4 +# Some constructions from https://tex.stackexchange.com/ gen_init Fig1: [ ls = 2/3 # local scale @@ -91,4 +92,63 @@ define(`textsize',`\Large') ] with .nw at Fig1.sw+(0.2,-0.3) +Fig4: [ + +# FourbarSVG.m4 +# https://tex.stackexchange.com/questions/563831/how-to-draw-four-bar-linkage-with-center-of-mass +ls = 1/25.4 # local scale + + a = 18*ls + b = 73*ls + c = 47*ls + d = 72*ls + A0: Here + B0: A0+(d,0) + circlerad = 1*ls + +define(`pivot',`[ + C: circle + line down_ 4*ls from C+(2*ls,0) + arc from last line.start to C+(-2*ls,0) with .c at C + line down_ 4*ls + B: line thick 1.6 right 7*ls with .c at (C,Here) + thinlines_ + sep = 0.9*ls + nhash = B.len/sep + for i=0 to nhash do { line down sep left sep from B.end-(i/nhash*B.len,0) } + thicklines_ + ]') + + pivot with .C at A0; "$A_0$" at A0-(5,0)*ls + circle dashed rad a at A0 + pivot with .C at B0; "$B_0$" at B0-(5,0)*ls + "$d = A_0B_0$" at 0.5<A0,B0> + + B1: Cintersect(A0,a+b,B0,c) + B2: Cintersect(A0,b-a,B0,c) + arc dashed from B1 to B2 with .c at B0 + + A0B1: line thick 1.6 from A0 to B1 chop 2*ls chop 0 + line thick 1.6 from B0 to B1 chop 2*ls chop 0 "$c$" ljust + circle fill_(1) at B1; "$B_1$" wid 3*ls at B1+(5,0)*ls + A1: circle fill_(1) at LCintersect(A0B1,A0,a,R) + "$A_1$" at A1+(5,0)*ls + + A2: b/(b-a) between B2 and A0; "$a$" at 0.4<A2,A0> above rjust + "$b$" at 0.4<A1,B1> above rjust + A2B2: line thick 1.6 from A2 to B2 + line thick 1.6 from B0 to B2 chop 2*ls chop 0 + circle fill_(1) at B2; "$B_2$" at B2+(5,0)*ls + circle fill_(1) at A2; "$A_2$" at A2+(5,0)*ls + + thinlines_ + line from B0+(3*ls,0) right 4*ls + ArcAngle(Here,B0,B1,5*ls) ->; "$\psi_0$" at last arc.ne above ljust + ArcAngle(B1,B0,B2,8*ls) ->; "$\psi$" at last arc.n+(-3*ls,0) above + ArcAngle(A1,A0,B2,b*0.45) ->; "$\theta$" at last arc.start+(0,4*ls) + line from A0+(3*ls,0) right 8*ls + ArcAngle(Here,A0,B1,9*ls) ->; "$\theta_0$" at last arc.start+(2,2)*ls + + ] with .nw at Fig3.ne+(0.2,0.2) + .PE diff --git a/graphics/circuit_macros/examples/Lyap.m4 b/graphics/circuit_macros/examples/Lyap.m4 index 4bce1b1d37..e01d365fc0 100644 --- a/graphics/circuit_macros/examples/Lyap.m4 +++ b/graphics/circuit_macros/examples/Lyap.m4 @@ -20,7 +20,7 @@ h = 0.5 c = 1 # The projected ellipse is (x/q)^2 + y^2 = c. # The cost is v = c+h -define(`vs',``$2'*q*cos(`$1'),`$2'*sin(`$1')') +define(`vs',`(`$2')*q*cos(`$1'),(`$2')*sin(`$1')') define(`vp',`vs(`$1',`$2'),0') define(`vx',`sum3D(vp(`$1',`$2'),0,0,h+(`$2')^2)') @@ -133,7 +133,7 @@ ifpstricks(` fitcurve(X2,nx,dotted 0.025) fitcurve(X3,nx) fitcurve(X4,3,dotted 0.015) - arca(from X4[4] to X4[2],ccw,0.3,<-) + arca(from X4[4] to X4[3],ccw,0.3,<-) # Projected trajectory np = np-2 @@ -144,6 +144,7 @@ ifpstricks(` # Axes and vertical lines thinlines_ line from X1[0] to Xp[0] + line from X4[4] to Xp[np] arrow from Origin to Project(1.5,0,0) "$x_1$" rjust below arrow from Origin to Project(0,1.5,0) @@ -153,7 +154,7 @@ arrow from F[n/2] to Project(0,0,2) "$v(X)$" ljust "`${0}$'" at Origin+(0,1 pt__) below -"$\Omega$" at Project(0,0.9*c,0) above +"$\Omega$" at Project(0,0.9*c,0)+(0,3bp__) above "`$v(X) = c$'" at (Project(vp(100*dtor_,c)))+(2bp__,0) above ljust .PE diff --git a/graphics/circuit_macros/examples/Makefile b/graphics/circuit_macros/examples/Makefile index 8e32490d6d..55cf147dcc 100644 --- a/graphics/circuit_macros/examples/Makefile +++ b/graphics/circuit_macros/examples/Makefile @@ -58,15 +58,16 @@ PICS = \ ABlogix.tex Adder.tex Alogix.tex AmpTable.tex Antennas.tex \ Audio.tex Bip.tex Btree.tex Buttons.tex Byte.tex \ Capacitors.tex CanLogic.tex Chips.tex Conn.tex Connectors.tex \ - Contacts.tex Contact.tex control.tex Counting.tex Crossbar.tex Crow.tex \ + Contacts.tex Contact.tex control.tex Crossbar.tex Crow.tex \ csc.tex Csource.tex Decoder.tex \ - Demultiplexer.tex diamond.tex Dini.tex Diodes.tex Drive.tex Emarrows.tex \ + Demultiplexer.tex diamond.tex Dini.tex Diodes.tex Drive.tex \ + EEP.tex Emarrows.tex Escher.tex \ ex00.tex ex01.tex ex02.tex ex03.tex ex04.tex ex05.tex ex06.tex ex08.tex \ ex09.tex ex10.tex ex11.tex ex12.tex ex15.tex ex16.tex ex17.tex ex18.tex \ ex21.tex exp.tex fet.tex Flow.tex Fuses.tex GrayCode.tex graysurf.tex \ Grounds.tex Headers.tex Heathkit.tex \ I2L.tex Incleps.tex Inductors.tex Jack.tex \ - lcct.tex Lyap.tex Logic.tex Loglog.tex MC.tex Mixer.tex MoreTable.tex \ + lcct.tex Logic.tex Loglog.tex MC.tex Mixer.tex MoreTable.tex \ MotorControl.tex Multiplexer.tex \ NLG.tex NPDT.tex Nport.tex Opamp.tex Optoiso.tex \ Pconn.tex Plate.tex PushPull.tex pwrsupply.tex \ @@ -80,7 +81,7 @@ PICS = \ worm.tex Xform.tex XOR.tex # Files that have to be processed twice: -BOXDIMS = ex09.tex Crow.tex Incleps.tex Lyap.tex Loglog.tex Opamp.tex \ +BOXDIMS = ex09.tex Crow.tex Incleps.tex Loglog.tex Opamp.tex \ random.tex Ttree.tex Windings.tex ######################################################################### @@ -275,7 +276,7 @@ clean: rm -f fig*.tex $(PICS) *.roff *.int *.pic gpic.m4 test.tex xxx* *.fig rm -f *.dim *.bak rotate.ps tst.ps *.bbl *-pics.ps rm -f *.tfm *[0-9]pk *.png *.1 *.gif - rm -f F_* Version.tex *stackdump *.ico + rm -f F_* Version.tex *stackdump *.ico ./.[A-Za-z]* rm -rf distfile distfile.tar.gz mode.tex @printf "\n" # @if test -f distmakefile ; then make -f distmakefile clean ; fi diff --git a/graphics/circuit_macros/examples/README-examples b/graphics/circuit_macros/examples/README-examples index c74c92c274..1f37cf5f36 100644 --- a/graphics/circuit_macros/examples/README-examples +++ b/graphics/circuit_macros/examples/README-examples @@ -56,4 +56,4 @@ The xfig subdirectory contains the file xfig/xfiglib.fig, which contains elements in xfig 3.2 format produced by dpic for importing into xfig. SVG: Look in the svg directory for an experimental configuration file and -examples. +examples. Type "make" in the svg directory to see the examples. diff --git a/graphics/circuit_macros/examples/Stator.m4 b/graphics/circuit_macros/examples/Stator.m4 new file mode 100644 index 0000000000..9141d20bd4 --- /dev/null +++ b/graphics/circuit_macros/examples/Stator.m4 @@ -0,0 +1,53 @@ +.PS +# Stator.m4 +# https://tex.stackexchange.com/questions/612620/how-to-paint-inside-a-set-of-lines +gen_init + + outerwid = 5/2 + innerwid = 3.7/2 + nteeth = 32 + toothdepth = (innerwid/2)*(twopi_/nteeth) + statordepth = toothdepth*4 + viewangle = 30 + outershade = 0.9 + topshade = 0.8 + innershade = 0.6 + toothshade = 0.5 + + cv = cosd(viewangle) + sv = sind(viewangle) + define ang { ($1)/nteeth*twopi_ } + + T: (0,statordepth*cv) + Tc: (0,toothdepth*cv) + for i = 0 to nteeth/2 do { for j=1 to -1 by -2 do { # Shaded tooth walls + P: (cos(ang(i)+pi_/2)*j,sin(ang(i)+pi_/2)*sv)*outerwid/2 + Q: P*innerwid/outerwid + line from P to P+Tc then to Q+Tc then to Q then to P \ + shaded rgbstring(toothshade,toothshade,toothshade) } } + shade(innershade, # inner arc and teeth + E: ellipsearc(innerwid,innerwid*sv,pi_,0,0,cw) with .C at T + move to (innerwid/2,0) + toothht = toothdepth*cv + for i = 0 to nteeth/2 do { + line up toothht + ellipsearc(innerwid,innerwid*sv,ang(i),ang(i+1),0,ccw) with .Start at Here + move to last [].End + toothht = -toothht } ) + shade(outershade, # outer arc and teeth + E: ellipsearc(outerwid,outerwid*sv,0,pi_,0,cw) with .C at T + line down statordepth*cv from E.End + toothht = toothdepth*cv + for i = nteeth/2 to nteeth-1 do { + line up toothht + ellipsearc(outerwid,outerwid*sv,ang(i),ang(i+1),0,ccw) with .Start at Here + move to last [].End + toothht = -toothht } + line up statordepth*cv from E.Start-T ) + for r=innerwid to outerwid by lthick*2 do { # shade the top + ellipse wid r ht r*sv with .c at T \ + outlined rgbstring(topshade,topshade,topshade) } + ellipse wid outerwid ht outerwid*sv with .c at T + ellipse wid innerwid ht innerwid*sv with .c at T + +.PE diff --git a/graphics/circuit_macros/examples/Switches.m4 b/graphics/circuit_macros/examples/Switches.m4 index 46b3f9240d..3e599a39ef 100644 --- a/graphics/circuit_macros/examples/Switches.m4 +++ b/graphics/circuit_macros/examples/Switches.m4 @@ -2,130 +2,144 @@ # Switches.m4 cct_init -define(`Below',`at last [].s+(0,-10bp__)') +define(`Below',`at last [].s+(0,-(8 ifelse(`$1',,,+10*(`$1')))bp__)') movewid = 0.25 + # Row 1 right_; { - lswitch; {S:"\tt ls{}witch" Below} + lswitch; {"\tt ls{}witch" at last [].s Below} move right_ - lswitch(,,O); {"\tt (,{,}O)" at (last [],S)} + lswitch(,,O); {"\tt (,{,}O)" at last [].s Below} move right_ - lswitch(,,C); {"\tt (,{,}C)" at (last [],S)} + lswitch(,,C); {"\tt (,{,}C)" at last [].s Below} move right_ - lswitch(,,DA); {"\tt (,{,}DA)" at (last [],S)} + lswitch(,,DA); {"\tt (,{,}DA)" at last [].s Below} move right_ - lswitch(,,dDO); {"\tt (,{,}dDO)" at (last [],S)} + lswitch(,,dDO); {"\tt (,{,}dDO)" at last [].s Below} move right_ - lswitch(,,uDC); {"\tt (,{,}uDC)" at (last [],S)} + lswitch(,,uDC); {"\tt (,{,}uDC)" at last [].s Below} } # Row 2 - move down; right_; { - lswitch(,,K); {S:"\tt (,{,}K)" Below} + move down 0.4; right_; { + lswitch(,,K); {"\tt (,{,}K)" at last [].s Below} move right_ - lswitch(,,KD); {"\tt (,{,}KD)" at (last [],S)} + lswitch(,,KD); {"\tt (,{,}KD)" at last [].s Below} move right_ - lswitch(,,KOD); {"\tt (,{,}KOD)" at (last [],S)} + lswitch(,,KOD); {"\tt (,{,}KOD)" at last [].s Below} move right_ - lswitch(,,KCD); {"\tt (,{,}KCD)" at (last [],S)} + lswitch(,,KCD); {"\tt (,{,}KCD)" at last [].s Below} move right_ - bswitch; {"\tt `bswitch'" at (last [],S)} + bswitch; {"\tt `bswitch'" at last [].s Below} move right_ - bswitch(,,C); {"\tt (,{,}C)" at (last [],S)} + bswitch(,,C); {"\tt (,{,}C)" at last [].s Below} } # Row 3 - move down; right_; { - D: dswitch(,,); {S: "\tt ds{}witch(,{},)" Below} + move down 0.45; right_; { + D: dswitch(,,); {"\tt ds{}witch(,{},)" at last [].s Below} thinlines_ - { spline <- from 0.25 along_(D) up 0.1 then up 0.05 left 0.1 - {"\tt W" rjust} - spline <- from D.c+(0,m4sc*2) up 0.1 then up 0.05 left 0.1 - {"\tt B" rjust }} + {spline <- from last [].B.c up 0.1 then up 0.05 left 0.1; "\tt B" rjust} thicklines_ move right_ - D: dswitch(,,WdBK); {"\tt (,{,}WdBK)" at (last [],S)+(0,-4bp__)} + dswitch(,,WdBK); {"\tt (,{,}WdBK)" at last [].s Below} thinlines_ - { spline <- from tr_xy(0,-2) up 0.1 then up 0.10 left 0.1 - {"\tt dB" rjust} - spline <- from tr_xy(4,-2) right 0.1 then right 0.05 up 0.15 + { spline <- from 0.5 along_(last [].B) up 0.1 then up 0.10 left 0.1 + {"\tt B" rjust} } + { spline <- from last [].K right 0.1 then right 0.05 up 0.15 {"\tt K" above }} thicklines_ move right_ - dswitch(,,WBmdDK); {"\tt (,{,}WBmdDK)" at (last [],S)} + dswitch(,,WBmdDK); {"\tt (,{,}WBmdDK)" at last [].s Below} move right_ - dswitch(,,WBKTr); {"\tt (,{,}WBKTr)" at (last [],S)} + dswitch(,,WBKTr); {"\tt (,{,}WBKTr)" at last [].s Below} move right_ - dswitch(,,WdBL); {"\tt (,{,}WdBL)" at (last [],S+(0,-4bp__))} + dswitch(,,WdBL); {"\tt (,{,}WdBL)" at last [].s Below} move right_ - dswitch(,,WBCo); {"\tt (,{,}WBCo)" at (last [],S)} + dswitch(,,WBSd); {"\tt (,{,}WBSd)" at last [].s Below} } # Row 4 - move down; right_; { - dswitch(,,WBKCo); {S: "\tt (,{,}WBKCo)" Below} + move down 0.4; right_; { + dswitch(,,WBCb); {"\tt (,{,}WBCb)" at last [].s Below} move right_ - dswitch(,,WBCb); {"\tt (,{,}WBCb)" at (last [],S)} + dswitch(,,WBcCb); {"\tt (,{,}WBcCb)" at last [].s Below} move right_ - dswitch(,,WBDI); {"\tt (,{,}WBDI)" at (last [],S)} + dswitch(,,WBcDI); {"\tt (,{,}WBcDI)" at last [].s Below} + thinlines_ + {arrow <- from last [].DI.start up_ 0.1 right_ 0.15; "\tt DI" ljust} + thicklines_ move right_ - dswitch(,,WBSd); {"\tt (,{,}WBSd)" at (last [],S)} +# dswitch(,,WBDI); {"\tt (,{,}WBDI)" at last [].s Below} + dswitch(,,WBKCo); {"\tt (,{,}WBKCo)" at last [].s Below} move right_ - dswitch(,,WBFDI); {"\tt (,{,}WBFDI)" at (last [],S)} + dswitch(,,WBFDI); {"\tt (,{,}WBFDI)" at last [].s Below} move right_ - dswitch(,,WBFSd); {"\tt (,{,}WBFSd)" at (last [],S)} + dswitch(,,WBFSd); {"\tt (,{,}WBFSd)" at last [].s Below} } # Row 5 - move down moveht*5/4; right_; { - dswitch(,,WBTh); {S: "\tt (,{,}WBTh)" Below} + move down 0.4; right_; { + dswitch(,,WBMMR); {"\tt (,{,}WBMMR)" at last [].s Below} move right_ - dswitch(,,WBKC); {"\tt (,{,}WBKC)" at (last [],S)} + dswitch(,,WBMM); {"\tt (,{,}WBMM)" at last [].s Below} move right_ - dswitch(,,WBM); {"\tt (,{,}WBM)" at (last [],S)} + dswitch(,,WBMR); {"\tt (,{,}WBMR)" at last [].s Below} move right_ - dswitch(,,WBCO); {"\tt (,{,}WBCO)" at (last [],S)} + dswitch(,,WBEL); {"\tt (,{,}WBEL)" at last [].s Below} move right_ - dswitch(,,WBMP); {"\tt (,{,}WBMP)" at (last [],S)} + dswitch(,,WBLE); {"\tt (,{,}WBLE)" at last [].s Below} move right_ - dswitch(,,WBoKCP); {"\tt (,{,}WBoKCP)" at (last [],S)} + dswitch(,,WBoKEL); {"\tt (,{,}WBoKEL)" at last [].s Below} } # Row 6 - move down moveht*5/4; right_; { - dswitch(,,WBCY); {S: "\tt (,{,}WBCY)" Below} + move down moveht+2bp__; right_; { + dswitch(,,WBTh); {"\tt (,{,}WBTh)" at last [].s Below} move right_ - dswitch(,,WBCZ); {"\tt (,{,}WBCZ)" at (last [],S)} - move right_ - dswitch(,,WBCE); {"\tt (,{,}WBCE)" at (last [],S)} + dswitch(,,WBKC); {"\tt (,{,}WBKC)" at last [].s Below} + thinlines_ + { arrow <- from last [].C.c left 0.2; "\tt C" rjust } + thicklines_ move right_ - dswitch(,,WBRH); {"\tt (,{,}WBRH)" at (last [],S)} + dswitch(,,WBM); {"\tt (,{,}WBM)" at last [].s Below} move right_ - dswitch(,,WBRdH); {"\tt (,{,}WBRdH)" at (last [],S)} + dswitch(,,WBCO); {"\tt (,{,}WBCO)" at last [].s Below} move right_ - dswitch(,,WBRHH); {"\tt (,{,}WBRHH)" at (last [],S)} + dswitch(,,WBMP); {"\tt (,{,}WBMP)" at last [].s Below} + move down_ 2bp__ then right_ + dswitch(,,WBoKCP); {"\tt (,{,}WBoKCP)" at last [].s Below} } # Row 7 - move down moveht; right_; { - move down_ 2bp__; right_ - dswitch(,,WBPr); {S: "\tt (,{,}WBPr)" Below} + move down moveht*7/6; right_; { + dswitch(,,WBCY); {"\tt (,{,}WBCY)" at last [].s Below} move right_ - dswitch(,,WBPrT); {S: "\tt (,{,}WBPrT)" Below} -# move right_ -# Proxim; {S: "\tt Pro{}xim" Below} -# move right_ -# Magn; {S: "\tt Mag{}n" Below} - move down_ 6bp__ then right_ - dswitch(,,WBPrM); {S: "\tt (,{,}WBPrM)" Below} + dswitch(,,WBCZ); {"\tt (,{,}WBCZ)" at last [].s Below} + move right_ + dswitch(,,WBCE); {"\tt (,{,}WBCE)" at last [].s Below} + move right_ + dswitch(,,WBRH); {"\tt (,{,}WBRH)" at last [].s Below} + move right_ + dswitch(,,WBRdH); {"\tt (,{,}WBRdH)" at last [].s Below} + move right_ + dswitch(,,WBRHH); {"\tt (,{,}WBRHH)" at last [].s Below} } # Row 8 - move down; right_; { - dswitch(,,WBMMR); {S: "\tt (,{,}WBMMR)" Below} - move right_ - dswitch(,,WBMM); {"\tt (,{,}WBMM)" at (last [],S)} + move down moveht; right_; { + move down_ 2bp__; right_ + dswitch(,,WBPr); {"\tt (,{,}WBPr)" at last [].s Below} move right_ - dswitch(,,WBMR); {"\tt (,{,}WBMR)" at (last [],S)} + dswitch(,,WBPrT); {"\tt (,{,}WBPrT)" at last [].s Below} + move down_ 6bp__ then right_ + dswitch(,,WBPrM); {"\tt (,{,}WBPrM)" at last [].s Below} move right_ - dswitch(,,WBEL); {"\tt (,{,}WBEL)" at (last [],S)} + dswitch(,,WBDIGX,text=W); #{"\tt (,{,}WBDIGX,W)" at last [].s Below} + {"\tt (,{,}WBDIGX," ljust at last line.start+(0,-15bp__) \ + "\tt text=W)" ljust} move right_ - dswitch(,,WBLE); {"\tt (,{,}WBLE)" at (last [],S)} + dswitch(,,WBDIGC,text=M) + {"\tt (,{,}WBDIGC," ljust at last line.start+(0,-15bp__) \ + "\tt text=M)" ljust} move right_ - dswitch(,,WBoKEL); {"\tt (,{,}WBoKEL)" at (last [],S)} + dswitch(,,WBcDIGC,text=M) # + {"\tt (,{,}WBcDIGC," ljust at last line.start+(0,-15bp__) \ + "\tt text=M)" ljust} } + .PE diff --git a/graphics/circuit_macros/examples/control.m4 b/graphics/circuit_macros/examples/control.m4 index aa3de4bff9..db6a5940cc 100644 --- a/graphics/circuit_macros/examples/control.m4 +++ b/graphics/circuit_macros/examples/control.m4 @@ -13,7 +13,7 @@ PID: [ arrow S1: circle line right "$e(s)$" above - { arrow right ; box ht bh wid bw "$K_p$" + { arrow right ; box ht bh wid bw "$K_P$" arrow right linewid-circlerad ; S2: circle } { arrow up linewid then right ; box ht bh wid bw "$K_D s$" arrow to (S2,Here) then to S2.n } @@ -43,7 +43,7 @@ R: arrow S: circle fill {"$-$" below ljust at S.s; "$+$" above rjust at S.w+(2bp__,0)} { OLP: box invis fill 0.9 wid 3.1 ht 1.4 with .nw at Here+(0.3,boxht*5/4) - "\sf plant" at OLP.nw below ljust } + "\sf plant" at OLP.sw above ljust } U: arrow right 0.4 {"$u$" at last arrow+(2bp__,0) above } Bp: box fill "$B$" diff --git a/graphics/circuit_macros/examples/ex05.m4 b/graphics/circuit_macros/examples/ex05.m4 index af26c78781..dbdacdab90 100644 --- a/graphics/circuit_macros/examples/ex05.m4 +++ b/graphics/circuit_macros/examples/ex05.m4 @@ -9,11 +9,17 @@ darrow_init extlen=4*dx indel = boxht/3 -COb: box fill_ "C$\bar{\mbox{O}}$" +# Replacement for \bar, see +# https://tex.stackexchange.com/questions/22100/the-bar-and-overline-commands +command "\newcommand{\ols}[1]{% +\mskip.5\thinmuskip\overline{\mskip-.5\thinmuskip {#1} \mskip-.5\thinmuskip}% +\mskip.5\thinmuskip} % overline short " + +COb: box fill_ "C$\ols{\mbox{O}}$" CO:box fill_ with .nw at last box.se+(dx,-dx) "CO" CbOb: box fill_ with .nw at last box.se+(dx,-dx) \ - "$\bar{\mbox{C}}$$\bar{\mbox{O}}$" -CbO: box fill_ with .nw at last box.se+(dx,-dx) "$\bar{\mbox{C}}$O" + "$\ols{\mbox{C}}$$\ols{\mbox{O}}$" +CbO: box fill_ with .nw at last box.se+(dx,-dx) "$\ols{\mbox{C}}$O" dline(from CbO.s down_ dx,,t,,!-) dright diff --git a/graphics/circuit_macros/examples/ex06.m4 b/graphics/circuit_macros/examples/ex06.m4 index 4f6986a133..1fb6b1bd7b 100644 --- a/graphics/circuit_macros/examples/ex06.m4 +++ b/graphics/circuit_macros/examples/ex06.m4 @@ -14,10 +14,13 @@ G: box invis wid 1i ht F.ht qmell = F.ht - ell kwid = F.wid-qmell-r + hatchbox(wid G.e.x-F.w.x ht F.ht,hatch) with .sw at F.sw + box invis fill_(1) ht ell wid E.e.x-F.w.x with .nw at F.nw + box wid G.e.x-F.w.x ht F.ht with .sw at F.sw thick linethick*3/2 Loopover_(`B', - `line from B.ne to B.se thick linethick*3/2 - B`'T: B.se + (-qmell,qmell) + `B`'T: B.se + (-qmell,qmell) + line invis fill_(1) from B.se to (B.se,B`'T) then to B`'T then to B.se line from (B.w,B`'T) to B`'T chop 0 chop -offset line from B`'T up ell chop -offset chop 0 line from B`'T + (-r,0) up ell @@ -27,28 +30,13 @@ G: box invis wid 1i ht F.ht "$t$" at (B`'T,B.n) + (-offset/2,offset) sprintf("$\overbrace{\phantom{\hbox to %gin{}}}^{\hbox{$k$}}$",kwid) \ at B.nw + (kwid/2,0) above - thinlines_ - for x = hatch to B`'T.x-B.w.x-r by hatch do {line down ell from B.nw+(x,0)} - for y = dhs to qmell by dhs do {line up y right y from (B.w,B`'T)+(0,-y)} - for x = y-qmell to B.wid-qmell*2 by dhs do { - line up qmell right qmell from B.sw+(x,0) } - for x = last line.start.x-B.w.x+dhs to B.wid by dhs do { - line up (B.wid-x)/2 right (B.wid-x)/2 from B.sw+(x,0) } - thicklines_ + hatchbox(wid kwid ht ell,hatch,,90) with .nw at B.nw + line from B.ne to B.se thick linethick*3/2 ',F,E) line from (G.w,ET) right G.wid line from ET + (0,r) left ET.x-E.w.x - - thinlines_ - for y = hatch to r by hatch do { line left r from ET+(0,r-y) } - for x = dhs to G.wid by dhs do { - line left x down x from G.nw+(x,0) } - for y=x-G.wid to G.ht-G.wid by dhs do { - line left G.wid down G.wid from G.ne+(0,-y) } - for x = y-(G.ht-G.wid) to G.wid by dhs do { - line right G.wid-x up G.wid-x from G.sw+(x,0) } - thicklines_ + hatchbox(wid r ht r,hatch,,0) with .se at ET "$q$" at F.sw + (-offset,offset/3) "$\ell$" at (F.w,FT) + (-offset,offset/3) diff --git a/graphics/circuit_macros/examples/examples.pdf b/graphics/circuit_macros/examples/examples.pdf Binary files differindex 6d02c456cc..7b89aac55c 100644 --- a/graphics/circuit_macros/examples/examples.pdf +++ b/graphics/circuit_macros/examples/examples.pdf diff --git a/graphics/circuit_macros/examples/examples.tex b/graphics/circuit_macros/examples/examples.tex index 79979379bb..8d3af1327c 100644 --- a/graphics/circuit_macros/examples/examples.tex +++ b/graphics/circuit_macros/examples/examples.tex @@ -5,6 +5,7 @@ \input mode \usepackage{rotating} \usepackage{graphicx} +\usepackage{xcolor} \usepackage{boxdims} %\usepackage{upgreek} \usepackage{siunitx} diff --git a/graphics/circuit_macros/examples/files.tex b/graphics/circuit_macros/examples/files.tex index 5a04b20edc..03c9ffa090 100644 --- a/graphics/circuit_macros/examples/files.tex +++ b/graphics/circuit_macros/examples/files.tex @@ -14,19 +14,20 @@ \bfig{ \centerline{{\small\getpic{Capacitors}}} - \caption{Capacitors, showing some variations + \caption{Capacitors \src{Capacitors.m4}.} } \bfig{ \centerline{{\small\getpic{Inductors}}} - \caption{Inductors, showing some variations + \caption{Inductors \src{Inductors.m4}.} } \bfig{ \centerline{\getpic{Diodes}} - \caption{Diodes: a {\tt K} in the second argument draws an open arrowhead + \caption{Diodes: appending a {\tt K} to the second argument + draws an open arrowhead \src{Diodes.m4}.} } @@ -506,6 +507,12 @@ } \bfig{ + \centerline{\getpic{EEP}} + \caption{A test of experimental single-line diagram macros + \src{EEP.m4}.} + } + +\bfig{ \centerline{\getpic{control}} \caption{Control-system block diagrams \src{control.m4}.} @@ -539,7 +546,7 @@ \bfig{ \centerline{\getpic{ex06}} - \caption{Crosshatching by {\tt for} loops + \caption{Crosshatching \src{ex06.m4}.} } @@ -562,18 +569,19 @@ } \bfig{ - \centerline{\getpic{ex05}} - \caption{Use of {\tt darrow} - \src{ex05.m4}.} - } - -\bfig{ \centerline{\getpic{Plate}} \caption{Dimensioning with tolerances \src{Plate.m4}.} } \bfig{ + \centerline{\getpic{ex05}} + \caption{The Kalman canonical decomposition of a dynamical system: + use of {\tt darrow} + \src{ex05.m4}.} + } + +\bfig{ \centerline{\getpic{Loglog}} \caption{A graph drawn using the pic language \src{Loglog.m4}.} @@ -595,8 +603,7 @@ \bfig{ \centerline{\getpic{graysurf}} - \caption{Plotting surfaces using gray scales. A sort algorithm - determines plotting order + \caption{Plotting surfaces using gray scales \src{graysurf.m4}.} } @@ -607,12 +614,6 @@ } \bfig{ - \centerline{\getpic{Lyap}} - \caption{Illustrating a Lyapunov function - \src{Lyap.m4}.} - } - -\bfig{ \centerline{\getpic{csc}} \caption{Conestoga Sailing Club (illustrating the filling of arbitrary shapes) and an antique clock face with shading and rotated text @@ -625,7 +626,7 @@ {\it Dracula,} used for testing {\tt dpic}. This diagram consumes much \LaTeX\ main memory but can be produced directly as pdf using \hbox{\tt dpic -d}, - as svg using \hbox{\tt dpic -g}, + as svg using \hbox{\tt dpic -v}, or as postscript using \hbox{\tt dpic -r} since no text formatting is required \src{rose.m4}.} @@ -665,6 +666,12 @@ } \bfig{ + \centerline{\getpic{Escher}} + \caption{Two Escher-like objects + \src{Escher.m4}.} + } + +\bfig{ \centerline{\getpic{recycle}} \caption{Modest repetition and partial fill \src{recycle.m4}.} @@ -677,12 +684,6 @@ } \bfig{ - \centerline{\getpic{Counting}} - \caption{An example of enumeration - src{Counting.m4}.} - } - -\bfig{ \centerline{\getpic{Crow}} \caption{Illustrating {\tt shadebox} and a custom crowfoot line termination \src{Crow.m4}.} diff --git a/graphics/circuit_macros/examples/ics.m4 b/graphics/circuit_macros/examples/ics.m4 index bf702d7c44..98789b73cd 100644 --- a/graphics/circuit_macros/examples/ics.m4 +++ b/graphics/circuit_macros/examples/ics.m4 @@ -290,7 +290,7 @@ define(`DIP',`[ pinct= ifelse(`$1',,8,`$1') type:I:N) setdir_(m4direct,U) Body: box ht_ m4bodywid wid_ m4bodylen - arcs = ifelse(m4dir,right,90,m4dir,up,180,m4dir,left,270,0) + arcs = ifelse(m4_dir_,right,90,m4_dir_,up,180,m4_dir_,left,270,0) arcd(Body.e_, 0.1/2, arcs,arcs+180) np2 = int(pinct/2+0.5) define(`m4bxht',`m4pinlen ifelse(m4type,Q,`*(1+(i%%2))')')dnl diff --git a/graphics/circuit_macros/examples/mf/cct.mf b/graphics/circuit_macros/examples/mf/cct.mf index 16e77f4cbd..85a84e5a7f 100644 --- a/graphics/circuit_macros/examples/mf/cct.mf +++ b/graphics/circuit_macros/examples/mf/cct.mf @@ -1,5 +1,5 @@ % cct.mf, generated by Mfpic, v1.10 2012/12/03, -% from TeX source "font" on 2021/10/02 at 01:36 +% from TeX source "font" on 2022/02/11 at 17:20 numeric mfpicversion; mfpicversion := 110; if unknown mode: mode := localfont; fi if unknown mag: mag := 1000/1000; fi @@ -142,8 +142,8 @@ resizedrawpen (0.8bp); store (curpath) drawn polyline (false) -((0.303716,0), -(0.323964,0)); +((0.313085,0), +(0.333333,0)); endmfpic; % (3) line 59 in the TeX source. %------------------------------------------ @@ -224,8 +224,8 @@ resizedrawpen (0.8bp); store (curpath) drawn polyline (false) -((0,-0.303716), -(0,-0.323964)); +((0,-0.313085), +(0,-0.333333)); endmfpic; % (4) line 77 in the TeX source. %------------------------------------------ @@ -306,8 +306,8 @@ resizedrawpen (0.8bp); store (curpath) drawn polyline (false) -((-0.303716,-0), -(-0.323964,-0)); +((-0.313085,0), +(-0.333333,0)); endmfpic; % (5) line 95 in the TeX source. %------------------------------------------ @@ -388,8 +388,8 @@ resizedrawpen (0.8bp); store (curpath) drawn polyline (false) -((-0,0.303716), -(-0,0.323964)); +((0,0.313085), +(0,0.333333)); endmfpic; % (6) line 113 in the TeX source. %------------------------------------------ @@ -491,11 +491,11 @@ arcplr ((0,-0.135417),90,-90,0.03125); store (curpath) drawn -arcplr ((0,-0.197917),90,-90,0.03125); +arcplr ((-0,-0.197917),90,-90,0.03125); store (curpath) drawn -arcplr ((0,-0.260417),90,-90,0.03125); +arcplr ((-0,-0.260417),90,-90,0.03125); store (curpath) drawn @@ -3262,7 +3262,7 @@ endmfpic; % (78) line 1101 in the TeX source. %----------------------------<79> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.104167, 0.104167, -0.333333, -0); +bounds (-0.104167, 0.104167, -0.333333, 0); beginmfpic(79); % line 1102 in the TeX source. @@ -3272,7 +3272,7 @@ setcolor (drawcolor) black; store (curpath) drawn polyline (false) -((-0.104167,-0), +((-0.104167,0), (-0.104167,-0.041667)); store (curpath) @@ -4815,7 +4815,7 @@ store (curpath) drawn polyline (false) ((0.122222,0.148911), -(0,0.148911)); +(-0,0.148911)); store (curpath) drawn @@ -4842,7 +4842,7 @@ endmfpic; % (106) line 1617 in the TeX source. %----------------------------<107> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.151089, 0.151089, -0.355556, -0); +bounds (-0.151089, 0.151089, -0.355556, 0); beginmfpic(107); % line 1618 in the TeX source. @@ -4862,7 +4862,7 @@ arcplr ((-0.001089,0.310672),-64.227634,-115.376934,0.35); store (curpath) drawn polyline (false) -((-0.151089,-0), +((-0.151089,0), (-0.151089,-0.122222)); store (curpath) @@ -4880,7 +4880,7 @@ endmfpic; % (107) line 1629 in the TeX source. %----------------------------<108> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.355556, -0, -0.151089, 0.151089); +bounds (-0.355556, 0, -0.151089, 0.151089); beginmfpic(108); % line 1630 in the TeX source. @@ -4929,7 +4929,7 @@ store (curpath) drawn polyline (false) ((-0.148911,0.122222), -(-0.148911,0)); +(-0.148911,-0)); store (curpath) drawn @@ -5175,7 +5175,7 @@ store (curpath) drawn polyline (false) ((0.122222,0.148911), -(0,0.148911)); +(-0,0.148911)); store (curpath) drawn @@ -5206,7 +5206,7 @@ endmfpic; % (118) line 1746 in the TeX source. %----------------------------<119> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.151089, 0.151089, -0.430556, -0); +bounds (-0.151089, 0.151089, -0.430556, 0); beginmfpic(119); % line 1747 in the TeX source. @@ -5226,7 +5226,7 @@ arcplr ((-0.001089,0.310672),-64.227634,-115.376934,0.35); store (curpath) drawn polyline (false) -((-0.151089,-0), +((-0.151089,0), (-0.151089,-0.122222)); store (curpath) @@ -5248,7 +5248,7 @@ endmfpic; % (119) line 1759 in the TeX source. %----------------------------<120> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.430556, -0, -0.151089, 0.151089); +bounds (-0.430556, 0, -0.151089, 0.151089); beginmfpic(120); % line 1760 in the TeX source. @@ -5301,7 +5301,7 @@ store (curpath) drawn polyline (false) ((-0.148911,0.122222), -(-0.148911,0)); +(-0.148911,-0)); store (curpath) drawn @@ -5416,7 +5416,7 @@ endmfpic; % (123) line 1811 in the TeX source. %----------------------------<124> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.4, -0, -0.151089, 0.151089); +bounds (-0.4, 0, -0.151089, 0.151089); beginmfpic(124); % line 1812 in the TeX source. @@ -5592,7 +5592,7 @@ endmfpic; % (127) line 1865 in the TeX source. %----------------------------<128> unitlen := 1.0pt#; xscale := 72; yscale := 72; -bounds (-0.475, -0, -0.151089, 0.151089); +bounds (-0.475, 0, -0.151089, 0.151089); beginmfpic(128); % line 1866 in the TeX source. diff --git a/graphics/circuit_macros/examples/svg/CctTableSVG.m4 b/graphics/circuit_macros/examples/svg/CctTableSVG.m4 deleted file mode 100644 index e46bb97a76..0000000000 --- a/graphics/circuit_macros/examples/svg/CctTableSVG.m4 +++ /dev/null @@ -1,96 +0,0 @@ -.PS -# `CctTableSVG.m4' -cct_init(svg_font(sans-serif,11pt__)) -textwid = 1.5 -movewid = 2 pt__ -hm = 2.1 -vm = 0.28 - -hm = 2.05 -vm = 0.28 -{ {resistor ; move ; svgLink(NportSVG.svg,"`resistor'" ljust)} - move right_ hm - {resistor(,,Q) ; move ; "`resistor(,,Q) '" ljust} - move right_ hm - {resistor(,,E) ; move - "`resistor(,,E) = ebox'" ljust} -} - move down vm; right_ -{ {resistor(,,ES) ; move ; "`resistor(,,ES) '" ljust} - move right_ hm - {resistor(,,H) ; move ; "`resistor(,,H) '" ljust} - move right_ hm - {ebox(,,,0.5) ; move ; "`ebox(,,,0.5) '" ljust} -} - move down vm; right_ -{ {resistor(,,V) ; move ; "`resistor(,,V) '" ljust} - move right_ hm - {move down_ 0.05; right_ - thermocouple ; move; "`thermocouple '" ljust; move up_ 0.05} - move right_ hm - {ebox(,0.5,0.3) ; move ; "`ebox(,0.5,0.3) '" ljust} -} - move down vm; right_ -{ {inductor ; move ; "`inductor '" ljust} - move right_ hm - {inductor(,W); move ; "`inductor(,W) '" ljust} - move right_ hm - {inductor(,L); move ; "`inductor(,L) '" ljust} -} - move down vm; right_ -{ {inductor(,,,M) ; move ; "`inductor(,,,M) '" ljust} - move right_ hm - {inductor(,W,6,P); move ; "`inductor(,W,6,P) '" ljust} - move right_ hm - {move right_ 0.2; ttmotor(,G) ; move ; "`ttmotor(,G) '" ljust} -} - move down vm; right_ -{ {capacitor ; move ; "`capacitor '" ljust} - move right_ hm - {capacitor(,C); move ; "`capacitor(,C) '" ljust} - move right_ hm - {capacitor(,C+); move ; "`capacitor(,C+) '" ljust} -} - move down vm; right_ -{ {capacitor(,P); move ; "`capacitor(,P) '" ljust} - move right_ hm - {capacitor(,E); move ; "`capacitor(,E) '" ljust} - move right_ hm - {capacitor(,K); move ; "`capacitor(,K) '" ljust} -} - move down 0.25; right_ -{ {capacitor(,M); move ; "`capacitor(,M) '" ljust} - move right_ hm - {capacitor(,N); move ; "`capacitor(,N) '" ljust} - move right_ hm - {xtal ; move ; "`xtal '" ljust} -} - move down 0.25; right_ -{ {memristor ; move; "`memristor '" ljust} - move right_ hm - {heater; move; "`heater '" ljust} - move right_ hm - {tline ; move; "`tline '" ljust} -} - move down 0.25; right_ -{ {move up_ 0.05; right_; gap ; move ; "`gap '" ljust} - move right_ hm - {gap(,,A) ; move ; "`gap(,,A) '" ljust} - move right_ hm - {arrowline ; move; "`arrowline '" ljust} -} - move down 0.25; right_ -{ {lamp ; move; "`lamp '" ljust} - move right_ hm - {reed ; move ; "`reed '" ljust} - move right_ hm - {reed(,,,fill_(0.9),CR) ; move ; "`reed(,,,fill_(0.9),CR) '" ljust} -} - move down 0.25; right_ -{ {pvcell ; move; "`pvcell '" ljust} - move right_ hm - {arrester ; move ; "`arrester '" ljust} -} - - command "</g>" # end font -.PE diff --git a/graphics/circuit_macros/examples/svg/DiodesSVG.m4 b/graphics/circuit_macros/examples/svg/DiodesSVG.m4 index eb1c6f5672..543132fe33 100644 --- a/graphics/circuit_macros/examples/svg/DiodesSVG.m4 +++ b/graphics/circuit_macros/examples/svg/DiodesSVG.m4 @@ -2,6 +2,7 @@ # `Diodes.m4' cct_init(svg_font(sans-serif,11bp__)) movewid = 2pt__ + { {diode ; move ; "`diode'" ljust} move down 0.2; right_ {diode(,S) ; move ; "`diode(,S)'" ljust} @@ -15,11 +16,12 @@ movewid = 2pt__ {diode(,B) ; move ; "`diode(,B)'" ljust} move down 0.2; right_ {diode(,G) ; move ; "`diode(,G)'" ljust} + move down 0.2; right_ + {diode(,D) ; move ; "`diode(,D)'" ljust} } move right_ 2.0 -{ - {diode(,K) ; move ; "`diode(,K)'" ljust} +{ {diode(,K) ; move ; "`diode(,K)'" ljust} move down 0.2; right_ {diode(,ZK) ; move ; "`diode(,ZK)'" ljust} move down 0.2; right_ @@ -31,11 +33,13 @@ movewid = 2pt__ move down 0.2; right_ {diode(,Sh) ; move ; "`diode(,Sh)'" ljust} move down 0.2; right_ - {diode(,D) ; move ; "`diode(,D)'" ljust} + {diode(,M) ; move ; "`diode(,M)'" ljust} + move down 0.2; right_ + {diode(,MK) ; move ; "`diode(,MK)'" ljust} } move right_ 2.0 -{ {diode(,Z,RE) ; move ; "`diode(,Z,RE)'" ljust; move right 1.5} +{ {diode(,Z,RE) ; move ; "`diode(,Z,RE)'" ljust} move down 0.25; right_ {diode(,T) ; move ; "`diode(,T)'" ljust} move down 0.30; right_ diff --git a/graphics/circuit_macros/examples/svg/EEPSVG.m4 b/graphics/circuit_macros/examples/svg/EEPSVG.m4 index 277b704cd8..25a9ff71d9 100644 --- a/graphics/circuit_macros/examples/svg/EEPSVG.m4 +++ b/graphics/circuit_macros/examples/svg/EEPSVG.m4 @@ -1,572 +1,107 @@ .PS # EEPSVG.m4 -# https://electrical-engineering-portal.com/single-line-diagrams-symbols-drawings-analysis - -cct_init -divert(-1) - -# This section defines *DRAFT* SLD elements with or without attached -# circuit breakers. Many other elements applicable to SLD drawings are -# already in libcct.m4. The contributions and suggestions of Benjamin -# Vilmann are acknowledged with thanks. - -# Notes for 1-terminal SLD elements: -# Argument 1 is normally the linespec of the stem to set the element direction -# and length. See also: PtoL defined in libgen.m4. -# For a 0-length stem (which has undefined direction): -# arg1 can also be U, D, L, R (for up, down, left, right), -# or a number to set the direction in degrees, optionally followed by -# `at position' to set the position (Here by default). -# Zero-length stem examples: sl_box(U), sl_box(45 at Here+(1,0)) -# Argument 2 contains semicolon (;)-separated key-value attributes -# of the element head as applicable: e.g., name=Carol; text="Stop"; lgth=expr -# If argument 3 is blank then no breaker is drawn. A non-blank argument 3 -# is C for a default closed breaker in the stem, O for an open breaker, -# or key-value pairs to specify breaker details. -# The element body (head) can be named with name=. It is overlaid with -# or contained in a [] block. - -# Notes for 2-terminal SLD elements: -# These obey the normal Circuit_macro two-terminal conventions. -# They can be labelled using rlabel() or llabel() as well as directly. -# Argument 2 contains key-value pairs to customize the element body, -# e.g., name=Name; text="text"; wdth=expr; ... -# Nonblank arguments 3 and 4 put a breaker in the input and output respectively. - -# Notes for attached breakers: -# Nonblank arguments 3 and 4 of the two-terminal elements and argument 3 of -# the 1-terminal elements specify a breaker in the input, output, and stem -# respectivlely. An O creates a default-size open breaker, and C a closed -# breaker, otherwise the argument contains key-value pairs to specify the -# details of the box; e.g., box=dotted 2bp__ shaded "green" - -# Notes for composite elements within a [ ] block: -# The SLD current transformer macro sl_ct is composite. -# Internal labels L (for inductor) and terminals Ts, Tc, and Te are defined. - -define(`sldlib_') -ifdef(`libcct_',,`include(libcct.m4)divert(-1)') - -# Default size parameters. These can be redefined in a diagram. - -define(`brksiz_',`dimen_*3/16') # Default inline box breaker size -define(`drosiz_',`dimen_/4') # Default sl_drawout (chevron) size - -# One-terminal elements ################################################### - - `sl_disk( stem linespec, keys, breaker ) - keys: name=Name; - text="text"; - diam=expr; - circle=circle attributes; eg diam expr' - `default breaker name Bd' -define(`sl_disk', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; circle::N; text::N; diam:dimen_*2/3')dnl - ifelse(`$3',, - `ifelse(m4name,,,m4name:) circle diam m4diam \ - at last line.end + vec_(m4diam/2,0) m4circle m4text - [ box invis wid_ m4diam ht_ m4diam ] at last circle - line from last line.end to last line.start', - `m4br_one(`sl_disk',`$1',`$2',m4brk_(`$3',Bd))') ') - - `sl_box( stem linespec, keys, breaker ) - keys: name=Name; lgth=expr; wdth=expr; - text="text"; - box= box attributes; (e.g. shade "red")' - `default breaker name Bb' -define(`sl_box', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*2/3; lgth:dimen_*2/3; box::N; text::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - { ifelse(m4name,,,m4name:) [S:Here; lbox(m4lgth,m4wdth,m4box)] \ - with .S at last line.start } - ifelse(m4text,,,`{m4text at last []}')', - `m4br_one(`sl_box',`$1',`$2',m4brk_(`$3',Bb))') ') - - `sl_grid( stem linespec, keys, breaker ) - keys: name=Name; lgth=expr; wdth=expr;' - `default breaker name Bgr' -define(`sl_grid', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*4/5; lgth:dimen_*2/3; box::N; text::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - { ifelse(m4name,,,m4name:) [S:Here - { ifelse(m4name,,,m4name:) lbox(m4lgth,m4wdth) } - { line to rvec_(m4lgth/2, m4wdth/2) - line to rvec_(m4lgth/2,-m4wdth/2) - line to rvec_(-m4lgth/2,-m4wdth/2) - line to rvec_(-m4wdth/2, m4wdth/2) } - { line from rvec_(0,m4wdth/2) to rvec_(m4lgth,-m4wdth/2) } - line from rvec_(0,-m4wdth/2) to rvec_(m4lgth,m4wdth/2) - ] with .S at last line.start } ', - `m4br_one(`sl_grid',`$1',`$2',m4brk_(`$3',Bgr))') ') - - `sl_load( stem linespec, keys, breaker ) - keys: name=Name; lgth=expr; wdth=expr; - head= arrowhead attributes;' - `default breaker name Bl' -define(`sl_load', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*0.32; lgth:dimen_*0.45; head::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - { ifelse(m4name,,,m4name:) [S:Here; line to rvec_(0,m4wdth/2) \ - then to rvec_(m4lgth,0) then to rvec_(0,-m4wdth/2) \ - then to Here m4head ] with .S at last line.start } ', - `m4br_one(`sl_load',`$1',`$2',m4brk_(`$3',Bl))') ') - - `sl_meterbox( stem linespec, keys, breaker ) - keys: sl_box attributes' - `default breaker name Bm' -define(`sl_meterbox', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*2/3; lgth:dimen_*2/3; box::N; text::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - {ifelse(m4name,,,m4name:) [S:Here; - { B: rotbox( m4lgth, m4wdth, m4box ) with .W at S } - a = rp_ang*rtod_ - if (abs(a-90) < 45) || (abs(a-180) < 45) || (abs(a+180) < 45) then { - C: rvec_(m4lgth*2/5,0) - line from rvec_(m4lgth*4/5,m4wdth/2) to rvec_(m4lgth*4/5,-m4wdth/2) } \ - else { C: rvec_(m4lgth*3/5,0) - line from rvec_(m4lgth/5,m4wdth/2) to rvec_(m4lgth/5,-m4wdth/2) } - ifelse(m4text,,,`m4text at C') - ] with .S at last line.start}', - `m4br_one(`sl_meterbox',`$1',`$2',m4brk_(`$3',Bm))') ') - - `sl_generator( stem linespec, keys, breaker )' - `default breaker name Bd' -define(`sl_generator',`sl_disk($@) - { ACsymbol(at last circle,,,R) - m4lcd = last circle.diam - [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ') - - `sl_syncmeter( stem linespec, keys, breaker )' - `default breaker name Bd' -define(`sl_syncmeter',`sl_disk($@) - { Syncsymb(at last circle) - m4lcd = last circle.diam - [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ') - - `sl_lamp( stem linespec, keys, breaker )' - `default breaker name Bd' -define(`sl_lamp',`sl_disk($@) - { line from last circle.ne to last circle.sw - line from last circle.nw to last circle.se - m4lcd = last circle.diam - [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ') - -# One-terminal utilities ################################################## - - `Syncsymb(at position, rad) - Symbol for sync meter' -define(`Syncsymb',`[ define(`m4ssrad',`ifelse(`$2',,(dimen_/4),`($2)')')dnl - Origin: Here - {arc <-> ht arrowht/2 wid arrowwid*2/3 \ - from Rect_(m4ssrad,30) to Rect_(m4ssrad,150) with .c at Here} - line from (0,m4ssrad) to (0,-m4ssrad/2) - `$3' ] with .Origin ifelse(`$1',,`at Here',`$1')') - - `m4br_one( `name', stem linespec, body keys, - breaker keys )' - `Draw the breaker in the stem then the element' -define(`m4br_one', - `M4_S: last line.start - setkey_(`$4',lgth,brksiz_)dnl - line from M4_S to last line.end+vec_(-(m4lgth)*5/2,0) - sl_breaker(to rvec_(m4lgth,0),`$4') - $1(to rvec_((m4lgth)*3/2,0),`$3') - move to M4_S ') - - `sl_eleminit_(linespec or (for zero length) - U|D|L|R|number [at location])' -define(`sl_eleminit_', - `ifelse(regexp(`$1',^ *[UDLR0123456789]),-1, - `eleminit_(`$1',dimen_)', - `pushdef(`M4pos',`ifinstr(`$1',` at ',`patsubst(`$1',^.* at *)')')dnl - ifelse(M4pos,,,`move to M4pos;') setdir_(patsubst(`$1',` at.*')) - line invis from Here to Here popdef(`M4pos')')') - -# Two-terminal elements ################################################### - - `sl_transformer(linespec,keys, - input breaker keys, output breaker keys) - keys: - type=I|S - (type=I) loopwid=expr; (default dimen_*3/10) - cycles=n; (default 4) - core= A[ir]|M[n]|P[n]|K[n] - n=integer (default 2 lines) - (type=S) body=shaded "color"; - name=Body name; - (breaker default names BrI, BrO)' -define(`sl_transformer', - `setkeys_(`$2',name::N; type:I:N; cycles:4:N; core::N; body::N; - loopwid:3/20*dimen_; )dnl - ifelse(`$3'`$4',, - `ifinstr(m4type,S, - `source(`$1',G,,,m4body)', - `eleminit_(`$1'); m4atmp = rp_ang; m4slen = rp_len - ifelse(ifinstr(m4core,M,T,m4core,P,T,m4core,K,T),T, - `define(`m4nL',ifelse(len(m4core),1,2,substr(m4core,1)))dnl - define(`m4swd',(m4loopwid + dimen_/12+(m4nL-1)*dimen_/16))',dnl - `define(`m4swd',(m4loopwid*3/2))')dnl - { line to rvec_((m4slen-m4swd)/2,0) - {ifelse(m4name,,SL_box,m4name): [#linewid = linewid*m4scale - {L1: inductor(to vec_(0,-m4cycles*m4loopwid),,m4cycles,m4core, - m4loopwid)} - {point_(m4atmp) - L2: inductor(from vec_(m4swd,-m4cycles*m4loopwid) \ - to vec_(m4swd,0),,m4cycles,,m4loopwid)} - C2: last line.c; point_(m4atmp) ] with .L1.c at Here} - line from rvec_(m4swd,0) to rvec_((m4slen+m4swd)/2,0) } - line invis to rvec_(rp_len,0)') ', - `m4br_two(`sl_transformer',`$1',`$2',m4brk_(`$3',BrI),m4brk_(`$4',BrO), - ifelse(`$3',,,I)`'ifelse(`$4',,,O))') ') - - `Two-terminal box' - `sl_ttbox(linespec,keys,breaker keys,breaker keys) - keys= lgth=expr; wdth=expr; box=attributes; - supp=additional rotbox commands; name=Body name; - text="text"; - (breaker default names BrI, BrO)' -define(`sl_ttbox', - `setkeys_(`$2',`lgth:dimen_*3/4; wdth:dimen_*3/4; - name::N; box::N; text::N; supp::N')dnl - ifelse(`$3'`$4',, - `eleminit_(`$1') - {line to rvec_((rp_len-m4lgth)/2,0) - {ifelse(m4name,,,m4name:)rotbox(m4lgth,m4wdth,m4box,,m4supp) \ - with .W at Here } - {ifelse(m4text,,,`{m4text at rvec_(m4lgth/2,0)}') } - line from rvec_(m4lgth,0) to rvec_((rp_len+m4lgth)/2,0)} - line invis to rvec_(rp_len,0) ', - `m4br_two(`sl_ttbox',`$1',`$2',m4brk_(`$3',BrI),m4brk_(`$4',BrO), - ifelse(`$3',,,I)`'ifelse(`$4',,,O))') ') - -define(`m4brk_',`ifelse(`$1',,, - `ifelse(`$1',C,,`$1',O,box=fill 0,`$1')`'ifelse(`$2',,,;name=`$2')')') - - `sl_rectifier(ttbox args)' -define(`sl_rectifier', - `sl_ttbox(`$@') - { line from last [].Line.ne to last [].Line.sw - AC: ACsymbol(at last [].C+(-m4lgth/6, m4wdth/4),,,R) - DC: DCsymbol(at 2nd last [].C+( m4lgth/6,-m4wdth/4),,,R) } ') - - `sl_inverter(ttbox args)' -define(`sl_inverter', - `sl_ttbox(`$@') - { line from last [].Line.ne to last [].Line.sw - DC: DCsymbol(at last [].C+(-m4lgth/6, m4wdth/4),,,R) - AC: ACsymbol(at 2nd last [].C+( m4lgth/6,-m4wdth/4),,,R) } ') - - `sl_breaker(linespec, type=[A|C][D]; ttbox keys) - C is for curved breaker - D is for sl_drawout' -define(`sl_breaker', - `setkeys_(`$2',`lgth:brksiz_; wdth:brksiz_; name::N; type::N')dnl - ifinstr(m4type,C, - `ifinstr(m4type,D, - `m4ch_two(`cbreaker',`$1')', - `ifelse(m4name,,,m4name:) cbreaker(`$1')')', - `ifinstr(m4type,D, - `m4ch_two(`sl_ttbox',`$1',lgth=m4lgth;wdth=m4wdth;`$2';name=Br)', - `sl_ttbox(`$1',lgth=m4lgth;wdth=m4wdth;`$2')') ') ') - - `sl_reactor(linespec,keys,breaker keys,breaker keys) - keys= - diam=expr, - (Default breaker names BrI and BrO)' -define(`sl_reactor', - `setkeys_(`$2',`diam:sourcerad_*4/3; type::N')dnl - ifelse(`$3'`$4',, - `eleminit_(`$1') - { line to rvec_(rp_len/2,0) then to rvec_(rp_len/2,-m4diam/2); round - arc rad m4diam/2 cw from Here to rvec_(m4diam/2,m4diam/2) \ - with .c at rvec_(0,m4diam/2); round - line to rvec_(rp_len/2-m4diam/2,0) } - {[ box invis ht m4diam wid m4diam ] at rvec_(rp_len/2,0)} - line invis to rvec_(rp_len,0) ', - `m4br_two(`sl_reactor', `$1', lgth=m4diam*2;`$2', - m4brk_(`$3',BrI),m4brk_(`$4',BrO),ifelse(`$3',,,I)`'ifelse(`$4',,,O))')') - - `sl_busbar( linespec, nports, keys ) - Labels P1, P2 ... Pnports are defined on the line. - keys: line=line attributes; - port=D; (dotted ports) - The bus extends beyond the first and last points - by dimen_/5 which can be redefined as - line=chop -(expr)' -define(`sl_busbar', - `define(`m4npoints',`ifelse(`$2',,2,`$2')')dnl - setkeys_(`$3',`line:thick 1.6 chop -dimen_/5:N; port::N')dnl - [ tmp_ang = rp_ang - eleminit_(`$1',(m4npoints-1)*dimen_) - Start: last line.start; End: last line.end - for_(1,m4npoints,1, - `P`'m4x: (m4x-1)/(m4npoints-1) between Start and End dnl - ifinstr(m4port,D,` ;dot(at P`'m4x)')') - Line: line from Start to End m4line - Start: last line.start; End: last line.end - point_(tmp_ang) ] ') - - `sl_drawout(linespec, keys, R) - Drawout (i.e. plugin) chevron element; - keys: type=T; (truncated leads) - lgth=expr; (body size) - wdth=expr; - name=Name; (body name) - line= line attributes (e.g. thick 2) - arg3=R reverse direction' -define(`sl_drawout', - `setkeys_(`$2',`lgth:drosiz_; wdth:drosiz_; type::N; name::N; line::N')dnl - eleminit_(`$1',ifelse(m4type,T,m4lgth)) - ifelse(`$3',R,`{M4ds: Here; move to last line.end; rp_ang = rp_ang+pi_') - {line to rvec_(rp_len/2,0) - ifelse(m4name,,,m4name:) [ - S: Here; {line from rvec_(-m4lgth/2,m4wdth/2) to Here then - to rvec_(-m4lgth/2,-m4wdth/2) m4line } - E: rvec_(m4lgth/2,0); line from rvec_(0,m4wdth/2) to E then - to rvec_(0,-m4wdth/2) m4line ] with .S at Here - ifelse(m4type,T,, - line from last [].E to last [].E+vec_((rp_len-m4lgth)/2,0))} - ifelse(`$3',R,`rp_ang = rp_ang-pi_; move to M4ds}') - line invis to rvec_(rp_len,0) ') - -# Two-terminal utilities ################################################## - - `Breakers in the input and output lines:' - `m4br_two(`2-term element macroname in quotes', - linespec, body keys, - input breaker keys, - output breaker keys, - I|O|IO)' - `(Default breaker names are BrI and BrO)' -define(`m4br_two', - `define(`m4il',`ifinstr(`$6',I,`setkey_(`$4',lgth,brksiz_) m4lgth',0)')dnl - define(`m4ol',`ifinstr(`$6',O,`setkey_(`$5',lgth,brksiz_) m4lgth',0)')dnl - define(`m4bl',`setkey_(`$3',lgth,dimen_*4/3) m4lgth')dnl - eleminit_(`$2',dimen_*3) - M4start: Here; M4end: last line.end - M4cc: last line.c+vec_(((m4il*3/2)-(m4ol*3/2)),0) - M4ii: M4cc+vec_(-min((m4bl/2+m4il/2),distance(M4start,M4cc)-m4il),0) - line from M4start to ifinstr(`$6',I, - `M4ii+vec_(-m4il,0); sl_breaker(to M4ii,`$4';name=BrI)',M4ii) - M4oi: M4cc+vec_(min((m4bl/2+m4ol/2),distance(M4end,M4cc)-m4ol),0) - $1(from M4ii to M4oi,`$3') - ifinstr(`$6',O,`sl_breaker(to M4oi+vec_(m4ol,0),`$5';name=BrO)') - line to M4end - line invis from M4start to M4end ') - - `Chevrons in the input and output lines:' - `m4ch_two(`2-term element macroname in quotes', - linespec, body keys, - input breaker keys, - output breaker keys, - I|O|IO)' -define(`m4ch_two', - `define(`m4bl',`setkey_(`$3',lgth,dimen_*3/8) m4lgth')dnl - eleminit_(`$2',dimen_*3) - M4start: Here; M4end: last line.end - M4elem: $1(to rvec_(m4bl+2*drosiz_,0) with .c at last line.c,`$3') - sl_drawout(from last line.start-vec_(drosiz_,0) to last line.start,type=T,R) - line from last line.start to M4start - sl_drawout(from M4elem.end to M4elem.end+vec_(drosiz_,0),type=T) - line to M4end - line invis from M4start to M4end') - -# Composite elements ################################################### - - `sl_ct( at position, stem length, U|D|L|R|expr, - scale=expr) (default scale is 1.5)' -define(`sl_ct', - `[ setdir_(`$3'); setkey_(`$4',scale,1.5); linewid = linewid*m4scale - L: inductor(to vec_(2*dimen_/8,0),,2) - stemlen = ifelse(`$2',,dimen_/5,`$2') - line from L.start to L.start+vec_(0,-stemlen) - Ts: Here - line from L.end to L.end+vec_(0,-stemlen) - Te: Here - line from L.c to L.c+vec_(0,-stemlen) - Tc: Here - resetdir_ ] with .L.c at ifelse(`$1',,Here,patsubst(`$1',^ *at *)) ') - -# ####################################################################### - -# The following is defined in Circuit_macros 9.5.4 or later: - - `setkeys_(string,keysequence) - Invoke setkey_ on arg1 and each term in a - sequence of terms. - keysequence is a ;-separated sequence - of terms of the form - identifier:default value:N ' -define(`setkeys_',`Loopover_(`M4sk',`setkey_(`$1',patsubst(M4sk,:,`,')) dnl', - patsubst(`$2',;,`,'))') - -divert(0)dnl - - - u = dimen_ - - svg_font(sans-serif,9.0bp__,textoffset) - -define(`ctb',`[CT: sl_ct(,,`$1') - L: line up_ u/2 with .c at CT.L.c - BU: sl_breaker( up_ u*2/3,box=fill_(0)) - BR: sl_breaker( right_ ifelse(`$1',U,,-)u*3/4 \ - from CT.ifelse(`$1',U,Te,Ts),box=fill_(0))]') - -define(`tsbx',`sl_ttbox(`$1',`$2';lgth=u*0.4;wdth=u/2;text="TS")') -define(`lcdiam',u*0.85) -define(`lcirc',`[C: circle diam lcdiam ifelse(`$1',,,`$1') - line right C.diam*3/4 with .c at C - ifelse(`$2',,,`$2' at C.ne above ) - ifelse(`$3',,,`$3' at C.se below ) - ]') - -define(`Svee',`[S: Here; line from (sqrt(3),1)*(`$1') to S \ - then to (sqrt(3),-1)*(`$1')]') - -Box1: [ - V: line down_ u - {`"13.8 kV 3 ph + GND 60 Hz"' at V.start rjust} - { ellipse wid u/6 ht u/10 at Here+(0,u/3) - line right_ u/2 from last ellipse.e - ellipse wid u*4/3 ht u/2 "M1-00" } - AT: open_arrow(ToPos(,U,u), u/3*sqrt(3)/2, u/3) - dot(at 2nd last line.start) - { line left_ u then up_ u/3 ht u/10 wid u/10; dot } - line down_ u - { line up_ u/2 from last line.end+(-u/6,u/8) - sl_disk( left_ u/2 from last line.c,diam=u/3;name=L ); move to L.c - for_(45,315,90,`{line to L.c+(Rect_(L.diam,m4x)) chop u/5 chop 0}') } - T: dot - { sl_transformer(right_ 2*u,cycles=2;name=Tr1) - {"14400:120` 'V" at last [].n above} - { Svee(u/7) with .ne at Tr1.sw+(-u/15,-u/15) - Svee(u/7) with .nw at Tr1.se+( u/15,-u/15); ground(at last [].S) } - dot; fuse(right_ u,C) - line to (Here,1st ellipse) - MB: box wid 3/4*u ht 3/4*u with .sw at Here+(-u/8,0) - circle diam 5/8*u at last box "M" } - line down u/2 - CT1: ctb(U) with .BU.end at Here - {"500:5" rjust at CT1.CT.w } - { Svee(u/7) with .S at CT1.CT.Ts+( u/4,0); ground(at last [].S) } - line from MB.se+(-u/8,0) down_ MB.s.y-CT1.BR.y then to CT1.BR.end - line from CT1.L.start down_ 3/4*u - T2: dot - { line left_ u from T2; sl_drawout(,type=T,R); fuse(left_ u,C) - sl_transformer(left_ u/2,cycles=2;name=Tr2) - {"14400:120` 'V" at last [].n above} - {Ysymbol(with .ne at Tr2.sw+(u/8,0),type=G;size=u/6)} - {Ysymbol(with .nw at Tr2.se+(u/15,0),type=G;size=u/6)} - fuse(left_ u,C); sl_drawout(,type=T) - TS1: tsbx(left_ u*3/4) } - CT2: ctb(U) with .BU.end at Here - {"800:5" rjust at CT2.CT.w } - {Ysymbol(at CT2.CT.Ts+(u/2,-u/8),type=G;size=u/5)} - sl_breaker(up_ 2.0*u with .end at CT2.L.start, - lgth=u*0.75;wdth=u*0.8;name=M1;type=D) - {`"52-M1" "1200 A"' at M1} - CT3: ctb(D) with .BU.end at last line.start - {"800:5" ljust at CT3.CT.e } - BT3: CT3.BR.end - {Ysymbol(at CT3.CT.Te+(-u/2,-u/8),type=G;size=u/5)} - CT4: ctb(D) with .BU.end at CT3.L.start - {"600:5 MR" ljust at CT4.CT.e } - {Ysymbol(at CT4.CT.Te+(-u/2,-u/8),type=G;size=u/5)} - line from CT4.L.start down_ u; dot; - { line left_ u then up_ u/3 ht u/10 wid u/10; dot } - AB: arrow down_ u*2/3 ht u/3*sqrt(3)/2 wid u/3 - tsbx(left_ u from CT3.BR.end,text="SB") - line to (TS1.start,Here) - tsbx(left_ u*3/4); line left_ u/2+lcdiam/2 then up_ u/5 - CEDR3: lcirc("59" "M1","(3)") with .C.s at Here - Q: line left_ u*3/4 from CEDR3.C.w - { line left_ u/8 from Q.c+(u/8,CEDR3.C.rad) \ - then down_ CEDR3.C.diam then right_ u/8 } - CEDR4: lcirc("22" "M1","(1)") with .C.e at Here - { arrow right_ 3/2*u from CEDR3.C.e - lcirc("86" "M1","(1)") with .C.w at Here - arrow right_ u from last [].C.e - "TRIP M1" ljust above "TRIP S1" ljust } - { CEDR1: lcirc("59" "M1",,"(3)") with .C.w at (Q.c,T2) - { line from TS1.end to CEDR1.C.e } - CEDR2: lcirc("22" "M1",,"(3)") - arrow up u*2/3 from (CEDR2.e.x,CEDR2.n.y+u/3) - "TRIP S1" above; "TRIP M1" at last "".n above - move to last arrow.start - line from CEDR2.n to (CEDR2,Here) then to (CEDR1,Here) then to CEDR1.n - } - EDR5000: box wid TS1.end.x-CEDR4.C.w.x-u/8 ht last arrow.y-CEDR4.C.s.y+u/2 \ - with .n at last arrow "EDR-5000-M1" - M2: box wid u*1.1 ht u*0.85 at (TS1,CT4.BR) "PXM6000" "METER" - { line from M2.e to CT4.BR.end } - line from M2.w left_ u*3/4 - BT: dot - line to (EDR5000.w,Here)+(-u/5,0); Lft: Here - continue to (Here,CEDR2.C) then to CEDR2.C.w - Head: line down_ u*3/4 from AB.end - { ellipse wid u/6 ht u/10 at Here+(0,u/3) - line left_ u/2 from last ellipse.w - ellipse wid u*4/3 ht u/2 "M1-00" } - { line right_ u*3/4 then down_ u/8; - {line right_ u/10 with .c at Here} - {line right_ u/10 with .c at Here+(0,-u/8)} - pushdef(`dimen_',u/2) ground(at last line.c) popdef(`dimen_') } - { line down_ u/8 from Here+(u/2,0) - { pushdef(`dimen_',u/2) ground(at Here+(0,-u/8)) popdef(`dimen_') } - pushdef(`dotrad_',dotrad_/2) gap(down_ u/8,1) popdef(`dotrad_') } - BB: arrow <- down_ u/2 ht u/3*sqrt(3)/2 wid u/3 - sl_transformer(down_ u,name=Tr3) - { CUR2: lcirc("21" "T1",,"(1)") with .C.c at Tr3.e+(u,0) - CUR3: lcirc("49" "T1",,"(1)") with .C.w at CUR2.C.e - CUR1: lcirc("21" "T1","(1)") with .C.c at CUR2.C.c+(Rect_(CUR2.C.diam,60)) - } - line from BT to (BT.x,AB.y+u/10); X: Here; corner - CT5: ctb(U) with .BU.end at Tr3.L2.end - {"600:5" ljust below at CT5.CT.e } - corner(,at CT5.CT.Ts); ground - line from CT5.BR.end to (CUR3.C.e,CT5.BR.end)+(u/6,0) - continue to (Here,X) - tsbx(up_ u*4/3) - CUR5: lcirc("51G" "T1","(1)") with .C.s at Here - CUR6: lcirc("87" "T1","(1)") with .C.c at CUR5.C.c+(2*u,0) - arrow up_ u*2/3 from CUR5.C.n - CUR4: lcirc("86" "T1","(1)") with .C.s at Here - arrow up_ u*2/3 from CUR4.C.n - arrow <- from CUR4.C.w left CUR4.C.w.x-CUR1.C.x; corner - J2: line to CUR1.C.n - arrow from CUR6.C.w left_ u/3 then up_ CUR4.C.y-CUR6.C.y then to CUR4.C.e - tsbx(up_ u from CUR6.C.n) - line to (Here,CT2.BR) then to CT2.BR.end - crossover(from X to (CUR5,X)-(u*2/3,0),L,AB,J2); corner - tsbx(up_ u*4/3); dot - ETR5000: box wid CUR6.C.e.x-CUR1.C.x + u/5 ht CUR5.C.diam+u/2 \ - with .nw at (CUR1.C.n.x-u/8,CUR5.C.n.y+u/6) - {" ETR-5000-T1" wid 72bp__ at ETR5000.s above } - AL: arrow from Tr3.L2.c down_ u ht u/3*sqrt(3)/2 wid u/3; BX: Here - { line down_ u*2/3 from Here+( u/12,0) } - { line down_ u*2/3 from Here+(-u/12,0) } - { line down_ u*2/3; Bbot: Here } - { ellipse wid u/6 ht u/10 at Here+(0,-u/6) - line left_ u/2 from last ellipse.e - ellipse wid u*2 ht u/2 `"2000 A BUSWAY"' } - line from (CUR6,Bbot) to (CUR6,X); tsbx(to CUR6.C.s) - Outer: box ht AT.end.y-AB.end.y wid ETR5000.e.x-Lft.x + u/3 \ - with .nw at (Lft.x-u/6,AT.end.y) - `"USG-1A"' ljust \ - `"13.8 KV 1200 A"' ljust \ - `"50 kA SYM S.C."' ljust \ - `"(15 kV - 95 kV BIL RATED)"' ljust at Outer.nw+(0,-u*2/3) - ] +# slddiagsSVG.m4 +cct_init(svg_font(sans-serif,10bp__)) +include(libSLD.m4) +maxpsht = 30 + +Pic1: [ +define(`TrDeltaWye', + `sl_transformer(down_ elen_ `$1',type=S) + { Deltasymbol(at last [].M1); Ysymbol(at 2nd last [].M2,,D) } ') + + T: dot + switch(up_ elen_); {"Public supply" above} + Bus1: sl_busbar(right_ 5*dimen_,6,port=D) with .c at T + {"svg_small(20 kV)" at Bus1.Start above ljust} + S1: switch(from Bus1.P1-(0,elen_) up_ elen_) + S2: switch(from Bus1.P2-(0,elen_) up_ elen_) + TRF1: sl_transformer(from Bus1.P3 down_ elen_,type=S,,,Delta,Y) + arrow down_ dimen_/3 + TRF2: sl_transformer(from Bus1.P4 down_ elen_,type=S,,,Delta,Y) + arrow down_ dimen_/3 + TRF3: sl_transformer(from Bus1.P5 down_ elen_,type=S,,,Delta,Y) + arrow down_ dimen_/3 + S3: switch(from Bus1.P6-(0,elen_) up_ elen_) + Bus2: sl_busbar(right_ 1.5*dimen_,3,port=D) with .c at Bus1.P1+(0,-dimen_*3) + {"svg_small(20 kV)" at Bus2.Start above ljust} + {"svg_small(1.25 MVA)" at Bus2.P2 below} + S4: switch(from Bus2.P2 to S1.start) + TRF4: sl_transformer(from Bus2.P1 down_ elen_,type=S,,,Delta,Y) + S4: switch(from Bus2.P3+(0,-elen_) to Bus2.P3) +] + +Pic2: [ +# https://tex.stackexchange.com/questions/597643/draw-a-power-system-network + B1: sl_busbar(up_ dimen_*4/3,3) + sl_transformer(right_ 2*dimen_ from last [].P2, + type=S;body=shaded "lightgray"); variable(,,,dimen_*3/2) + B2: sl_busbar(up_ dimen_*4/3,3) + { line left_ dimen_/2 from B2.P1 + C1: capacitor(down_ dimen_/2); ground(,T) } + line right_ dimen_/2 + { line to (Here,C1.start); C2: capacitor(to (Here,C1.end)); ground(,T) } + ebox(right_ 3.5*dimen_, 2.5*dimen_, dimen_/5, 0.75) + { line to (Here,C1.start); C3: capacitor(to (Here,C1.end)); ground(,T) } + line right_ dimen_/2 + B3: sl_busbar(up_ dimen_*4.5,6) + line right_ dimen_*3/4 from B3.P1; box wid dimen_*3 ht dimen_*.6 \ + shaded rgbstring(0.85, 0.65, 0.13) "Static Load" + line right_ dimen_*3/4 from B3.P2; box wid dimen_*3 ht dimen_*.6 \ + shaded rgbstring(0.79, 0.59, 0.57) "Electronic Load" + sl_disk(right_ dimen_ from B3.P3, + text="A/C";circle=shaded rgbstring(0.2, 0.8, 0.2);diam=dimen_*3/4) + sl_disk(right_ dimen_ from B3.P4, + text="M";circle=shaded rgbstring(0.21, 0.47, 0.86);diam=dimen_*3/4) + sl_disk(right_ dimen_ from B3.P5, + text="M";circle=shaded rgbstring(0.2, 0.6, 0.8);diam=dimen_*3/4) + sl_disk(right_ dimen_ from B3.P6, + text="M";circle=shaded rgbstring(0.2, 0.63, 0.8);diam=dimen_*3/4) + sl_disk(left_ dimen_ from 1/2 between B3.P1 and B3.P2, + text="svg_small(DER_A)"; circle=shaded rgbstring(0.78, 0.36, 0.3);diam=dimen_*3/4) +] with .nw at last [].sw + (100bp__,120bp__) + +Pic3: [ +define(`shadedb',`shaded rgbstring(0.39,0.50,0.93)') +Loopover_(`LR', # loop to take advantage of symmetry + `define(`opposite',`ifelse(LR,left,right,left)')dnl + ifelse(LR,left,L,R)`'side: [ + sl_generator(LR dimen_/2,type=B;name=G1;circle=shadedb,box=shadedb) + { move from G1 opposite last circle.rad*3/2 down_ last circle.rad + ifelse(LR,left,`Delta',`Wye')symbol(,size=sourcerad_*2/3) } + T1: sl_transformer(opposite dimen_*3/2,name=Tx) + Bus1: sl_busbar(up_ dimen_*3/2,3,) with .P2 at Here + Br1: sl_breaker(from Bus1.P3 opposite elen_,box=shadedb) + line opposite dimen_*4/3 + Br2: sl_breaker(from Bus1.P1 opposite elen_,box=shadedb) + Br3: sl_breaker(down_ dimen_,box=shadedb) + Bus2: sl_busbar(opposite dimen_,3) with .P2 at Here + T2: sl_transformer(down_ dimen_ from Bus2.P2,name=X2) + sl_disk(down_ dimen_/2,type=B;text="SM";name=SM1;circle=shadedb,box=shadedb) + { move from last circle opposite sourcerad_*3 + Wyesymbol(,type=G`'ifelse(LR,right,L);size=sourcerad_*2/3) } + ]', + left,right) + "Bus 1" at Lside.Bus1.top above + "Bus 2" at Rside.Bus1.top above + "Bus 3" at Lside.Bus2.w above + "Bus 4" at Rside.Bus2.e above + "TL`'svg_sub(1) 50 km 69 kV" at 1/2 between Lside.Br1 and Rside.Br1 above + "TL`'svg_sub(2) 30 km" ljust "69 kV" ljust at Lside.Br2.end + (-18bp__,12bp__) + "TL`'svg_sub(2) 20 km" ljust "69 kV" ljust at Rside.Br2.end + (-18bp__,12bp__) + "G`'svg_sub(1) 50 MVA" ljust "13.8 kV" ljust at Lside.G1.w+(-25bp__,-32bp__) + "G`'svg_sub(2) 30 MVA" ljust "13.8 kV" ljust at Rside.G1.w+(10bp__,-28bp__) + "T`'svg_sub(1) 50 MVA" "13.8/69 kV svg_Delta/Y" \ + at Lside.Tx.s+(-2bp__,-25bp__) + "T`'svg_sub(2) 30 MVA" "69/13.8 kV Y/svg_Delta " \ + at Rside.Tx.s+(2bp__,-27bp__) + "T`'svg_sub(3) 50 MVA" rjust "13.8/69 kV Y/svg_Delta " rjust \ + at Lside.X2.w+(-4bp__,0) + "T`'svg_sub(4) 20 MVA" ljust "69/6.9 kV Y/svg_Delta " ljust \ + at Rside.X2.e+(4bp__,0) + "SM`'svg_sub(1) 30 MVA" rjust "13.8 kV" rjust at Lside.SM1.w+(-4bp__,0) + "SM`'svg_sub(2) 20 MVA" ljust "6.9 kV" ljust at Rside.SM1.e+( 4bp__,0) +] with .nw at (Pic1.w,last [].sw + (0,-15bp__)) command "</g>" diff --git a/graphics/circuit_macros/examples/svg/EscherSVG.m4 b/graphics/circuit_macros/examples/svg/EscherSVG.m4 index 191123754e..637f99b29a 100644 --- a/graphics/circuit_macros/examples/svg/EscherSVG.m4 +++ b/graphics/circuit_macros/examples/svg/EscherSVG.m4 @@ -2,6 +2,8 @@ # EscherSVG.m4 # https://tex.stackexchange.com/questions/129274/showcase-of-optical-illusions-made-with-tex-latex-luatex-context threeD_init +[] +ifelse(1,1,` [ u=1/2.54 # unit size; could use scale for this @@ -107,82 +109,67 @@ define dorgb { gg = $2 to last line.end-UX*(weststeps+1) then to last line.end \ then to proj(eaststeps+1,0,-f) then to proj(eaststeps+1,0,eb*f) ] +') ifelse(1,1,` +define(`DPL',`(project(`$1',`$2',`$3'))') +define(`ISL',` + S1: `$2'; E1: `$2' + `$3' + S2: `$4'; E2: `$4' + `$5' + `$1': line from S2 to intersect_(S1,E1,S2,E2) ') + [ - setview(-45,20) - bwid = 2.8 - bh = 1.5 bdp = 1.8 - bth = 0.3 - A: Project(0,0,0) - AA: A+Project(bth,bth,-bth) - B: Project(0,bwid,0) - BB: B+Project(bth,-bth,-bth) - C: Project(bdp,bwid,0) - D: Project(bdp,0,0) - E: Project(0,0,-bh) - F: Project(bdp,0,-bh) - G: Project(bdp,bwid,-bh) - H: B + Project(0,0,-bh) - - line from A to B then to C then to D then to A then to E then to F \ - then to G then to H then to E - line from C to G - line from A+Project(bth,bth,0) to B+Project(bth,-bth,0) \ - then to C+Project(-bth,-bth,0) - L1: line to D+Project(-bth,bth,0) - L2: line to A+Project(bth,bth,0) - L4: line from E+Project(bth,bth,0) to H+Project(bth,-bth,0) - L3: line to C+Project(-bth,-bth,-bh) - line to F+Project(-bth,bth,0) then to A+Project(bth,bth,-bh) - - L5: line from D+Project(-bth,0,-bth) to A+Project(bth,0,-bth) - line to E+Project(bth,0,bth) - L6: line to Here+Project(0,bwid-2*bth,0) - L7: line from D+Project(0,bth,-bth) to C+Project(0,-bth,-bth) - line to G+Project(0,-bth,bth) - L8: line to Here+Project(-bdp+2*bth,0,0) - Tmp: line invis from L8.start+Project(-bth,0,0) up bh - line from Tmp.start to Intersect_(Tmp,L7) - Tmp: line invis from L8.end up bh - line from L8.end to Intersect_(Tmp,L7) - line from Intersect_(Tmp,L1) to BB+Project(bth,0,0) - Tmp: line invis to Here+Project(bdp,0,0) - line from Tmp.start to Intersect_(Tmp,L1) - - Tmp: line invis from H up bh - line from H to Intersect_(Tmp,L7) - line from Intersect_(Tmp,L1) to B+Project(bth,-bth,0) - - Tmp: line invis from AA to AA+Project(0,bwid,0) - Tmp2: line invis up bh from L6.end - line from Intersect_(Tmp,L2) to Intersect_(Tmp2,Tmp) \ - then to Intersect_(Tmp2,L1) - line from L6.end to Intersect_(Tmp2,L7) - - Tmp: line invis down bh from AA - line from Intersect_(Tmp,L6) to Intersect_(Tmp,L5) - - Tmp: line invis down bh from D - line from D to Intersect_(Tmp,L6) - line from Intersect_(Tmp,L4) to F+Project(-bth,bth,0) - - Tmp: line invis from L5.start to L5.start+Project(0,0,-bh) - move to E+Project(0,2*bth,0) - Tmp2: line invis to Here+Project(bdp,0,0) - line from L5.start to Intersect_(Tmp,L6) - line from Intersect_(Tmp,L4) to Intersect_(Tmp,Tmp2) \ - then to Intersect_(Tmp2,L4) - - Tmp: line invis from L7.start to L7.start+Project(0,0,-(bh-bth)) - line from L7.start to Intersect_(Tmp,L6) - - move to G+Project(-2*bth,0,0) - Tmp2: line invis to Here+Project(0,-bwid,0) - line from Intersect_(Tmp2,L3) to Intersect_(Tmp,Tmp2) - line from Intersect_(Tmp,L4) to Intersect_(Tmp2,Tmp) - + bwd = 2.8 + bht = 1.5 + bth = bwd/10 + setview(-45,20,0) + + L1: line from DPL(0,0,0) to DPL(0,0,bht) \ + then to DPL(0,bwd,bht) \ + then to DPL(bdp,bwd,bht) \ + then to DPL(bdp,bwd,0) \ + then to DPL(bdp,0,0) \ + then to DPL(0,0,0) + L2: line from DPL(bth,bth,bht) to DPL(bth,bwd-bth,bht) \ + then to DPL(bdp-bth,bwd-bth,bht) \ + then to DPL(bdp-bth,bth,bht) \ + then to DPL(bth,bth,bht) + L3: line from DPL(bth,bth,0) to DPL(bth,bwd-bth,0) \ + then to DPL(bdp-bth,bwd-bth,0) \ + then to DPL(bdp-bth,bth,0) \ + then to DPL(bth,bth,0) + L4: line from DPL(bdp,bth,bht-bth) to DPL(bdp,bwd-bth,bht-bth) \ + then to DPL(bdp,bwd-bth,bth) \ + then to DPL(bth+bth,bwd-bth,bth) + L5: line from DPL(bdp-bth,0,bht-bth) to DPL(bth,0,bht-bth) \ + then to DPL(bth,0,bth) \ + then to DPL(bth,bwd-bth-bth,bth) + L6: line from DPL(0,0,bht) to DPL(bdp,0,bht) \ + then to DPL(bdp,bwd,bht) + L7: line from DPL(0,0,0) to DPL(0,bwd,0) \ + then to DPL(bdp,bwd,0) + ISL(L8,L4.start,UPy_,L4.end,UPz_) + ISL(L9,L4.start,UPy_,DPL(0,bwd,0),UPz_) + ISL(L10,L4.start,UPy_,L5.end,UPz_) + ISL(L11,L5.end,UPy_,L4.start,UPz_) + ISL(L12,L5.end,UPy_,DPL(bdp,0,bht),UPz_) + ISL(L13,L5.end,UPy_,L5.start,UPz_) + ISL(L14,DPL(bdp-bth,bth,bht),UPy_,DPL(bth,bwd-bth-bth,bht-bth),UPz_) + ISL(L15,L2.start,UPx_,DPL(bth,bwd-bth-bth,bht-bth),UPy_) + ISL(L16,DPL(bdp-bth,bth,bht),UPy_,DPL(bth,bwd-bth,bht),UPz_) + ISL(L17,DPL(bdp-bth,bth,bht),UPy_,DPL(bth+bth,bwd-bth,bht-bth),UPz_) + ISL(L18,DPL(bdp-bth,bth,bht),UPy_,DPL(bth+bth,bwd-bth,bht-bth),UPx_) + ISL(L19,L3.start,UPy_,L5.start+DPL(0,0,-bht+bth+bth),UPx_) + ISL(L20,L3.start,UPy_,L5.start+DPL(0,0,-bht+bth+bth),UPz_) + ISL(L21,L3.start,UPy_,DPL(bdp-bth,bth,0),UPz_) + ISL(L22,L3.start,UPy_,L4.start+DPL(0,0,-bht+bth+bth),UPz_) + ISL(L23,DPL(bth,bwd-bth,0),UPx_,L4.start+DPL(0,0,-bht+bth+bth),UPy_) + ISL(L24,L5.start,UPx_,DPL(bth,bth,bth),UPz_) + ISL(L25,L4.start,UPy_,DPL(bdp-bth,bwd-bth,bth),UPz_) + +ifelse(0,1,`for i=1 to 7 do { exec sprintf("\"L%g.s\" at L%g.start",i,i) } + for i=8 to 10 do { exec sprintf("\"L%g\" at L%g",i,i) }') ] with .sw at last [].se+(0.2,0) ') .PE diff --git a/graphics/circuit_macros/examples/svg/EyeSVG.m4 b/graphics/circuit_macros/examples/svg/EyeSVG.m4 new file mode 100644 index 0000000000..457abb8081 --- /dev/null +++ b/graphics/circuit_macros/examples/svg/EyeSVG.m4 @@ -0,0 +1,53 @@ +.PS +# EyeSVG.m4 +gen_init + +define(`eye',`[ u = $1; v = 0.47*u; w = 0.25*u + shade(1, + arc thick 0 from (u/2,0) to (-u/2,0) with .c at (0,-u/3) + arc thick 0 to (u/2,0) with .c at (0,u/3) ) + circle diam v fill_(0.24) at (0,0) + circle diam w fill_(0) at (0,0) + circle thick 0 diam last circle.diam/2 fill_(1) at last circle.nw + circle diam last circle.diam-lthick at last circle outlined graystring(0.9) + ] ') + + skale = 2/3 + Bx: box wid 11*skale ht 8.5*skale fill_(0) at (0,0) + C[0]: Bx.se; C[1]: Bx.nw + d[5] = 0.92*Bx.ht + d[4] = 0.78*Bx.ht + d[3] = 0.62*Bx.ht + d[2] = 0.40*Bx.ht + d[1] = 0.25*Bx.ht + ane = atan2(Bx.ht,Bx.wid)*rtod_ + dax = 360/64 + da = 1 + for a=-int(ane/dax)*dax to 180-ane by dax do { + T1: intersect_(Bx.ne,C[(a>ane)],Bx,(Rect_(1,a+da))) + T2: intersect_(Bx.ne,C[(a>ane)],Bx,(Rect_(1,a))) + line outlined "white" shaded "white" from Bx to T1 then to T2 then to Bx + line outlined "white" shaded "white" from Bx to T1*(-1) \ + then to T2*(-1) then to Bx + } + for i=5 to 2 by -1 do { + C[i]: circle diam d[i] fill_(0) at Bx + for a=0 to 359 by dax do { + T1: Rect_(d[i]/2,a) + T2: Rect_(d[i]/2,a-da*2) + nx = int(distance(T1,T2)/lthick*1.5+0.5) + for h = 1 to nx-1 do { + spline 0.55 outlined "white" from h/nx between T1 and T2 \ + to 0.8 between Bx and T2 then to (Rect_(d[i]/4,a+31)) } + } + } + C[1]: circle thick 2 diam d[1] at Bx fill_(0.1) + eye(d[1]-4bp__) at (0,0) + for a=0 to 359 by dax do { + T1: (Rect_(d[1]/2-1bp__,a)) + T2: (Rect_(d[1]/2-1bp__,a+dax/2)) + line thick 0.4 from T1 to T2 then to 0.5 between Bx and T2 \ + then to 0.5 between Bx and T1 then to T1 shaded "white" + } + +.PE diff --git a/graphics/circuit_macros/examples/svg/FlowSVG.m4 b/graphics/circuit_macros/examples/svg/FlowSVG.m4 index f0f5b6df71..05f411cd6a 100644 --- a/graphics/circuit_macros/examples/svg/FlowSVG.m4 +++ b/graphics/circuit_macros/examples/svg/FlowSVG.m4 @@ -75,7 +75,7 @@ Repeatuntil: Frepeatuntil("svg_it(n svg_gt 5)",,,Fbox("Task"), "svg_it(.S)" at Repeatuntil.S rjust below "svg_it(.E)" at Repeatuntil.E ljust "svg_it(.W)" at Repeatuntil.W rjust - "svg_tt(`Frepeatuntil')" below at Repeatuntil.se +(-0.0,0.2) + "svg_tt(`Frepeatuntil')" below at Repeatuntil.se +(-0.0,0.1) Ifthenelse: Fifthenelse("svg_it(A svg_lt B)",,, Fbox("False"), diff --git a/graphics/circuit_macros/examples/svg/FourbarSVG.m4 b/graphics/circuit_macros/examples/svg/FourbarSVG.m4 index 208e817822..376fbe8efe 100644 --- a/graphics/circuit_macros/examples/svg/FourbarSVG.m4 +++ b/graphics/circuit_macros/examples/svg/FourbarSVG.m4 @@ -35,8 +35,8 @@ define(`pivot',`[ B2: Cintersect(A0,b-a,B0,c) arc dashed from B1 to B2 with .c at B0 - A0B1: line thick 1.6 from A0 to B1 chop 2 chop - line thick 1.6 from B0 to B1 chop 2 chop "svg_it(c)" ljust + A0B1: line thick 1.6 from A0 to B1 chop 2 chop 0 + line thick 1.6 from B0 to B1 chop 2 chop 0 "svg_it(c)" ljust circle fill_(1) at B1; "svg_it(B`'svg_sub(1))" wid 3 at B1+(5,0) A1: circle fill_(1) at LCintersect(A0B1,A0,a,R) "svg_it(A`'svg_sub(1))" at A1+(5,0) diff --git a/graphics/circuit_macros/examples/svg/GeometrySVG.m4 b/graphics/circuit_macros/examples/svg/GeometrySVG.m4 index 5dc1284d08..de5fc62523 100644 --- a/graphics/circuit_macros/examples/svg/GeometrySVG.m4 +++ b/graphics/circuit_macros/examples/svg/GeometrySVG.m4 @@ -1,14 +1,12 @@ .PS # Geometry.m4 +# Some constructions from https://tex.stackexchange.com/ gen_init - maxpswid = 10 - scale = 5/4 -Fig1: [ - - A: Here; "A" at A above - B: A+(-1,-3.5); "B" at B below rjust - C: B+(4.6,0); "C" at C below ljust +Fig1: [ ls = 2/3 # local scale + A: Here; "A" at A above + B: A+(-1*ls,-3.5*ls); "B" at B below rjust + C: B+(4.6*ls,0); "C" at C below ljust AB: line from A to B BC: line from B to C CA: line from C to A @@ -45,181 +43,45 @@ Fig1: [ line dashed from X to Y chop -linewid/2 RightAngle(A,Z,Y) - ] scaled 0.8 - -Fig2: [ -#.PS -# Lyap.m4 -threeD_init -#scale = 1/1.2 - -viewaz = 30 -viewel = 18 -setview(viewaz,viewel) - -Origin: Project(0,0,0) -# Components of view vector W -w1 = view3D1 -w2 = view3D2 -w3 = view3D3 -# Shape factor of the ellipse on the xy plane -q = Cos(40) - -# cost function -h = 0.5 -c = 1 -# The projected ellipse is (x/q)^2 + y^2 = c. -# The cost is v = c+h -define(`vs',``$2'*q*cos(`$1'),`$2'*sin(`$1')') -define(`vp',`vs(`$1',`$2'),0') -define(`vx',`sum3D(vp(`$1',`$2'),0,0,h+(`$2')^2)') - -# The gradient of v is (2x/q, 2y, -1) and the line -# separating front and back is W^T * grad(v) = 0 -# This line intersects the projected ellipse at -# x1,y1 and x2,y2 - ap = w2^2*q^2/w1^2+1 - bp = -w2*w3*q^2/w1^2 - cp = w3^2*q^2/4/w1^2-c - m = sqrt(bp^2-4*ap*cp) - y1 = (-bp+m)/ap/2 ; x1 = (w3-2*y1*w2)*q/2/w1 - y2 = (-bp-m)/ap/2 ; x2 = (w3-2*y2*w2)*q/2/w1 - t1 = atan2(y1,x1) - t2 = atan2(y2,x2) - theta1 = min(t1,t2) - theta2 = max(t1,t2) - -# tangent curve - nT = 11 - for i = 0 to nT do { - y = y1 + (y2-y1)/nT*i - theta = atan2(y,(w3-2*y*w2)*q/2/w1) - r = y/sin(theta) - T[i]: Project(vx(theta,r)) - } - -# front and back parts of the top curve - n = 12 - for i = 0 to n do { - theta = theta1 + (theta2-theta1)/n*i - F[i]: Project(vx(theta,c)) - Fp[i]: Project(vp(theta,c)) - } - for i = 0 to n do { - theta = theta2 + (theta1+twopi_-theta2)/n*i - B[i]: Project(vx(theta,c)) - Bp[i]: Project(vp(theta,c)) - } - -# trajectory -rotations = 1.55 -nx = 7 -thetas = 75*dtor_ -thetaf = thetas - rotations*twopi_ -rx = c*0.9 -beta = exp(log(.5)/20) - -define(`defX',` rx = `$5' ; np = np-1 - ts = `$1' ; tf = `$2' - for i = 0 to `$3' do { - tha = ts + (tf-ts)*i/(`$3') - for thx = tha to -twopi_ by twopi_ do {} - `$4'[i]: Project(vx(thx,rx)) - Xp[np]: Project(vp(thx,rx)) - np = np+1 - rx = beta*rx - }') - -np = 1 -defX(thetas,theta1,nx,X1,rx) -defX(theta1,theta2-twopi_,nx,X2,rx/beta) -defX(theta2-twopi_,theta1-twopi_,nx,X3,rx/beta) -defX(theta1-twopi_,thetaf,5,X4,rx/beta) - -# First draw the inside back -# B is the back curve -# T is the outline -ifpstricks(` -\psset{gradbegin=lightgray,gradend=darkgray,gradlines=1000} -\pscustom[fillstyle=gradient,gradmidpoint=0.7]{ - fitcurve(B,n) - for i = 0 to nT do {TT[i]: T[nT-i] } - fitcurve(TT,nT) -\relax} ', -` fitcurve(B,n) - for i = 0 to nT do {TT[i]: T[nT-i] } - fitcurve(TT,nT) ') - -# Centre axis -thinlines_ -line from Origin to Project(0,0,h) -# F[0] is the leftmost point of the front curve -line from F[0] to Fp[0] -# F[n] is the rightmost point of the front curve -line from F[n] to Fp[n] -thicklines_ - -# Now draw the outside front -ifpstricks(` -\newgray{gray1}{0.9}% -\newgray{gray2}{0.4}% -\psset{gradbegin=gray1,gradend=gray2,gradlines=1000} -\pscustom[linewidth=0pt,fillstyle=gradient,gradmidpoint=0.99]{ - fitcurve(F,n) - fitcurve(T,nT) -\relax} ', -` shade(1,fitcurve(F,n) - fitcurve(T,nT)) ') -# T is the limit curve of visibility - fitcurve(T,nT) -# F is the top front - fitcurve(F,n) -# Front and back projections of the top on xy - fitcurve(Fp,n) - fitcurve(Bp,n) - -# The trajectory in pieces, to allow dashed parts - fitcurve(X1,nx) - fitcurve(X2,nx,dotted 0.025) - fitcurve(X3,nx) - fitcurve(X4,3,dotted 0.015) - arca(from X4[4] to X4[2],ccw,0.3,<-) - -# Projected trajectory - np = np-2 - fitcurve(Xp,np-1) - arca(from Xp[np] to Xp[np-2],ccw,0.18,<-) - "svg_it(X(t))" at Xp[np]-(2bp__,0) ljust - -# Axes and vertical lines -thinlines_ - line from X1[0] to Xp[0] -arrow from Origin to Project(1.5,0,0) -"svg_it(x)`'svg_sub(1)" rjust below -arrow from Origin to Project(0,1.5,0) -"svg_it(x)`'svg_sub(2)" wid 10bp__ ljust -line dashed from Project(0,0,h) to F[n/2] chop 0 chop arrowht/4 -arrow from F[n/2] to Project(0,0,2) -"svg_it(v(X))" ljust - -"svg_it(0)" at Origin+(0,1 pt__) below -"svg_Omega" at Project(0,0.9*c,0) above -"svg_it(v(X) = c)" at (Project(vp(100*dtor_,c)))+(2bp__,0) above ljust - -#.PE - ] scaled 1.5 with .w at last [].e+(0.5,0) + ] + +Fig2: [ ls = 3/4 # local scale +# https://tex.stackexchange.com/questions/593272/drawing-complex-geometry + P: dot(at Here); "P" at P.s below + N: dot(at P+(3.5*ls,1.5*ls)); "N" at N.se ljust below + O: dot(at (N,P)); "O" at O.s below + R: dot(at 1/3 between O and P);"R" at R.s below + M: dot(at (R,N)); "M" at M.se ljust below + Q: dot(at (M.x,M.y+distance(M,N)/distance(N,O)*distance(P,O)));"Q" at Q.e ljust + line from P to Q then to N then to O + B: line to P chop -0.3 + line from M to N + Pu: line from R to Q chop 0 chop -0.3 + H: line from P to N chop 0 chop -0.3 + X: dot(at Intersect_(Pu,H)); "X" at X.se ljust below + thinlines_ + RightAngle(Q,M,N) + RightAngle(Q,N,H.end) + RightAngle(N,O,B.start) + ArcAngle(N,P,Q,0.4); "svg_beta" at last arc.ne above ljust + ArcAngle(O,P,N,0.5); "svg_alpha" at last arc.start+(5bp__,8bp__) + ArcAngle(R,Q,N,0.5); "svg_alpha" at last arc.start+(8bp__,-5bp__) + ] with .w at Fig1.e+(-0.4,0) Fig3: [ +# FourbarSVG.m4 # https://tex.stackexchange.com/questions/609452/help-drawing-a-more-sophisticated-right-triangle-with-tikz-or-something-else -gen_init - unit = 0.8 + textkht = 12/72 + unit = 0.6 C: Here; { "C" at C rjust below } B: C+(4*unit,0); { "B" at B ljust below } A: C+(0,3*unit); { "A" at A rjust above } H: PerpTo(C,A,B); { "H" at H ljust above } line from C to H then to B then to C shaded rgbstring(0.5,0.8,0.9) +# line from C to H then to B then to C shaded "CornflowerBlue" line from C to H then to A then to C shaded rgbstring(0.8,0.9,0.7) +# line from C to H then to A then to C shaded "SpringGreen" ArcAngle(C,A,B,unit*0.4) ArcAngle(C,A,B,unit*0.5) ArcAngle(A,B,C,unit*0.5,,"svg_theta" rjust) @@ -228,6 +90,66 @@ gen_init RightAngle(B,C,A,unit*0.17) RightAngle(C,H,A,unit*0.17) - ] with .sw at Fig2.se+(0.2,0) + ] with .nw at Fig1.sw+(0.2,-0.3) + +Fig4: [ + +# FourbarSVG.m4 +# https://tex.stackexchange.com/questions/563831/how-to-draw-four-bar-linkage-with-center-of-mass +ls = 1/25.4 # local scale + + a = 18*ls + b = 73*ls + c = 47*ls + d = 72*ls + A0: Here + B0: A0+(d,0) + circlerad = 1*ls + +define(`pivot',`[ + C: circle + line down_ 4*ls from C+(2*ls,0) + arc from last line.start to C+(-2*ls,0) with .c at C + line down_ 4*ls + B: line thick 1.6 right 7*ls with .c at (C,Here) + thinlines_ + sep = 0.9*ls + nhash = B.len/sep + for i=0 to nhash do { line down sep left sep from B.end-(i/nhash*B.len,0) } + thicklines_ + ]') + + pivot with .C at A0; "A`'svg_sub(0)" at A0-(5,0)*ls + circle dashed rad a at A0 + pivot with .C at B0; "B`'svg_sub(0)" at B0-(5,0)*ls + "d = A`'svg_sub(0)B`'svg_sub(0)" at 0.5<A0,B0> + + B1: Cintersect(A0,a+b,B0,c) + B2: Cintersect(A0,b-a,B0,c) + arc dashed from B1 to B2 with .c at B0 + + A0B1: line thick 1.6 from A0 to B1 chop 2*ls chop 0 + line thick 1.6 from B0 to B1 chop 2*ls chop 0 "c" ljust + circle fill_(1) at B1; "B`'svg_sub(1)" wid 3*ls at B1+(5,0)*ls + A1: circle fill_(1) at LCintersect(A0B1,A0,a,R) + "A`'svg_sub(1)" at A1+(5,0)*ls + + A2: b/(b-a) between B2 and A0; "a" at 0.4<A2,A0> above rjust + "b" at 0.4<A1,B1> above rjust + A2B2: line thick 1.6 from A2 to B2 + line thick 1.6 from B0 to B2 chop 2*ls chop 0 + circle fill_(1) at B2; "B`'svg_sub(2)" at B2+(5,0)*ls + circle fill_(1) at A2; "A`'svg_sub(2)" at A2+(5,0)*ls + + thinlines_ + line from B0+(3*ls,0) right 4*ls + ArcAngle(Here,B0,B1,5*ls) ->; "svg_psi`'svg_sub(0)" at last arc.ne above ljust + ArcAngle(B1,B0,B2,8*ls) ->; "svg_psi" at last arc.n+(-3*ls,0) above + ArcAngle(A1,A0,B2,b*0.45) ->; "svg_theta" at last arc.start+(0,4*ls) + line from A0+(3*ls,0) right 8*ls + ArcAngle(Here,A0,B1,9*ls) ->; "svg_theta`'svg_sub(0)" \ + at last arc.start+(2,2)*ls + + ] with .nw at Fig3.ne+(0.2,0.2) .PE diff --git a/graphics/circuit_macros/examples/svg/LoglogSVG.m4 b/graphics/circuit_macros/examples/svg/LoglogSVG.m4 index d6b29d0fa0..37e6d746c6 100644 --- a/graphics/circuit_macros/examples/svg/LoglogSVG.m4 +++ b/graphics/circuit_macros/examples/svg/LoglogSVG.m4 @@ -1,7 +1,9 @@ .PS # LoglogSVG.m4 gen_init(svg_font(sans-serif,11bp__)) +maxpswid = 12 +LL: [ define(`rint',`sign(`$1')*int(abs(`$1')+.5)') S:[ horiz = 4 @@ -76,6 +78,553 @@ Q: box invis fill_(1) wid 0.80 ht 0.18 \ # box wid S.wid ht S.ht at S # print (S.wid,S.ht)/(1 pc__) + command "</g>" # end font +] # LL +#showbox_ + +Cons: [ +#.PS +## Consumption.m4 +#gen_init +svg_font(Helvetica,10pt__) + +#svg_rot_init(test) +svg_rot_init(LoglogSVG) + +divert(-1) + `brace(linespec,depth,arm thickness,attributes) + Curly brace along linespec + default depth is linewid/5 + attributes = eg + thick 0.4 outlined "string" shaded "string" + (default black)' +define(`brace',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + M4brS: last line.start; M4brE: last line.end + [ brdepth = ifelse(`$2',,linewid/5,`$2') + brthick = ifelse(`$3',,brdepth/6,`$3') + define(`m4braceattribs', + `ifelse(`$4',,`thick 0.4 shaded rgbstring(0,0,0)',`$4')')dnl + tension = 0.55 + halfwid = distance(M4brS,M4brE) + smallrad = brdepth-brthick + bigrad = brdepth+brthick + for sgn=1 to -1 by -2 do { + S: rvec_(sgn*halfwid/2,0) + A: S+vec_(0,smallrad/2) + B: vec_(0,smallrad/2) + T: vec_(0,brdepth) + C: vec_(0,bigrad/2) + D: vec_(sgn*halfwid/2,bigrad/2) + {spline tension m4braceattribs \ + from S to tension between S and A \ + then to tension between A-vec_(sgn*bigrad/2,0) and A \ + then to A-vec_(sgn*bigrad/2,0) \ + then to B+vec_(sgn*bigrad/2,0) \ + then to tension between B+vec_(sgn*bigrad/2,0) and B \ + then to tension between T and B \ + then to T \ + then to tension between T and C \ + then to tension between C+vec_(sgn*bigrad/2,0) and C \ + then to C+vec_(sgn*bigrad/2,0) \ + then to D-vec_(sgn*bigrad/2,0) \ + then to tension between D-vec_(sgn*bigrad/2,0) and D \ + then to tension between S and D \ + then to S } + } + E: (0,0) +] with .E at 0.5 between M4brS and M4brE') +divert(0)dnl + +#nl raw data ranges + rxmin=1.76665, rxmax=5.87332, rymin=1.49164, rymax=4.00836 + +#nl horiz range + yearmin = 1850 + yearmax = 2040 +#nl data ranges + tonsmin = 0 + tonsmax = 2.0 + popmin = 0 + popmax = 10 +#nl page graph size + minx = 0 + maxx = 4.5 + maxx = 4.566 + miny = 0 + maxy = 3.5 + +define dtop {(minx + ($1-yearmin)/(yearmax-yearmin)*(maxx-minx), \ + miny + ($2-tonsmin)/(tonsmax-tonsmin)*(maxy-miny))} +define ptop {(minx + ($1-yearmin)/(yearmax-yearmin)*(maxx-minx), \ + miny + ($2-popmin)/(popmax-popmin)*(maxy-miny))} + +define(`rtod',`yearmin + (`$1'-rxmin)/(rxmax-rxmin)*(2010-yearmin), \ + tonsmin + (`$2'-rymin)/(rymax-rymin)*1.8') + +[ +nD = 0 +define data { nD+=1 + yr[nD]=$1; pop[nD]=$2/1e9; wood[nD]=$3; other[nD]=$4; hydro[nD]=$5 + coal[nD]=$6; oil[nD]=$7; gas[nD]=$8; nuclear[nD]=$9 } + +data(1850,1241000000,0.238506368,0.238506368,0.238506368,0.274220157,0.274220157,0.276138711,0.276138711) +data(1851,1247847137,0.238701076,0.238701076,0.238701076,0.2788137,0.2788137,0.280785327,0.280785327) +data(1852,1254732053,0.238886465,0.238886465,0.238886465,0.287918165,0.287918165,0.289942225,0.289942225) +data(1853,1261654955,0.239062633,0.239062633,0.239062633,0.290097546,0.290097546,0.292173405,0.292173405) +data(1854,1268616055,0.239229675,0.239229675,0.239229675,0.289984551,0.289984551,0.292111579,0.292111579) +data(1855,1275615561,0.239387687,0.239387687,0.239387687,0.289864062,0.289864062,0.292041635,0.292041635) +data(1856,1282653687,0.239651345,0.239651345,0.239651345,0.301026039,0.301026039,0.303253538,0.303253538) +data(1857,1289730646,0.239904902,0.239904902,0.239904902,0.298720029,0.298720029,0.300996841,0.300996841) +data(1858,1296846651,0.24014846,0.24014846,0.24014846,0.303062054,0.303062054,0.30538757,0.30538757) +data(1859,1304001918,0.240382123,0.240382123,0.240382123,0.309545901,0.309914765,0.312288384,0.312288384) +data(1860,1311196664,0.24060599,0.24060599,0.24060599,0.309390256,0.310123937,0.312545059,0.312545059) +data(1861,1318431107,0.240590657,0.240590657,0.240590657,0.319869525,0.320964008,0.323432041,0.323432041) +data(1862,1325705465,0.240568247,0.240568247,0.240568247,0.308599723,0.310051026,0.312565381,0.312565381) +data(1863,1333019958,0.24053884,0.24053884,0.24053884,0.318950063,0.320754238,0.323314334,0.323314334) +data(1864,1340374810,0.240502511,0.240502511,0.240502511,0.327038715,0.329191844,0.331797103,0.331797103) +data(1865,1347770241,0.240459339,0.240459339,0.240459339,0.328647778,0.331145979,0.333795828,0.333795828) +data(1866,1347770241,0.242191279,0.242191279,0.242191279,0.330379718,0.333234804,0.335943539,0.335943539) +data(1867,1362683739,0.241253672,0.241253672,0.241253672,0.336892133,0.340068952,0.342806283,0.342806283) +data(1868,1370202258,0.24163346,0.24163346,0.24163346,0.336747138,0.340257568,0.3430378,0.3430378) +data(1869,1377762260,0.242001817,0.242001817,0.242001817,0.33659359,0.340433875,0.343256455,0.343256455) +data(1870,1385363974,0.242358855,0.242358855,0.242358855,0.348847699,0.353014113,0.355878493,0.355878493) +data(1871,1393007630,0.24215233,0.24215233,0.24215233,0.358346838,0.362835686,0.365741322,0.365741322) +data(1872,1400693459,0.241940775,0.241940775,0.241940775,0.365684522,0.37049214,0.373438493,0.373438493) +data(1873,1408421694,0.24172425,0.24172425,0.24172425,0.360718048,0.365840803,0.368827338,0.368827338) +data(1874,1416192570,0.241502816,0.241502816,0.241502816,0.363892286,0.369326575,0.372352763,0.372352763) +data(1875,1424006320,0.241276535,0.241276535,0.241276535,0.362994434,0.368736684,0.371802,0.371802) +data(1876,1431863183,0.240604702,0.240604702,0.240604702,0.369663316,0.375709983,0.378813907,0.378813907) +data(1877,1439763395,0.239932976,0.239932976,0.239932976,0.368283426,0.374630997,0.377773011,0.377773011) +data(1878,1447707196,0.239261379,0.239261379,0.239261379,0.366907548,0.373552539,0.376732133,0.376732133) +data(1879,1455694826,0.238589927,0.238589927,0.238589927,0.373413172,0.380352127,0.383568794,0.383568794) +data(1880,1463726528,0.23791864,0.23791864,0.23791864,0.383753486,0.390982979,0.394236217,0.394236217) +data(1881,1471802544,0.237570608,0.237570608,0.237570608,0.392344331,0.399860965,0.403150275,0.403150275) +data(1882,1479923119,0.237219231,0.237219231,0.237227977,0.396963826,0.404764232,0.40808912,0.40808912) +data(1883,1488088499,0.236864558,0.236864558,0.236881953,0.403447314,0.411528151,0.414888128,0.414888128) +data(1884,1496298931,0.236506634,0.236506634,0.236532584,0.406015836,0.414373792,0.417768372,0.417768372) +data(1885,1504554663,0.236145507,0.236145507,0.236179917,0.404733187,0.413364978,0.416793681,0.416793681) +data(1886,1512855946,0.235261191,0.235261191,0.235303968,0.40293236,0.411834727,0.415297076,0.415297076) +data(1887,1521203030,0.23437947,0.23437947,0.23443052,0.406792802,0.415962519,0.419458041,0.419458041) +data(1888,1529596169,0.233500342,0.233500342,0.233559574,0.423718314,0.433152176,0.436680404,0.436680404) +data(1889,1538035617,0.232623805,0.232623805,0.232691127,0.425534315,0.435229149,0.438789617,0.438789617) +data(1890,1546521628,0.231749857,0.231749857,0.231825179,0.431025052,0.44097771,0.444569959,0.444569959) +data(1891,1555054461,0.23057828,0.23057828,0.230661512,0.436142504,0.446349864,0.449973439,0.449973439) +data(1892,1563634373,0.229412583,0.229412583,0.229503635,0.439357394,0.449816361,0.453470809,0.453470809) +data(1893,1572261624,0.228252736,0.228252736,0.228351521,0.431583686,0.442291192,0.445976065,0.445976065) +data(1894,1580936476,0.22709871,0.22709871,0.22720514,0.436575574,0.447528576,0.45124343,0.45124343) +data(1895,1589659190,0.225950477,0.225950477,0.226064464,0.441499685,0.452695166,0.456439562,0.456439562) +data(1896,1598430032,0.225392144,0.225392144,0.225513603,0.450527775,0.461962746,0.465736247,0.465736247) +data(1897,1607249265,0.224833135,0.224833135,0.224961981,0.457659825,0.469331318,0.473133492,0.473133492) +data(1898,1616117159,0.224273475,0.224273475,0.224409622,0.473569462,0.48547454,0.489304958,0.489304958) +data(1899,1625033980,0.223713188,0.223713188,0.223856553,0.494583176,0.506718923,0.510577162,0.510577162) +data(1900,1634000000,0.223152296,0.223152296,0.223302795,0.504825195,0.51718872,0.521074359,0.521074359) +data(1901,1648219401,0.221510378,0.221510378,0.221677629,0.505816316,0.519528083,0.5237969,0.5237969) +data(1902,1662562543,0.219880182,0.219880182,0.220068436,0.508573752,0.523333498,0.527978592,0.527978592) +data(1903,1677030501,0.218261627,0.218261627,0.218478353,0.530583699,0.546223844,0.551238406,0.551238406) +data(1904,1691624363,0.216654634,0.216654634,0.216900192,0.527887731,0.545298807,0.550676116,0.550676116) +data(1905,1706345223,0.215059124,0.215059124,0.215337131,0.547716584,0.564693219,0.570426643,0.570426643) +data(1906,1721194188,0.214836225,0.214836225,0.215148552,0.563118074,0.579880854,0.585963848,0.585963848) +data(1907,1736172371,0.214601167,0.214601167,0.214954035,0.596547339,0.617095414,0.62352152,0.62352152) +data(1908,1751280897,0.214354174,0.214354174,0.214752998,0.574277169,0.596299335,0.60306218,0.60306218) +data(1909,1766520901,0.214095471,0.214095471,0.214542936,0.586977877,0.609919015,0.61701231,0.61701231) +data(1910,1781893526,0.213825278,0.213825278,0.214318488,0.603352348,0.628089516,0.635693908,0.635693908) +data(1911,1797399927,0.212500054,0.212500054,0.213041248,0.605588411,0.631564823,0.639504319,0.639504319) +data(1912,1813041268,0.211181781,0.211181781,0.211751647,0.620130467,0.646297549,0.654565803,0.654565803) +data(1913,1828818723,0.209870438,0.209870438,0.210513435,0.644310839,0.672912362,0.681503109,0.681503109) +data(1914,1844733476,0.208566004,0.208566004,0.209324315,0.595307622,0.624513467,0.633420528,0.633420528) +data(1915,1860786724,0.207268457,0.207268457,0.208098411,0.584702733,0.615780985,0.624998263,0.624998263) +data(1916,1876979669,0.204485426,0.204485975,0.205402589,0.605882504,0.638934007,0.648455487,0.648455487) +data(1917,1893313529,0.201734987,0.201735896,0.202715085,0.616179081,0.652399178,0.662218924,0.662218924) +data(1918,1909789530,0.199016787,0.199017732,0.200115349,0.602687652,0.638337653,0.648449811,0.648449811) +data(1919,1926408908,0.196330472,0.196331097,0.196945715,0.535439366,0.575689906,0.586088699,0.586088699) +data(1920,1943172912,0.193675695,0.193676005,0.195243412,0.579848388,0.630973534,0.641653264,0.641653264) +data(1921,1960082799,0.192957547,0.192958381,0.194440762,0.512833825,0.567705487,0.578660532,0.578660532) +data(1922,1977139839,0.192237376,0.192238246,0.193895625,0.527050727,0.587771773,0.599365431,0.599365431) +data(1923,1994345313,0.19151527,0.191516348,0.193525554,0.578230714,0.649426509,0.662893064,0.662893064) +data(1924,2011700513,0.190791315,0.190792469,0.192986897,0.564368556,0.634750802,0.650057077,0.650057077) +data(1925,2029206742,0.190065598,0.190066911,0.192579912,0.561692328,0.634850472,0.651963721,0.651963721) +data(1926,2046865313,0.189342426,0.18934419,0.192313939,0.556598403,0.631036129,0.649924035,0.649924035) +data(1927,2064677552,0.188617585,0.188619709,0.191901916,0.581066305,0.66532014,0.685950808,0.685950808) +data(1928,2082644798,0.187891159,0.187893595,0.191560967,0.570524051,0.658240401,0.680582356,0.680582356) +data(1929,2082644798,0.188791962,0.188794439,0.19317309,0.596191895,0.694524554,0.718247863,0.718247863) +data(1930,2119049713,0.186433874,0.186436187,0.190385499,0.552331717,0.644491424,0.668934944,0.668934944) +data(1931,2137490116,0.185921585,0.185923717,0.190113868,0.506565457,0.594964462,0.620348577,0.620348577) +data(1932,2156090991,0.185404259,0.185406253,0.189724679,0.468661357,0.552304395,0.578611056,0.578611056) +data(1933,2174853735,0.184882022,0.184885026,0.189466471,0.478973885,0.569521584,0.596732983,0.596732983) +data(1934,2193779755,0.184354996,0.184357857,0.189137885,0.50231919,0.597048389,0.625146959,0.625146959) +data(1935,2212870475,0.183823303,0.183826489,0.189391253,0.513244919,0.615346693,0.6443151,0.6443151) +data(1936,2232127325,0.183422624,0.183426207,0.189292235,0.541976812,0.652213355,0.6820345,0.6820345) +data(1937,2251551752,0.183015177,0.183016132,0.189691455,0.557024422,0.681411525,0.713128315,0.713128315) +data(1938,2271145215,0.182601109,0.182608794,0.189219601,0.528985648,0.649365004,0.682755166,0.682755166) +data(1939,2290909184,0.182180563,0.182198879,0.189050477,0.544855454,0.669193862,0.704673928,0.704673928) +data(1940,2310845143,0.181753683,0.181773628,0.188817984,0.577859192,0.705095325,0.742626751,0.742626751) +data(1941,2330954589,0.180256141,0.180280081,0.187681608,0.587475315,0.717410922,0.756955672,0.756955672) +data(1942,2351239032,0.17877091,0.178803567,0.18636161,0.589499673,0.710751063,0.752271606,0.752271606) +data(1943,2371699993,0.17729789,0.177330845,0.185849103,0.596589637,0.725948747,0.769408049,0.769408049) +data(1944,2392339011,0.17583698,0.175847008,0.183932936,0.574921594,0.722215099,0.767576618,0.767576618) +data(1945,2413157633,0.174388081,0.174391359,0.182283924,0.493293215,0.63914527,0.68637295,0.68637295) +data(1946,2434157423,0.173522919,0.173531361,0.182267965,0.514250229,0.668057865,0.717384008,0.717384008) +data(1947,2455339957,0.172659705,0.172683238,0.181755468,0.551547112,0.719518964,0.773619655,0.773619655) +data(1948,2476706827,0.17179847,0.171828917,0.181742644,0.560535238,0.749010917,0.809647204,0.809647204) +data(1949,2498259635,0.170939245,0.17097559,0.181133719,0.538171636,0.723949765,0.788183962,0.788183962) +data(1950,2557628654,0.167579756,0.167622721,0.178408185,0.559396293,0.762977841,0.834822272,0.834822272) +data(1951,2594938936,0.167032664,0.167085184,0.179115513,0.574723533,0.802272625,0.886283415,0.886283415) +data(1952,2636770386,0.166215588,0.166275557,0.178905263,0.565999791,0.801386992,0.890443027,0.890443027) +data(1953,2682050452,0.165211328,0.165271599,0.178153454,0.56040182,0.805094458,0.897685967,0.897685967) +data(1954,2730224110,0.164066346,0.164125585,0.177552809,0.548214509,0.799870041,0.895277726,0.895277726) +data(1955,2782093851,0.162744571,0.162802026,0.177062242,0.572289721,0.849071541,0.950920777,0.950920777) +data(1956,2835293441,0.161343608,0.161397559,0.176802814,0.586639897,0.882197665,0.990604979,0.990610309) +data(1957,2891342302,0.159836585,0.159890471,0.176313385,0.589494533,0.894932945,1.010584994,1.010622753) +data(1958,2948128605,0.158347259,0.158403549,0.176092897,0.594122165,0.901178987,1.023306716,1.023348608) +data(1959,3000706677,0.157134282,0.157194027,0.175092878,0.60075882,0.926301469,1.060278841,1.060403012) +data(1960,3042990271,0.156490706,0.156555865,0.175795691,0.61309257,0.958977014,1.102738263,1.102971765) +data(1961,3084007286,0.155724141,0.155801371,0.175847845,0.582341401,0.945610971,1.097964839,1.098333034) +data(1962,3140187350,0.154229357,0.154309778,0.175037739,0.583886676,0.970894477,1.134494733,1.135032498) +data(1963,3209978774,0.152139251,0.152229147,0.173552486,0.585699084,0.991892736,1.166953505,1.167858812) +data(1964,3281412257,0.150062967,0.150160837,0.171811855,0.592867755,1.021995792,1.209049525,1.210281169) +data(1965,3350699989,0.14816998,0.148271574,0.171655685,0.592192206,1.043069039,1.239349435,1.241269627) +data(1966,3421015609,0.147131043,0.14723349,0.171776593,0.589397107,1.068586677,1.275452622,1.27813231) +data(1967,3490735455,0.146158896,0.14626543,0.170803075,0.56557596,1.069927556,1.288070014,1.291237119) +data(1968,3562786611,0.145129793,0.1452355,0.170411047,0.568040201,1.107666962,1.34146315,1.345320724) +data(1969,3637707956,0.14402776,0.144141478,0.170254838,0.567570209,1.136409991,1.38786865,1.392325229) +data(1970,3713327898,0.142943308,0.143053274,0.169862261,0.574604634,1.187424472,1.460093809,1.4656198) +data(1971,3790980082,0.141867123,0.1419725,0.169518561,0.562377273,1.199174341,1.484731543,1.492185663) +data(1972,3867242256,0.14088476,0.141006603,0.169241956,0.55299154,1.211873977,1.508449967,1.518429829) +data(1973,3942790520,0.139965732,0.140098019,0.168229646,0.551337808,1.256519325,1.5637256,1.576827076) +data(1974,4017323955,0.139116394,0.139264313,0.169566501,0.548855283,1.243354913,1.55159078,1.568155026) +data(1975,4088810897,0.138401041,0.13856795,0.16866321,0.563492361,1.21131787,1.515162671,1.537578295) +data(1976,4158888836,0.137644673,0.137823056,0.167542119,0.566773642,1.257660106,1.569161684,1.594857237) +data(1977,4229748034,0.136888084,0.137068744,0.166990254,0.571441309,1.275256046,1.610533422,1.641644931) +data(1978,4300631215,0.136155668,0.136323913,0.168223987,0.572181835,1.27205561,1.591706702,1.627562741) +data(1979,4374349678,0.135359212,0.13557451,0.168367796,0.588798681,1.303224877,1.642092677,1.678738222) +data(1980,4445423675,0.13466922,0.135694224,0.169018612,0.535103352,1.264795628,1.575204786,1.612060086) +data(1981,4526817917,0.134213008,0.135336361,0.168515198,0.530410164,1.209074468,1.518426926,1.559512282) +data(1982,4607193353,0.133802494,0.135342954,0.168753641,0.536996737,1.176267133,1.47980709,1.52463367) +data(1983,4688582743,0.133377208,0.135246041,0.169576319,0.532088682,1.158420925,1.46002144,1.510279864) +data(1984,4767669177,0.133030663,0.135364454,0.170242063,0.54694641,1.180279911,1.506703536,1.566412047) +data(1985,4849860549,0.132610473,0.135051242,0.169658748,0.552747513,1.171095757,1.504285752,1.573424331) +data(1986,4934211409,0.131291387,0.133685377,0.168393392,0.554194404,1.186400652,1.520044231,1.593296333) +data(1987,5021085089,0.129951317,0.132539382,0.166722644,0.554231496,1.181208808,1.524791298,1.603295671) +data(1988,5108736553,0.128637242,0.13125772,0.166140318,0.556210491,1.195203161,1.549641815,1.633219996) +data(1989,5195979089,0.127377522,0.13079373,0.164881748,0.553926742,1.193159265,1.553390392,1.638232703) +data(1990,5284252039,0.126134805,0.129737215,0.164632138,0.553384674,1.190735096,1.553386431,1.640350219) +data(1991,5367488662,0.125428663,0.12928236,0.164254982,0.528423389,1.154980396,1.516498613,1.613399159) +data(1992,5452187873,0.124710625,0.128643771,0.163153115,0.518552304,1.13735672,1.494240768,1.590566106) +data(1993,5534418049,0.12406988,0.128046593,0.163990775,0.50470235,1.119339298,1.477198192,1.575200738) +data(1994,5614530098,0.123494469,0.127690239,0.163473418,0.506216459,1.12531413,1.481458633,1.580083078) +data(1995,5695823105,0.122909758,0.127213893,0.164248122,0.510641048,1.135855904,1.49167459,1.592774524) +data(1996,5776327747,0.12216812,0.12649691,0.163557636,0.510522671,1.141850345,1.503121808,1.606488473) +data(1997,5854841500,0.121488167,0.12619452,0.163583023,0.524945344,1.167177534,1.523679854,1.624760285) +data(1998,5932024858,0.120853308,0.125593429,0.162567495,0.521014085,1.167330383,1.52595967,1.627688406) +data(1999,6008646651,0.120245994,0.125081498,0.162173341,0.512693203,1.14325022,1.505666716,1.609442579) +data(2000,6084703879,0.119665076,0.124729832,0.16178992,0.513011266,1.158715327,1.529969497,1.634878653) +data(2001,6160890093,0.119894056,0.125258541,0.161095098,0.524198822,1.1611659,1.535602425,1.642047723) +data(2002,6237154134,0.118903979,0.124921559,0.160784753,0.529942594,1.153921617,1.530689162,1.637033401) +data(2003,6313942570,0.117913902,0.124642773,0.160192176,0.546832827,1.182503339,1.566938847,1.670839416) +data(2004,6390636309,0.116923825,0.12432827,0.161759107,0.565673251,1.221114221,1.610936278,1.717713694) +data(2005,6467431499,0.115933748,0.124259776,0.162887647,0.604148825,1.263290753,1.659620623,1.765386482) +data(2006,6545218993,0.114943672,0.124695239,0.164252513,0.623509498,1.274460793,1.680457898,1.786351327) +data(2007,6623523655,0.113953595,0.125629532,0.165251003,0.637952129,1.279256584,1.68820381,1.790810594) +data(2008,6702159402,0.112963518,0.127142703,0.167940953,0.64989848,1.292105043,1.710278853,1.811269586) +data(2009,6780833881,0.111973441,0.127858368,0.168866486,0.654393109,1.282816573,1.686869485,1.785251313) +data(2010,6858584755,0.110983364,0.12921584,0.172117414,0.680609275,1.328410794,1.756431211,1.856334479) +data(2011,6935999491,0.109993287,0.130385385,0.173636892,0.704216284,1.348176864,1.785673581,1.880255695) +data(2012,7013871313,0.10900321,0.130975574,0.175672274,0.688388925,1.341250864,1.785302272,1.872409847) +data(2013,7092128094,0.108013133,0.132480909,0.177353971,0.688378378,1.336238537,1.781754888,1.868322734) +data(2014,7169968185,0.107023056,0.133567224,0.177755023,0.681107631,1.336758872,1.78693987,1.874787234) +data(2015,7247892788,0,0,0,0,0,0,0) +data(2016,7325996709,0,0,0,0,0,0,0) +data(2017,7405107650,0,0,0,0,0,0,0) +nD0=nD-3 + +define yrdata { nyd +=1; yrd[nyd]=$1; ypop[nyd]=$2/1e9 } + +nyd = 0 +yrdata(1850,1169923623) +yrdata(1851,1177298999) +yrdata(1852,1184724181) +yrdata(1853,1192199527) +yrdata(1854,1199725401) +yrdata(1855,1207302168) +yrdata(1856,1214930197) +yrdata(1857,1222609858) +yrdata(1858,1230341525) +yrdata(1859,1238125576) +yrdata(1860,1245962390) +yrdata(1861,1253852349) +yrdata(1862,1261795840) +yrdata(1863,1269793250) +yrdata(1864,1277844972) +yrdata(1865,1285951399) +yrdata(1866,1294112930) +yrdata(1867,1302329966) +yrdata(1868,1310602910) +yrdata(1869,1318932168) +yrdata(1870,1327318152) +yrdata(1871,1335761275) +yrdata(1872,1344261952) +yrdata(1873,1352820603) +yrdata(1874,1361437653) +yrdata(1875,1370113525) +yrdata(1876,1379548537) +yrdata(1877,1389051752) +yrdata(1878,1398623687) +yrdata(1879,1408264863) +yrdata(1880,1417975804) +yrdata(1881,1427757042) +yrdata(1882,1437609109) +yrdata(1883,1447532543) +yrdata(1884,1457527886) +yrdata(1885,1467595685) +yrdata(1886,1477736490) +yrdata(1887,1487950857) +yrdata(1888,1498239345) +yrdata(1889,1508602518) +yrdata(1890,1519040944) +yrdata(1891,1529555197) +yrdata(1892,1540145854) +yrdata(1893,1550813497) +yrdata(1894,1561558712) +yrdata(1895,1572382092) +yrdata(1896,1583284233) +yrdata(1897,1594265734) +yrdata(1898,1605327202) +yrdata(1899,1616469247) +yrdata(1900,1630171098) +yrdata(1901,1644554295) +yrdata(1902,1659067684) +yrdata(1903,1673712471) +yrdata(1904,1688489874) +yrdata(1905,1703401122) +yrdata(1906,1718447458) +yrdata(1907,1733630134) +yrdata(1908,1748950415) +yrdata(1909,1764409579) +yrdata(1910,1780008913) +yrdata(1911,1795749721) +yrdata(1912,1811633314) +yrdata(1913,1827661021) +yrdata(1914,1843834178) +yrdata(1915,1860154139) +yrdata(1916,1876622267) +yrdata(1917,1893239939) +yrdata(1918,1910008546) +yrdata(1919,1926929491) +yrdata(1920,1944419089) +yrdata(1921,1962566145) +yrdata(1922,1980884876) +yrdata(1923,1999376931) +yrdata(1924,2018043972) +yrdata(1925,2023803913) +yrdata(1926,2043462180) +yrdata(1927,2063406322) +yrdata(1928,2082689730) +yrdata(1929,2103850414) +yrdata(1930,2124167500) +yrdata(1931,2143802732) +yrdata(1932,2164157870) +yrdata(1933,2184604692) +yrdata(1934,2205534997) +yrdata(1935,2226530597) +yrdata(1936,2247993326) +yrdata(1937,2268545035) +yrdata(1938,2290267593) +yrdata(1939,2312702889) +yrdata(1940,2350947590) +yrdata(1941,2373554827) +yrdata(1942,2396382640) +yrdata(1943,2419433211) +yrdata(1944,2442708748) +yrdata(1945,2466211477) +yrdata(1946,2489943650) +yrdata(1947,2513907539) +yrdata(1948,2538105439) +yrdata(1949,2562539670) +yrdata(1950,2579434878) +yrdata(1951,2653954580) +yrdata(1952,2692712961) +yrdata(1953,2732388944) +yrdata(1954,2772909569) +yrdata(1955,2814390135) +yrdata(1956,2856675848) +yrdata(1957,2899864004) +yrdata(1958,2943689748) +yrdata(1959,2987555529) +yrdata(1960,3030709021) +yrdata(1961,3090453463) +yrdata(1962,3137151355) +yrdata(1963,3211786601) +yrdata(1964,3270671214) +yrdata(1965,3330055803) +yrdata(1966,3401169329) +yrdata(1967,3463250974) +yrdata(1968,3526647458) +yrdata(1969,3591511933) +yrdata(1970,3657420066) +yrdata(1971,3724116214) +yrdata(1972,3791497136) +yrdata(1973,3859732004) +yrdata(1974,3928723212) +yrdata(1975,3998320921) +yrdata(1976,4080634693) +yrdata(1977,4156349026) +yrdata(1978,4233151108) +yrdata(1979,4311785729) +yrdata(1980,4391777096) +yrdata(1981,4472736872) +yrdata(1982,4555816222) +yrdata(1983,4640588050) +yrdata(1984,4726272158) +yrdata(1985,4813567478) +yrdata(1986,4902566593) +yrdata(1987,4985904892) +yrdata(1988,5070443631) +yrdata(1989,5156030340) +yrdata(1990,5219191372) +yrdata(1991,5304659362) +yrdata(1992,5390911229) +yrdata(1993,5477320137) +yrdata(1994,5564356643) +yrdata(1995,5652711036) +yrdata(1996,5738516173) +yrdata(1997,5824945702) +yrdata(1998,5912061676) +yrdata(1999,5999735497) +yrdata(2000,6088144560) +yrdata(2001,6173932167) +yrdata(2002,6250016823) +yrdata(2003,6326520742) +yrdata(2004,6403805522) +yrdata(2005,6481944062) +yrdata(2006,6525559210) +yrdata(2007,6602274812) +yrdata(2008,6789771253) +yrdata(2009,6873741054) +yrdata(2010,6958169159) +yrdata(2011,7043008586) +yrdata(2012,7128176935) +yrdata(2013,7213426452) +yrdata(2014,7298453033) +yrdata(2015,7383008820) +yrdata(2016,7466964280) +yrdata(2017,7550262101) + +Left: line from dtop(yearmin,tonsmin) to dtop(yearmin,tonsmax) + htic = 8pt__ +# htic = maxy + vtic = 13pt__/2 +# vtic = maxy + "0" wid 5bp__ at dtop(yearmin,tonsmin) rjust above + for y=0.2 to 2 by 0.2 do { + move to dtop(yearmin,y) + if y<2 then {{ line right htic }} + sprintf("%g",y) wid 5bp__ rjust } + svg_rot(90,"Tonnes of oil equivalent per capita" at Left-(0.3,0)) + +Right: line from dtop(yearmax,tonsmin) to dtop(yearmax,tonsmax) + for p=0 to popmax do { + move to ptop(yearmax,p) + if p>0 && p<popmax then {{ line left htic }} + sprintf("%g",p) wid 5 bp__ ljust } + [svg_rot(90,"World population (billions)")] wid 10bp__ ht 114bp__ \ + with .w at Right+(0.25,0) + +Bot: line from Left.start to Right.start + for t=yearmin+10 to yearmax-10 by 10 do { + line up vtic from dtop(t,tonsmin) } + for t=yearmin to yearmax by 50 do { + sprintf("%g",t) wid 5bp__ at dtop(t,tonsmin) below } + "Year" wid 20bp__ at Bot+(0,-0.15) below + +Top: line from Left.end to Right.end + +# Population to 2017 +linethick_(2.5) + +NPopulation: \ + spline ctension_ dotted 1.5pt__ from ptop(yrd[1],ypop[1]) \ + to ptop(yrd[2],ypop[2]) + for y=3 to nyd by 10 do { continue to ptop(yrd[y],ypop[y]) } + for yy=y-10+1 to nyd do { continue to ptop(yrd[yy],ypop[yy]) } + +thicklines_ +# Wood + spline ctension_ from dtop(yr[1],wood[1]) to dtop(yr[2],wood[2]) + for y=3 to nD0 do { continue to dtop(yr[y],wood[y]) } + +# Other + spline ctension_ from dtop(yr[1],other[1]) to dtop(yr[2],other[2]) + for y=3 to nD0 do { continue to dtop(yr[y],other[y]) } + +# Hydro + spline ctension_ from dtop(yr[1],hydro[1]) to dtop(yr[2],hydro[2]) + for y=3 to nD0 do { continue to dtop(yr[y],hydro[y]) } + +# Coal + spline ctension_ from dtop(yr[1],coal[1]) to dtop(yr[2],coal[2]) + for y=3 to nD0 do { continue to dtop(yr[y],coal[y]) } + +# Oil + spline ctension_ from dtop(yr[1],oil[1]) to dtop(yr[2],oil[2]) + for y=3 to nD0 do { continue to dtop(yr[y],oil[y]) } + +# Gas + spline ctension_ from dtop(yr[1],gas[1]) to dtop(yr[2],gas[2]) + for y=3 to nD0 do { continue to dtop(yr[y],gas[y]) } + +# Total +linethick_(2.5) +Total: \ + spline ctension_ from dtop(yr[1],nuclear[1]) to dtop(yr[2],nuclear[2]) + for y=3 to nD0 do { continue to dtop(yr[y],nuclear[y]) } + +thicklines_ + +#f_box(invis fill_(1) with .s at dtop(2000,0)+(0,2pt__),Wood) +Cl: "Coal" wid 20bp__ at dtop(2000,0.36+3pt__) + "Oil" wid 15bp__ at dtop(2000,0.9) + "Gas" wid 20bp__ at dtop(2000,1.41) + "Wood" wid 20bp__ at dtop(1889,0.15) + svg_rot(50,"Population" at dtop(1975,0.9)) + +brpos = 2017 + Q: brace(down_ 2.96 with .c at dtop(brpos,1.03)) + svg_rot(90,"90 %" at Q.c+(15bp__,2bp__)) + svg_rot(90,"nonrenewable" at Q.c+(26bp__,2bp__)) + + R: brace(down_ 0.28 with .c at dtop(brpos,.09)) + [svg_rot(90,"10 %")] ht 15bp__ wid 10bp__ at R.c+(15bp__,4bp__) + svg_rot(90,"renewable" at R.c+(26bp__,17bp__)) + + linethick_(0.6) + arrow <- from dtop(1998,1.55) left 0.15 up 0.2 + "Nuclear" wid 70bp__ above + + arrow <- from dtop(1960,1.09) left 0.5 + "Total energy consumption" wid 200bp__ rjust + + spline ctension_ <- \ + from dtop(2014,1.89) left 0.5 up 0.2 then left 0.5 down 0.2 + "680 % of 1850 energy consumption" wid 300bp__ rjust + +H: "Hydro" wid 30bp__ with .w at (Cl.w.x,Cl.c.y-17pt__) +R: dtop(yr[nD0]-2,0.16) + spline from H.e+(2pt__,0) to (R.x+0.11,H.y) then to (R.x+0.11,R.y) \ + then to R -> + + spline <- from dtop(yr[nD0]-1,0.12) left 0.2 up 0.1 then left 0.55 up 0.05 + "Other renewables" wid 100bp__ with .b at Here+(-0.4,2pt__) + +Q: NPopulation.end + (-1.25,-0.1) + spline ctension_ <- \ + from NPopulation.end+(-3pt__,0) left 0.3 down 0.1 then left 0.45 then to Q + sprintf("%g %% of 1850 population",round_(ypop[nyd]/ypop[1]*10)*10) \ + wid 100bp__ rjust +] command "</g>" # end font +#.PE + ] with .sw at last [].se+(-40bp__,0) # Cons +#showbox_ + .PE diff --git a/graphics/circuit_macros/examples/svg/Makefile b/graphics/circuit_macros/examples/svg/Makefile index 1826a94d7a..0b01e8bc61 100644 --- a/graphics/circuit_macros/examples/svg/Makefile +++ b/graphics/circuit_macros/examples/svg/Makefile @@ -54,9 +54,9 @@ CCTSVG = \ BipSVG.svg BtreeSVG.svg ByteSVG.svg ButtonsSVG.svg \ CanLogicSVG.svg CapacitorsSVG.svg ChipsSVG.svg ConnSVG.svg ConnectorsSVG.svg \ ContactSVG.svg ContactsSVG.svg \ - CountingSVG.svg CrowSVG.svg CsourceSVG.svg \ + CrowSVG.svg CsourceSVG.svg \ DecoderSVG.svg DemultiplexerSVG.svg DiniSVG.svg DiodesSVG.svg DriveSVG.svg \ - EEPSVG.svg EmarrowsSVG.svg \ + EEPSVG.svg EmarrowsSVG.svg EscherSVG.svg \ FlowSVG.svg FontsSVG.svg FusesSVG.svg \ GeometrySVG.svg GrayCodeSVG.svg GroundsSVG.svg \ HeadersSVG.svg HeathkitSVG.svg \ @@ -114,6 +114,13 @@ tstSVG.html: tstSVG.htmx $(TEST).svg xst: Incleps.png # necessary because of rotated text: +LoglogSVG.svg test.svg: + m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic + $(DPIC) -v $*.pic > $*.svg + m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic + $(DPIC) -v $*.pic > $*.svg + grep '<\!-- width' $*.svg | sed -e 's%<\!-- *%%' -e 's% *-->%%' > $*.siz + ConnectorsSVG.svg cscSVG.svg test.svg: m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic $(DPIC) -v $*.pic > $*.svg diff --git a/graphics/circuit_macros/examples/svg/SLD.m4 b/graphics/circuit_macros/examples/svg/SLD.m4 deleted file mode 100644 index 96f04f7235..0000000000 --- a/graphics/circuit_macros/examples/svg/SLD.m4 +++ /dev/null @@ -1,389 +0,0 @@ -divert(-1) - -# This section defines *DRAFT* SLD elements with or without attached -# circuit breakers. Many other elements applicable to SLD drawings are -# already in libcct.m4. The contributions and suggestions of Benjamin -# Vilmann are acknowledged with thanks. - -# Notes for 1-terminal SLD elements: -# Argument 1 is normally the linespec of the stem to set the element direction -# and length. See also: PtoL defined in libgen.m4. -# For a 0-length stem (which has undefined direction): -# arg1 can also be U, D, L, R (for up, down, left, right), -# or a number to set the direction in degrees, optionally followed by -# `at position' to set the position (Here by default). -# Zero-length stem examples: sl_box(U), sl_box(45 at Here+(1,0)) -# Argument 2 contains semicolon (;)-separated key-value attributes -# of the element head as applicable: e.g., name=Carol; text="Stop"; lgth=expr -# If argument 3 is blank then no breaker is drawn. A non-blank argument 3 -# is C for a default closed breaker in the stem, O for an open breaker, -# or key-value pairs to specify breaker details. -# The element body (head) can be named with name=. It is overlaid with -# or contained in a [] block. - -# Notes for 2-terminal SLD elements: -# These obey the normal Circuit_macro two-terminal conventions. -# They can be labelled using rlabel() or llabel() as well as directly. -# Argument 2 contains key-value pairs to customize the element body, -# e.g., name=Name; text="text"; wdth=expr; ... -# Nonblank arguments 3 and 4 put a breaker in the input and output respectively. - -# Notes for attached breakers: -# Nonblank arguments 3 and 4 of the two-terminal elements and argument 3 of -# the 1-terminal elements specify a breaker in the input, output, and stem -# respectivlely. An O creates a default-size open breaker, and C a closed -# breaker, otherwise the argument contains key-value pairs to specify the -# details of the box; e.g., box=dotted 2bp__ shaded "green" - -# Notes for composite elements within a [ ] block: -# The SLD current transformer macro sl_ct is composite. -# Internal labels L (for inductor) and terminals Ts, Tc, and Te are defined. - -define(`sldlib_') -ifdef(`libcct_',,`include(libcct.m4)divert(-1)') - -# Default size parameters. These can be redefined in a diagram. - -define(`brksiz_',`dimen_*3/16') # Default inline box breaker size -define(`drosiz_',`dimen_/4') # Default sl_drawout (chevron) size - -# One-terminal elements ################################################### - - `sl_disk( stem linespec, keys, breaker ) - keys: name=Name; - text="text"; - diam=expr; - circle=circle attributes; eg diam expr' - `default breaker name Bd' -define(`sl_disk', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; circle::N; text::N; diam:dimen_*2/3')dnl - ifelse(`$3',, - `ifelse(m4name,,,m4name:) circle diam m4diam \ - at last line.end + vec_(m4diam/2,0) m4circle m4text - [ box invis wid_ m4diam ht_ m4diam ] at last circle - line from last line.end to last line.start', - `m4br_one(`sl_disk',`$1',`$2',m4brk_(`$3',Bd))') ') - - `sl_box( stem linespec, keys, breaker ) - keys: name=Name; lgth=expr; wdth=expr; - text="text"; - box= box attributes; (e.g. shade "red")' - `default breaker name Bb' -define(`sl_box', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*2/3; lgth:dimen_*2/3; box::N; text::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - { ifelse(m4name,,,m4name:) [S:Here; lbox(m4lgth,m4wdth,m4box)] \ - with .S at last line.start } - ifelse(m4text,,,`{m4text at last []}')', - `m4br_one(`sl_box',`$1',`$2',m4brk_(`$3',Bb))') ') - - `sl_grid( stem linespec, keys, breaker ) - keys: name=Name; lgth=expr; wdth=expr;' - `default breaker name Bgr' -define(`sl_grid', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*4/5; lgth:dimen_*2/3; box::N; text::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - { ifelse(m4name,,,m4name:) [S:Here - { ifelse(m4name,,,m4name:) lbox(m4lgth,m4wdth) } - { line to rvec_(m4lgth/2, m4wdth/2) - line to rvec_(m4lgth/2,-m4wdth/2) - line to rvec_(-m4lgth/2,-m4wdth/2) - line to rvec_(-m4wdth/2, m4wdth/2) } - { line from rvec_(0,m4wdth/2) to rvec_(m4lgth,-m4wdth/2) } - line from rvec_(0,-m4wdth/2) to rvec_(m4lgth,m4wdth/2) - ] with .S at last line.start } ', - `m4br_one(`sl_grid',`$1',`$2',m4brk_(`$3',Bgr))') ') - - `sl_load( stem linespec, keys, breaker ) - keys: name=Name; lgth=expr; wdth=expr; - head= arrowhead attributes;' - `default breaker name Bl' -define(`sl_load', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*0.32; lgth:dimen_*0.45; head::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - { ifelse(m4name,,,m4name:) [S:Here; line to rvec_(0,m4wdth/2) \ - then to rvec_(m4lgth,0) then to rvec_(0,-m4wdth/2) \ - then to Here m4head ] with .S at last line.start } ', - `m4br_one(`sl_load',`$1',`$2',m4brk_(`$3',Bl))') ') - - `sl_meterbox( stem linespec, keys, breaker ) - keys: sl_box attributes' - `default breaker name Bm' -define(`sl_meterbox', - `sl_eleminit_(`$1') - setkeys_(`$2',`name::N; wdth:dimen_*2/3; lgth:dimen_*2/3; box::N; text::N')dnl - ifelse(`$3',, - `line from last line.end to last line.start - {ifelse(m4name,,,m4name:) [S:Here; - { B: rotbox( m4lgth, m4wdth, m4box ) with .W at S } - a = rp_ang*rtod_ - if (abs(a-90) < 45) || (abs(a-180) < 45) || (abs(a+180) < 45) then { - C: rvec_(m4lgth*2/5,0) - line from rvec_(m4lgth*4/5,m4wdth/2) to rvec_(m4lgth*4/5,-m4wdth/2) } \ - else { C: rvec_(m4lgth*3/5,0) - line from rvec_(m4lgth/5,m4wdth/2) to rvec_(m4lgth/5,-m4wdth/2) } - ifelse(m4text,,,`m4text at C') - ] with .S at last line.start}', - `m4br_one(`sl_meterbox',`$1',`$2',m4brk_(`$3',Bm))') ') - - `sl_generator( stem linespec, keys, breaker )' - `default breaker name Bd' -define(`sl_generator',`sl_disk($@) - { ACsymbol(at last circle,,,R) - m4lcd = last circle.diam - [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ') - - `sl_syncmeter( stem linespec, keys, breaker )' - `default breaker name Bd' -define(`sl_syncmeter',`sl_disk($@) - { Syncsymb(at last circle) - m4lcd = last circle.diam - [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ') - - `sl_lamp( stem linespec, keys, breaker )' - `default breaker name Bd' -define(`sl_lamp',`sl_disk($@) - { line from last circle.ne to last circle.sw - line from last circle.nw to last circle.se - m4lcd = last circle.diam - [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ') - -# One-terminal utilities ################################################## - - `Syncsymb(at position, rad) - Symbol for sync meter' -define(`Syncsymb',`[ define(`m4ssrad',`ifelse(`$2',,(dimen_/4),`($2)')')dnl - Origin: Here - {arc <-> ht arrowht/2 wid arrowwid*2/3 \ - from Rect_(m4ssrad,30) to Rect_(m4ssrad,150) with .c at Here} - line from (0,m4ssrad) to (0,-m4ssrad/2) - `$3' ] with .Origin ifelse(`$1',,`at Here',`$1')') - - `m4br_one( `name', stem linespec, body keys, - breaker keys )' - `Draw the breaker in the stem then the element' -define(`m4br_one', - `M4_S: last line.start - setkey_(`$4',lgth,brksiz_)dnl - line from M4_S to last line.end+vec_(-(m4lgth)*5/2,0) - sl_breaker(to rvec_(m4lgth,0),`$4') - $1(to rvec_((m4lgth)*3/2,0),`$3') - move to M4_S ') - - `sl_eleminit_(linespec or (for zero length) - U|D|L|R|number [at location])' -define(`sl_eleminit_', - `ifelse(regexp(`$1',^ *[UDLR0123456789]),-1, - `eleminit_(`$1',dimen_)', - `pushdef(`M4pos',`ifinstr(`$1',` at ',`patsubst(`$1',^.* at *)')')dnl - ifelse(M4pos,,,`move to M4pos;') setdir_(patsubst(`$1',` at.*')) - line invis from Here to Here popdef(`M4pos')')') - -# Two-terminal elements ################################################### - - `sl_transformer(linespec,keys, - input breaker keys, output breaker keys) - keys: - type=I|S - (type=I) scale=expr; (default 1.5) - cycles=n; (default 4) - (type=S) body=shaded "color"; - name=Body name; - (breaker default names BrI, BrO)' -define(`sl_transformer', - `setkeys_(`$2',name::N; type:I:N; cycles:4:N; body::N; scale:1.5:; )dnl - ifelse(`$3'`$4',, - `ifinstr(m4type,S, - `source(`$1',G,,,m4body)', - `eleminit_(`$1'); m4atmp = rp_ang; m4slen = rp_len - define(`m4swd',`dimen_*3/16*m4scale')dnl - { line to rvec_((m4slen-m4swd)/2,0) - {ifelse(m4name,,SL_box,m4name): [ linewid = linewid*m4scale - {L1: inductor(to vec_(0,-m4cycles*dimen_/8),,m4cycles)} - {point_(m4atmp) - L2: inductor(from vec_(dimen_*3/16,-m4cycles*dimen_/8) \ - to vec_(dimen_*3/16,0),,m4cycles)} - C2: last line.c; point_(m4atmp) ] with .L1.c at Here} - line from rvec_(m4swd,0) to rvec_((m4slen+m4swd)/2,0) } - line invis to rvec_(rp_len,0)') ', - `m4br_two(`sl_transformer',`$1',`$2',m4brk_(`$3',BrI),m4brk_(`$4',BrO), - ifelse(`$3',,,I)`'ifelse(`$4',,,O))') ') - - `Two-terminal box' - `sl_ttbox(linespec,keys,breaker keys,breaker keys) - keys= lgth=expr; wdth=expr; box=attributes; - supp=additional rotbox commands; name=Body name; - text="text"; - (breaker default names BrI, BrO)' -define(`sl_ttbox', - `setkeys_(`$2',`lgth:dimen_*3/4; wdth:dimen_*3/4; - name::N; box::N; text::N; supp::N')dnl - ifelse(`$3'`$4',, - `eleminit_(`$1') - {line to rvec_((rp_len-m4lgth)/2,0) - {ifelse(m4name,,,m4name:)rotbox(m4lgth,m4wdth,m4box,,m4supp) \ - with .W at Here } - {ifelse(m4text,,,`{m4text at rvec_(m4lgth/2,0)}') } - line from rvec_(m4lgth,0) to rvec_((rp_len+m4lgth)/2,0)} - line invis to rvec_(rp_len,0) ', - `m4br_two(`sl_ttbox',`$1',`$2',m4brk_(`$3',BrI),m4brk_(`$4',BrO), - ifelse(`$3',,,I)`'ifelse(`$4',,,O))') ') - -define(`m4brk_',`ifelse(`$1',,, - `ifelse(`$1',C,,`$1',O,box=fill 0,`$1')`'ifelse(`$2',,,;name=`$2')')') - - `sl_rectifier(ttbox args)' -define(`sl_rectifier', - `sl_ttbox(`$@') - { line from last [].Line.ne to last [].Line.sw - AC: ACsymbol(at last [].C+(-m4lgth/6, m4wdth/4),,,R) - DC: DCsymbol(at 2nd last [].C+( m4lgth/6,-m4wdth/4),,,R) } ') - - `sl_inverter(ttbox args)' -define(`sl_inverter', - `sl_ttbox(`$@') - { line from last [].Line.ne to last [].Line.sw - DC: DCsymbol(at last [].C+(-m4lgth/6, m4wdth/4),,,R) - AC: ACsymbol(at 2nd last [].C+( m4lgth/6,-m4wdth/4),,,R) } ') - - `sl_breaker(linespec, type=[A|C][D]; ttbox keys) - C is for curved breaker - D is for sl_drawout' -define(`sl_breaker', - `setkeys_(`$2',`lgth:brksiz_; wdth:brksiz_; name::N; type::N')dnl - ifinstr(m4type,C, - `ifinstr(m4type,D, - `m4ch_two(`cbreaker',`$1')', - `ifelse(m4name,,,m4name:) cbreaker(`$1')')', - `ifinstr(m4type,D, - `m4ch_two(`sl_ttbox',`$1',lgth=m4lgth;wdth=m4wdth;`$2';name=Br)', - `sl_ttbox(`$1',lgth=m4lgth;wdth=m4wdth;`$2')') ') ') - - `sl_reactor(linespec,keys,breaker keys,breaker keys) - keys= - diam=expr, - (Default breaker names BrI and BrO)' -define(`sl_reactor', - `setkeys_(`$2',`diam:sourcerad_*4/3; type::N')dnl - ifelse(`$3'`$4',, - `eleminit_(`$1') - { line to rvec_(rp_len/2,0) then to rvec_(rp_len/2,-m4diam/2); round - arc rad m4diam/2 cw from Here to rvec_(m4diam/2,m4diam/2) \ - with .c at rvec_(0,m4diam/2); round - line to rvec_(rp_len/2-m4diam/2,0) } - {[ box invis ht m4diam wid m4diam ] at rvec_(rp_len/2,0)} - line invis to rvec_(rp_len,0) ', - `m4br_two(`sl_reactor', `$1', lgth=m4diam*2;`$2', - m4brk_(`$3',BrI),m4brk_(`$4',BrO),ifelse(`$3',,,I)`'ifelse(`$4',,,O))')') - - `sl_busbar( linespec, nports, keys ) - Labels P1, P2 ... Pnports are defined on the line. - keys: line=line attributes; - port=D; (dotted ports) - The bus extends beyond the first and last points - by dimen_/5 which can be redefined as - line=chop -(expr)' -define(`sl_busbar', - `define(`m4npoints',`ifelse(`$2',,2,`$2')')dnl - setkeys_(`$3',`line:thick 1.6 chop -dimen_/5:N; port::N')dnl - [ tmp_ang = rp_ang - eleminit_(`$1',(m4npoints-1)*dimen_) - Start: last line.start; End: last line.end - for_(1,m4npoints,1, - `P`'m4x: (m4x-1)/(m4npoints-1) between Start and End dnl - ifinstr(m4port,D,` ;dot(at P`'m4x)')') - Line: line from Start to End m4line - Start: last line.start; End: last line.end - point_(tmp_ang) ] ') - - `sl_drawout(linespec, keys, R) - Drawout (i.e. plugin) chevron element; - keys: type=T; (truncated leads) - lgth=expr; (body size) - wdth=expr; - name=Name; (body name) - line= line attributes (e.g. thick 2) - arg3=R reverse direction' -define(`sl_drawout', - `setkeys_(`$2',`lgth:drosiz_; wdth:drosiz_; type::N; name::N; line::N')dnl - eleminit_(`$1',ifelse(m4type,T,m4lgth)) - ifelse(`$3',R,`{M4ds: Here; move to last line.end; rp_ang = rp_ang+pi_') - {line to rvec_(rp_len/2,0) - ifelse(m4name,,,m4name:) [ - S: Here; {line from rvec_(-m4lgth/2,m4wdth/2) to Here then - to rvec_(-m4lgth/2,-m4wdth/2) m4line } - E: rvec_(m4lgth/2,0); line from rvec_(0,m4wdth/2) to E then - to rvec_(0,-m4wdth/2) m4line ] with .S at Here - ifelse(m4type,T,, - line from last [].E to last [].E+vec_((rp_len-m4lgth)/2,0))} - ifelse(`$3',R,`rp_ang = rp_ang-pi_; move to M4ds}') - line invis to rvec_(rp_len,0) ') - -# Two-terminal utilities ################################################## - - `Breakers in the input and output lines:' - `m4br_two(`2-term element macroname in quotes', - linespec, body keys, - input breaker keys, - output breaker keys, - I|O|IO)' - `(Default breaker names are BrI and BrO)' -define(`m4br_two', - `define(`m4il',`ifinstr(`$6',I,`setkey_(`$4',lgth,brksiz_) m4lgth',0)')dnl - define(`m4ol',`ifinstr(`$6',O,`setkey_(`$5',lgth,brksiz_) m4lgth',0)')dnl - define(`m4bl',`setkey_(`$3',lgth,dimen_*4/3) m4lgth')dnl - eleminit_(`$2',dimen_*3) - M4start: Here; M4end: last line.end - M4cc: last line.c+vec_(((m4il*3/2)-(m4ol*3/2)),0) - M4ii: M4cc+vec_(-min((m4bl/2+m4il/2),distance(M4start,M4cc)-m4il),0) - line from M4start to ifinstr(`$6',I, - `M4ii+vec_(-m4il,0); sl_breaker(to M4ii,`$4';name=BrI)',M4ii) - M4oi: M4cc+vec_(min((m4bl/2+m4ol/2),distance(M4end,M4cc)-m4ol),0) - $1(from M4ii to M4oi,`$3') - ifinstr(`$6',O,`sl_breaker(to M4oi+vec_(m4ol,0),`$5';name=BrO)') - line to M4end - line invis from M4start to M4end ') - - `Chevrons in the input and output lines:' - `m4ch_two(`2-term element macroname in quotes', - linespec, body keys, - input breaker keys, - output breaker keys, - I|O|IO)' -define(`m4ch_two', - `define(`m4bl',`setkey_(`$3',lgth,dimen_*3/8) m4lgth')dnl - eleminit_(`$2',dimen_*3) - M4start: Here; M4end: last line.end - M4elem: $1(to rvec_(m4bl+2*drosiz_,0) with .c at last line.c,`$3') - sl_drawout(from last line.start-vec_(drosiz_,0) to last line.start,type=T,R) - line from last line.start to M4start - sl_drawout(from M4elem.end to M4elem.end+vec_(drosiz_,0),type=T) - line to M4end - line invis from M4start to M4end') - -# Composite elements ################################################### - - `sl_ct( at position, stem length, U|D|L|R|expr, - scale=expr) (default scale is 1.5)' -define(`sl_ct', - `[ setdir_(`$3'); setkey_(`$4',scale,1.5); linewid = linewid*m4scale - L: inductor(to vec_(2*dimen_/8,0),,2) - stemlen = ifelse(`$2',,dimen_/5,`$2') - line from L.start to L.start+vec_(0,-stemlen) - Ts: Here - line from L.end to L.end+vec_(0,-stemlen) - Te: Here - line from L.c to L.c+vec_(0,-stemlen) - Tc: Here - resetdir_ ] with .L.c at ifelse(`$1',,Here,patsubst(`$1',^ *at *)) ') - -# ####################################################################### - -divert(0)dnl diff --git a/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 b/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 index 95c9f2b2ca..2bccc8cd8f 100644 --- a/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 +++ b/graphics/circuit_macros/examples/svg/SwitchesSVG.m4 @@ -4,124 +4,145 @@ cct_init(svg_font(sans-serif,11bp__,2bp__)) textoffset = 3bp__ movewid = 0.25 + +define(`Below',`at last [].s+(0,-(8 ifelse(`$1',,,+10*(`$1')))bp__)') +movewid = 0.25 + # Row 1 right_; { - lswitch; {S:"svg_tt(`lswitch')" at last [].s+(0,-10bp__)} + lswitch; {"svg_tt(`lswitch')" at last [].s Below} move right_ - lswitch(,,O); {"svg_tt(`(,,O)')" at (last [],S)} + lswitch(,,O); {"svg_tt(`(,,O)')" at last [].s Below} move right_ - lswitch(,,C); {"svg_tt(`(,,C)')" at (last [],S)} + lswitch(,,C); {"svg_tt(`(,,C)')" at last [].s Below} move right_ - lswitch(,,DA); {"svg_tt(`(,,DA)')" at (last [],S)} + lswitch(,,DA); {"svg_tt(`(,,DA)')" at last [].s Below} move right_ - lswitch(,,dDO); {"svg_tt(`(,,dDO)')" at (last [],S)} + lswitch(,,dDO); {"svg_tt(`(,,dDO)')" at last [].s Below} move right_ - lswitch(,,uDC); {"svg_tt(`(,,uDC)')" at (last [],S)} + lswitch(,,uDC); {"svg_tt(`(,,uDC)')" at last [].s Below} } # Row 2 - move down; right_; { - lswitch(,,K); {S:"svg_tt(`(,,K)')" at last [].s+(0,-10bp__)} + move down 0.4; right_; { + lswitch(,,K); {"svg_tt(`(,,K)')" at last [].s Below} move right_ - lswitch(,,KD); {"svg_tt(`(,,KD)')" at (last [],S)} + lswitch(,,KD); {"svg_tt(`(,,KD)')" at last [].s Below} move right_ - lswitch(,,KOD); {"svg_tt(`(,,KOD)')" at (last [],S)} + lswitch(,,KOD); {"svg_tt(`(,,KOD)')" at last [].s Below} move right_ - lswitch(,,KCD); {"svg_tt(`(,,KCD)')" at (last [],S)} + lswitch(,,KCD); {"svg_tt(`(,,KCD)')" at last [].s Below} move right_ - bswitch; {"svg_tt(``bswitch'')" at (last [],S)} + bswitch; {"svg_tt(``bswitch'')" at last [].s Below} move right_ - bswitch(,,C); {"svg_tt(`(,,C)')" at (last [],S)} + bswitch(,,C); {"svg_tt(`(,,C)')" at last [].s Below} } # Row 3 - move down; right_; { - D: dswitch(,,); {S: "svg_tt(`dswitch(,,)')" at last [].s+(0,-10bp__)} + move down 0.45; right_; { + D: dswitch; {"svg_tt(`dswitch')" at D.start below ljust} thinlines_ - { spline <- from 0.25 along_(D) up 0.1 then up 0.05 left 0.1 - {"svg_tt(`W')" rjust} - spline <- from D.c+(0,m4sc*2) up 0.1 then up 0.05 left 0.1 - {"svg_tt(`B')" rjust }} + {spline <- from last [].B.c up 0.1 then up 0.05 left 0.1 + "svg_tt(`B')" rjust} thicklines_ move right_ - D: dswitch(,,WdBK); {"svg_tt(`(,,WdBK)')" at (last [],S)+(0,-4bp__)} + dswitch(,,WdBK); {"svg_tt(`(,,WdBK)')" at last [].s Below} thinlines_ - { spline <- from tr_xy(0,-2) up 0.1 then up 0.10 left 0.1 - {"svg_tt(`dB')" rjust} - spline <- from tr_xy(4,-2) right 0.1 then right 0.05 up 0.15 + { spline <- from 0.5 along_(last [].B) up 0.1 then up 0.10 left 0.1 + {"svg_tt(`B')" rjust} } + { spline <- from last [].K right 0.1 then right 0.05 up 0.15 {"svg_tt(`K')" above }} thicklines_ move right_ - dswitch(,,WBmdDK); {"svg_tt(`(,,WBmdDK)')" at (last [],S)} + dswitch(,,WBmdDK); {"svg_tt(`(,,WBmdDK)')" at last [].s Below} move right_ - dswitch(,,WBKTr); {"svg_tt(`(,,WBKTr)')" at (last [],S)} + dswitch(,,WBKTr); {"svg_tt(`(,,WBKTr)')" at last [].s Below} move right_ - dswitch(,,WdBL); {"svg_tt(`(,,WdBL)')" at (last [],S+(0,-4bp__))} + dswitch(,,WdBL); {"svg_tt(`(,,WdBL)')" at last [].s Below} move right_ - dswitch(,,WBCo); {"svg_tt(`(,,WBCo)')" at (last [],S)} + dswitch(,,WBSd); {"svg_tt(`(,,WBSd)')" at last [].s Below} } # Row 4 - move down; right_; { - dswitch(,,WBKCo); {S: "svg_tt(`(,,WBKCo)')" at last [].s+(0,-10bp__)} + move down 0.4; right_; { + dswitch(,,WBCb); {"svg_tt(`(,,WBCb)')" at last [].s Below} move right_ - dswitch(,,WBCb); {"svg_tt(`(,,WBCb)')" at (last [],S)} + dswitch(,,WBcCb); {"svg_tt(`(,,WBcCb)')" at last [].s Below} move right_ - dswitch(,,WBDI); {"svg_tt(`(,,WBDI)')" at (last [],S)} + dswitch(,,WBcDI); {"svg_tt(`(,,WBcDI)')" at last [].s Below} + thinlines_ + {arrow <- from last [].DI.start up_ 0.1 right_ 0.15; "svg_tt(`DI')" ljust} + thicklines_ move right_ - dswitch(,,WBSd); {"svg_tt(`(,,WBSd)')" at (last [],S)} +# dswitch(,,WBDI); {"svg_tt(`(,,WBDI)')" at last [].s Below} + dswitch(,,WBKCo); {"svg_tt(`(,,WBKCo)')" at last [].s Below} move right_ - dswitch(,,WBFDI); {"svg_tt(`(,,WBFDI)')" at (last [],S)} + dswitch(,,WBFDI); {"svg_tt(`(,,WBFDI)')" at last [].s Below} move right_ - dswitch(,,WBFSd); {"svg_tt(`(,,WBFSd)')" at (last [],S)} + dswitch(,,WBFSd); {"svg_tt(`(,,WBFSd)')" at last [].s Below} } # Row 5 - move down moveht*5/4; right_; { - dswitch(,,WBTh); {S: "svg_tt(`(,,WBTh)')" at last [].s+(0,-10bp__)} + move down 0.4; right_; { + dswitch(,,WBMMR); {"svg_tt(`(,,WBMMR)')" at last [].s Below} move right_ - dswitch(,,WBKC); {"svg_tt(`(,,WBKC)')" at (last [],S)} + dswitch(,,WBMM); {"svg_tt(`(,,WBMM)')" at last [].s Below} move right_ - dswitch(,,WBM); {"svg_tt(`(,,WBM)')" at (last [],S)} + dswitch(,,WBMR); {"svg_tt(`(,,WBMR)')" at last [].s Below} move right_ - dswitch(,,WBCO); {"svg_tt(`(,,WBCO)')" at (last [],S)} + dswitch(,,WBEL); {"svg_tt(`(,,WBEL)')" at last [].s Below} move right_ - dswitch(,,WBMP); {"svg_tt(`(,,WBMP)')" at (last [],S)} + dswitch(,,WBLE); {"svg_tt(`(,,WBLE)')" at last [].s Below} move right_ - dswitch(,,WBoKCP); {"svg_tt(`(,,WBoKCP)')" at (last [],S)} + dswitch(,,WBoKEL); {"svg_tt(`(,,WBoKEL)')" at last [].s Below} } # Row 6 - move down moveht*5/4; right_; { - dswitch(,,WBCY); {S: "svg_tt(`(,,WBCY)')" at last [].s+(0,-10bp__)} - move right_ - dswitch(,,WBCZ); {"svg_tt(`(,,WBCZ)')" at (last [],S)} + move down moveht+2bp__; right_; { + dswitch(,,WBTh); {"svg_tt(`(,,WBTh)')" at last [].s Below} move right_ - dswitch(,,WBCE); {"svg_tt(`(,,WBCE)')" at (last [],S)} + dswitch(,,WBKC); {"svg_tt(`(,,WBKC)')" at last [].s Below} + thinlines_ + { arrow <- from last [].C.c left 0.2; "svg_tt(`C')" rjust } + thicklines_ move right_ - dswitch(,,WBRH); {"svg_tt(`(,,WBRH)')" at (last [],S)} + dswitch(,,WBM); {"svg_tt(`(,,WBM)')" at last [].s Below} move right_ - dswitch(,,WBRdH); {"svg_tt(`(,,WBRdH)')" at (last [],S)} + dswitch(,,WBCO); {"svg_tt(`(,,WBCO)')" at last [].s Below} move right_ - dswitch(,,WBRHH); {"svg_tt(`(,,WBRHH)')" at (last [],S)} + dswitch(,,WBMP); {"svg_tt(`(,,WBMP)')" at last [].s Below} + move down_ 2bp__ then right_ + dswitch(,,WBoKCP); {"svg_tt(`(,,WBoKCP)')" at last [].s Below} } # Row 7 - move down moveht*5/4; right_; { - move down 2bp__; right_ - dswitch(,,WBPr); {S: "svg_tt(`(,,WBPr)')" at last [].s+(0,-10bp__)} + move down moveht*7/6; right_; { + dswitch(,,WBCY); {"svg_tt(`(,,WBCY)')" at last [].s Below} move right_ - dswitch(,,WBPrT); {S: "svg_tt(`(,,WBPrT)')" at last [].s+(0,-10bp__)} - move down_ 6bp__ then right_ - dswitch(,,WBPrM); {S: "svg_tt(`(,,WBPrM)')" at last [].s+(0,-10bp__)} + dswitch(,,WBCZ); {"svg_tt(`(,,WBCZ)')" at last [].s Below} + move right_ + dswitch(,,WBCE); {"svg_tt(`(,,WBCE)')" at last [].s Below} + move right_ + dswitch(,,WBRH); {"svg_tt(`(,,WBRH)')" at last [].s Below} + move right_ + dswitch(,,WBRdH); {"svg_tt(`(,,WBRdH)')" at last [].s Below} + move right_ + dswitch(,,WBRHH); {"svg_tt(`(,,WBRHH)')" at last [].s Below} } # Row 8 - move down; right_; { - dswitch(,,WBMMR); {S: "svg_tt(`(,,WBMMR)')" at last [].s+(0,-10bp__)} - move right_ - dswitch(,,WBMM); {"svg_tt(`(,,WBMM)')" at (last [],S)} + move down moveht; right_; { + move down_ 2bp__; right_ + dswitch(,,WBPr); {"svg_tt(`(,,WBPr)')" at last [].s Below} move right_ - dswitch(,,WBMR); {"svg_tt(`(,,WBMR)')" at (last [],S)} + dswitch(,,WBPrT); {"svg_tt(`(,,WBPrT)')" at last [].s Below} + move down_ 6bp__ then right_ + dswitch(,,WBPrM); {"svg_tt(`(,,WBPrM)')" at last [].s Below} move right_ - dswitch(,,WBEL); {"svg_tt(`(,,WBEL)')" at (last [],S)} + dswitch(,,WBDIGX,text=W); #{"svg_tt(`(,,WBDIGX,W)')" at last [].s Below} + {"svg_tt(`(,,WBDIGX,')" ljust at last line.start+(0,-15bp__) \ + "svg_tt(`text=W)')" ljust} move right_ - dswitch(,,WBLE); {"svg_tt(`(,,WBLE)')" at (last [],S)} + dswitch(,,WBDIGC,text=M) + {"svg_tt(`(,,WBDIGC,')" ljust at last line.start+(0,-15bp__) \ + "svg_tt(`text=M)')" ljust} move right_ - dswitch(,,WBoKEL); {"svg_tt(`(,,WBoKEL)')" at (last [],S)} + dswitch(,,WBcDIGC,text=M) # + {"svg_tt(`(,,WBcDIGC,')" ljust at last line.start+(0,-15bp__) \ + "svg_tt(`text=M)')" ljust} } command "</g>')" # end font diff --git a/graphics/circuit_macros/examples/svg/controlSVG.m4 b/graphics/circuit_macros/examples/svg/controlSVG.m4 index ab2eea7efc..29f80df221 100644 --- a/graphics/circuit_macros/examples/svg/controlSVG.m4 +++ b/graphics/circuit_macros/examples/svg/controlSVG.m4 @@ -14,7 +14,7 @@ PID: [ arrow S1: circle line right "svg_it(e(s))" above - { arrow right ; box ht bh wid bw "svg_it(K)svg_sub(p)" + { arrow right ; box ht bh wid bw "svg_it(K)svg_sub(P)" arrow right linewid-circlerad ; S2: circle } { line up linewid ; arrow right ; box ht bh wid bw "svg_it(K)svg_sub(D)s" line to (S2,Here) ; arrow to S2.n } diff --git a/graphics/circuit_macros/examples/svg/cscSVG.m4 b/graphics/circuit_macros/examples/svg/cscSVG.m4 index afc633403f..8f1b954669 100644 --- a/graphics/circuit_macros/examples/svg/cscSVG.m4 +++ b/graphics/circuit_macros/examples/svg/cscSVG.m4 @@ -69,11 +69,11 @@ rgbdraw(midnight, line to coord(-2.2,-2.05) then to coord(2.1,-1.75) # spline to coord(-1,-2.08) then to coord(0.55,-1.77) line to coord(2.1,-1.75) -resetrgb + resetrgb setrgb(white) spline from coord(-2.2,-2.05) to coord(-1,-2.08) then to coord(0.55,-1.77) line to coord(-2.2,-2.05) -resetrgb + resetrgb linethick=`0.'eval(lwid*15)/(1pt__) ] diff --git a/graphics/circuit_macros/examples/svg/examplesSVG.htmx b/graphics/circuit_macros/examples/svg/examplesSVG.htmx index ec9847b32e..a7c830ed54 100644 --- a/graphics/circuit_macros/examples/svg/examplesSVG.htmx +++ b/graphics/circuit_macros/examples/svg/examplesSVG.htmx @@ -55,6 +55,13 @@ ifinstr(`$3',y,,`<hr>')') width="700px" border="0" align="center" ><tr><td> <H2>SVG Circuit_macros examples, Version XXX</H2> + +<A HREF="../../index.html">Home</A> +> +<A HREF="examples.html">Examples</A> +> +<A HREF="examplesSVG.html">SVG</A> + <hr> <p> @@ -309,7 +316,7 @@ cfig(InductorsSVG, Inductors) cfig(DiodesSVG, - Diodes: a m4tt`'K</g> in the second argument draws an open + Diodes: appending a m4tt`'K</g> to the second argument draws an open arrowhead) cfig(EmarrowsSVG, @@ -334,8 +341,9 @@ cfig(GroundsSVG, Ground symbols) cfig(SwitchesSVG, - The switch macros; m4tt`'switch(`,'`,'`,'L|B|D)</g> is a wrapper - for m4tt`'lswitch</g>`,' m4tt`'bswitch</g>`,' and m4tt`'dswitch</g>) + The switch macros; m4tt`'switch(`,'`,'`,'L|B|D,attribs)</g> + is a wrapper for m4tt`'lswitch</g>`,' m4tt`'bswitch</g>`,' + and m4tt`'dswitch</g>) cfig(AntennasSVG, Antenna symbols) @@ -585,8 +593,10 @@ cfig(GrayCodeSVG, Gray code 10-bit encoder disk pattern`,' and a crossbar switch) +<!-- #cfig(CrossbarSVG, # A crossbar switch) +--> cfig(ByteSVG, Elementary splines) @@ -597,7 +607,7 @@ cfig(RotboxSVG, draws a box in the current direction) cfig(ex06SVG, - Crosshatching by m4tt`'for</g> loops) + Crosshatching) cfig(ex09SVG, Illustrating the macro @@ -616,18 +626,18 @@ cfig(ex09SVG, specifies the arc to be dimensioned and the second argument is the outward radial offset of the dimension arrow arc.) -cfig(ex05SVG, - Use of m4tt`'darrow</g> and m4tt`'Darc</g>) - cfig(PlateSVG, Dimensioning with tolerances according to ASME Y14.5) Use of m4tt`'darrow</g> and m4tt`'Darc</g>) +cfig(ex05SVG, + Use of m4tt`'darrow</g> and m4tt`'Darc</g>) + cfig(LoglogSVG, - A graph drawn using the pic language) + Graphs drawn using the pic language) cfig(GeometrySVG, - Plane geometry examples and an illustration of a Lyapunov function) + Plane geometry examples) <!-- #cfig(LyapSVG, @@ -643,14 +653,15 @@ cfig(expSVG, the <i>y1`,'z1</i> plane by sighting along the x1 axis.) cfig(graysurfSVG, - Plotting surfaces using gray scales. A sort algorithm - determines plotting order) + Plotting surfaces using gray scales) cfig(shapesSVG, Basic shapes) +<!-- #fig(AntiqueClockSVG, # An antique clock face) +--> cfig(cscSVG, Conestoga Sailing Club (illustrating the filling of arbitrary shapes)`,' @@ -684,14 +695,19 @@ cfig(SierpinskiSVG, The Sierpinski triangle and a Cayley graph: tests of pic macro recursion) +cfig(EscherSVG, + Two Escher-like objects) + cfig(recycleSVG, Modest repetition and partial fill) cfig(ex15SVG, Simple diagrams that are easily drawn by looping) +<!-- cfig(CountingSVG, An example of enumeration) +--> cfig(CrowSVG, Illustrating m4tt`'shadebox</g> and a custom crowfoot line diff --git a/graphics/circuit_macros/examples/svg/expSVG.m4 b/graphics/circuit_macros/examples/svg/expSVG.m4 index 27209b094e..4d12688f97 100644 --- a/graphics/circuit_macros/examples/svg/expSVG.m4 +++ b/graphics/circuit_macros/examples/svg/expSVG.m4 @@ -8,51 +8,6 @@ NeedDpicTools # postprocessors do not have the same functionality so the following # demonstrates how it can be done in the pic language with m4 macros. -# `shadedpolygon(shadedpvertseq,line attributes, -# sweep angle (degrees),colorseq) -# arg1 is a colon (:) separated sequence of -# positions or position names, the vertices in -# order (cw or ccw) of the polygon. Colored -# shade lines are drawn perpendicular to the -# sweep angle. A colorseq is of the form -# 0,r0,g0,b0, -# frac1,r1,g1,b1, -# frac2,r2,g2,b2, -# ... -# 1,rn,gn,bn' -#`e.g. shadedpolygon((0,0):(0,1):(2,1):(2,0),,0,0,1,1,1,1,0,0,0)' -define(`shadedpolygon',`[ Origin: Here - shadedpverts(V,1,patsubst(patsubst(`$1',`,',|),:,`,')) - nverts = m4vx - T: (Rect_(1,`$3')) - p0 = 1; d[1] = T.x*V[1].x + T.y*V[1].y - pm = 1 - for i=2 to nverts do { d[i] = T.x*V[i].x + T.y*V[i].y - if d[i] < d[p0] then { p0 = i } - if d[i] > d[pm] then { pm = i } } - d0 = d[p0]; dmx = d[pm]-d0 - for i=1 to nverts do { d[i] = (d[i]-d0)/dmx } - qL = p0; pL = qL + 1; if pL > nverts then { pL = 1 } - qR = p0; pR = qR - 1; if pR < 1 then { pR = nverts } - nlines = int(1.5*dmx/lthick) - ShadeObject(ShadedPline,nlines,shift(shift(shift($@)))) \ - with .Origin at Origin - Midpt: 0.5 between V[1] and V[nverts] - line `$2' \ - from Midpt to for_(1,m4vx,1,`V[m4x] then to\') Midpt - Start: V[p0]; End: V[pm] - ]') -define(`shadedpverts',` -ifelse($3,,,`$1[$2]: patsubst(`$3',|,`,') define(`m4vx',$2) -shadedpverts(`$1',incr(`$2'),shift(shift(shift($@))))')') -define ShadedPline { - if $1 > d[pL] then { qL = pL; pL = qL + 1; if pL > nverts then {pL = 1} } - if $1 > d[pR] then { qR = pR; pR = qR - 1; if pR < 1 then {pR = nverts} } - M4L: ($1-d[qL])/(d[pL]-d[qL]) between V[qL] and V[pL] - M4R: ($1-d[qR])/(d[pR]-d[qR]) between V[qR] and V[pR] - line outlined rgbstring($2,$3,$4) \ - from M4L to M4R } - # Projected box object: [ g = 1.2 @@ -183,7 +138,7 @@ thicklines_ SE: Project( rectht/2, rectwid*0.75,0) NE: Project(-rectht/2, rectwid*0.75,0) - shadedpolygon(NW:NE:SE:SW,,-90, + ShadedPolygon(NW:NE:SE:SW,,-90, 0,0.25,0.25,0.25, 1,1,1,1) with .Start at NW diff --git a/graphics/circuit_macros/examples/svg/icsSVG.m4 b/graphics/circuit_macros/examples/svg/icsSVG.m4 index 8a3c99b66f..f1eb9ae9ab 100644 --- a/graphics/circuit_macros/examples/svg/icsSVG.m4 +++ b/graphics/circuit_macros/examples/svg/icsSVG.m4 @@ -283,18 +283,18 @@ define(`DIP_chip_outline', type=I|Q; (default I for uniform-length pins; Q: staggered) ' define(`DIP',`[ pinct= ifelse(`$1',,8,`$1') - Loopover_(`Z',`setkey_(`$2',patsubst(Z,:.*),patsubst(Z,.*:))', + Loopover_(`Z',`pushkey_(`$2',patsubst(Z,:.*),patsubst(Z,.*:))', bodywid: 5*L_unit, bodylen: m4pinpitch*int(pinct/2+0.5), pinpitch:2*L_unit, pinwid: 1.2*L_unit, pinlen: L_unit) - Loopover_(`Z',`setkey_(`$2',patsubst(Z,:.*),patsubst(Z,.*:),N)', + Loopover_(`Z',`pushkey_(`$2',patsubst(Z,:.*),patsubst(Z,.*:),N)', direct:U, type:I) setdir_(m4direct,U) Body: box ht_ m4bodywid wid_ m4bodylen - arcs = ifelse(m4dir,right,90,m4dir,up,180,m4dir,left,270,0) + arcs = ifelse(m4_dir_,right,90,m4_dir_,up,180,m4_dir_,left,270,0) arcd(Body.e_, 0.1/2, arcs,arcs+180) np2 = int(pinct/2+0.5) define(`m4bxht',`m4pinlen ifelse(m4type,Q,`*(1+(i%%2))')')dnl diff --git a/graphics/circuit_macros/examples/svg/quickSVG.m4 b/graphics/circuit_macros/examples/svg/quickSVG.m4 index 3e77ad1694..c4ddb20122 100644 --- a/graphics/circuit_macros/examples/svg/quickSVG.m4 +++ b/graphics/circuit_macros/examples/svg/quickSVG.m4 @@ -1,4 +1,5 @@ .PS # Pic input begins with .PS +# quickSVG.m4 cct_init # Set defaults elen = 0.75 # Variables are allowed; default units are inches @@ -6,7 +7,7 @@ move right 0.4 Origin: Here # Position names are capitalized svgLink(SourcesSVG.svg,source(up_ elen)) llabel(-,svg_it(v`'svg_sub(s)),+) - svgLink(CctTableSVG.svg,resistor(right_ elen)); rlabel(,svg_it(R),) + svgLink(ResistorsSVG.svg,resistor(right_ elen)); rlabel(,svg_it(R),) dot { # Save current position and direction capacitor(down_ to (Here,Origin)) #(Here,Origin) = (Here.x,Origin.y) diff --git a/graphics/circuit_macros/examples/svg/sldtestsSVG.m4 b/graphics/circuit_macros/examples/svg/slddiagsSVG.m4 index 658af488d6..ce213358d0 100644 --- a/graphics/circuit_macros/examples/svg/sldtestsSVG.m4 +++ b/graphics/circuit_macros/examples/svg/slddiagsSVG.m4 @@ -1,14 +1,10 @@ .PS # slddiagsSVG.m4 cct_init(svg_font(sans-serif,10bp__)) -include(../test/sld/SLD.m4) - -divert(-1) - -divert(0)dnl +include(libSLD.m4) Pic1: [ -define(`TRFDY', +define(`TrDeltaWye', `sl_transformer(down_ elen_ `$1',type=S) { Deltasymbol(at last [].M1); Ysymbol(at 2nd last [].M2,,D) } ') @@ -18,19 +14,19 @@ define(`TRFDY', {"svg_small(20 kV)" at Bus1.Start above ljust} S1: switch(from Bus1.P1-(0,elen_) up_ elen_) S2: switch(from Bus1.P2-(0,elen_) up_ elen_) - TRF1: TRFDY(from Bus1.P3); arrow down_ dimen_/3 - TRF2: TRFDY(from Bus1.P4); arrow down_ dimen_/3 - TRF3: TRFDY(from Bus1.P5); arrow down_ dimen_/3 + TRF1: TrDeltaWye(from Bus1.P3); arrow down_ dimen_/3 + TRF2: TrDeltaWye(from Bus1.P4); arrow down_ dimen_/3 + TRF3: TrDeltaWye(from Bus1.P5); arrow down_ dimen_/3 S3: switch(from Bus1.P6-(0,elen_) up_ elen_) Bus2: sl_busbar(right_ 1.5*dimen_,3,port=D) with .c at Bus1.P1+(0,-dimen_*3) {"svg_small(20 kV)" at Bus2.Start above ljust} {"svg_small(1.25 MVA)" at Bus2.P2 below} S4: switch(from Bus2.P2 to S1.start) - TRF4: TRFDY(from Bus2.P1) + TRF4: TrDeltaWye(from Bus2.P1) S4: switch(from Bus2.P3+(0,-elen_) to Bus2.P3) ] -Pic3: [ +Pic2: [ # https://tex.stackexchange.com/questions/597643/draw-a-power-system-network B1: sl_busbar(up_ dimen_*4/3,3) sl_transformer(right_ 2*dimen_ from last [].P2, @@ -48,37 +44,37 @@ Pic3: [ shaded "Goldenrod" "Static Load" line right_ dimen_*3/4 from B3.P2; box wid dimen_*3 ht dimen_*.6 \ shaded rgbstring(0.99*0.8, 0.74*0.8, 0.71*0.8) "Electronic Load" - sl_disk(at B3.P3,,R, + sl_disk(right_ dimen_ from B3.P3, text="A/C";circle=shaded ```rgbstring(.2,.8,.2)''';diam=dimen_*3/4) - sl_disk(at B3.P4,,R, + sl_disk(right_ dimen_ from B3.P4, text="M";circle=shaded ```rgbstring(.21,.47,.86)''';diam=dimen_*3/4) - sl_disk(at B3.P5,,R, + sl_disk(right_ dimen_ from B3.P5, text="M";circle=shaded ```rgbstring(.2,.6,.8)''';diam=dimen_*3/4) - sl_disk(at B3.P6,,R, + sl_disk(right_ dimen_ from B3.P6, text="M";circle=shaded ```rgbstring(.2,.63,.8)''';diam=dimen_*3/4) - sl_disk(at 1/2 between B3.P1 and B3.P2,,L, + sl_disk(left_ dimen_ from 1/2 between B3.P1 and B3.P2, text="svg_small(DER_A)";\ circle=shaded ```rgbstring(0.78,0.36,0.3)''';diam=dimen_*3/4) ] with .nw at last [].sw + (100bp__,120bp__) -Pic2: [ +Pic3: [ define(`shadedb',`shaded "CornflowerBlue"') Loopover_(`LR', # loop to take advantage of symmetry - `define(`lrdir',ifelse(LR,L,`right_',`left_'))dnl - LR`'side: [ - sl_generator(,dimen_,LR,type=B;name=G1;circle=shadedb,box=shadedb) - T1: sl_transformer(lrdir dimen_*3/2) + `define(`opposite',`ifelse(LR,left,right,left)')dnl + ifelse(LR,left,L,R)`'side: [ + sl_generator(LR dimen_/2,type=B;name=G1;circle=shadedb,box=shadedb) + T1: sl_transformer(opposite dimen_*3/2) Bus1: sl_busbar(up_ dimen_*3/2,3,) with .P2 at Here - Br1: sl_breaker(from Bus1.P3 lrdir elen_,box=shadedb) - line lrdir dimen_ - Br2: sl_breaker(from Bus1.P1 lrdir elen_,box=shadedb) + Br1: sl_breaker(from Bus1.P3 opposite elen_,box=shadedb) + line opposite dimen_ + Br2: sl_breaker(from Bus1.P1 opposite elen_,box=shadedb) Br3: sl_breaker(down_ dimen_,box=shadedb) - Bus2: sl_busbar(lrdir dimen_,3) with .P2 at Here + Bus2: sl_busbar(opposite dimen_,3) with .P2 at Here T2: sl_transformer(down_ dimen_ from Bus2.P2,name=X2) - sl_disk(,dimen_/2,D,type=B;text="SM";name=SM1;circle=shadedb,box=shadedb) + sl_disk(down_ dimen_/2,type=B;text="SM";name=SM1;circle=shadedb,box=shadedb) ground(at last circle.s,dimen_/2) ]', - L,R) + left,right) "Bus 1" at Lside.Bus1.top above "Bus 2" at Rside.Bus1.top above "Bus 3" at Lside.Bus2.w above @@ -89,7 +85,7 @@ Loopover_(`LR', # loop to take advantage of symmetry "G`'svg_sub(1) 50 MVA" ljust "13.8 kV" ljust at Lside.G1.w+(0,-28bp__) "G`'svg_sub(2) 30 MVA" ljust "13.8 kV" ljust at Rside.G1.w+(0,-28bp__) "T`'svg_sub(1) 50 MVA" ljust "13.8/69 kV svg_Delta/Y" ljust \ - at Lside.T1.start+(0,-33bp__) + at Lside.T1.start+(0,-37bp__) "T`'svg_sub(2) 30 MVA" ljust "69/13.8 kV Y/svg_Delta" ljust \ at Rside.T1.end+(5bp__,-33bp__) "T`'svg_sub(3) 50 MVA" rjust "13.8/69 kV Y/svg_Delta" rjust \ diff --git a/graphics/circuit_macros/examples/worm.m4 b/graphics/circuit_macros/examples/worm.m4 index f7efc1c2e6..333ad78ee0 100644 --- a/graphics/circuit_macros/examples/worm.m4 +++ b/graphics/circuit_macros/examples/worm.m4 @@ -54,7 +54,7 @@ Worm: [ setrgb(r,g,b,tmpcolor) line shaded "tmpcolor" outlined "tmpcolor" \ from C to Rect_(C.rad-0.05,90-(t-0.5)/90*360) \ - then to Rect_(C.rad-0.05,90-(t+0.5)/90*360) \ + then to Rect_(C.rad-0.05,90-(t+0.5)/90*360) \ then to C resetrgb } diff --git a/graphics/circuit_macros/examples/xfig/xfiglib.fig b/graphics/circuit_macros/examples/xfig/xfiglib.fig index 521b4d0307..c9c51e7097 100644 --- a/graphics/circuit_macros/examples/xfig/xfiglib.fig +++ b/graphics/circuit_macros/examples/xfig/xfiglib.fig @@ -6,7 +6,7 @@ Letter 100.00 Single -2 -# dpic version 2021.08.01 option -x for Fig 3.2 +# dpic version 2021.11.01 option -x for Fig 3.2 1200 2 6 0 0 3975 5025 6 0 0 3975 5025 @@ -30,7 +30,7 @@ Single 1 3 0 0 0 -1 0 -1 -1 0 1 0.0 525 211 3 3 528 211 528 211 -6 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 - 525 211 525 86 + 525 199 525 75 -6 6 750 75 975 675 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 @@ -47,11 +47,11 @@ Single 1 3 0 0 0 -1 0 -1 -1 0 1 0.0 900 211 3 3 903 211 903 211 -6 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 - 900 211 900 86 -2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 790 551 790 199 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 752 551 752 199 +2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 + 900 199 900 75 -6 6 1125 75 1200 675 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 @@ -75,11 +75,11 @@ Single 5 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 1500 263 1500 300 1463 263 1500 225 -6 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 - 1500 225 1500 75 -2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 1437 525 1438 225 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 1400 525 1400 225 +2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 + 1500 225 1500 75 -6 6 1650 75 1800 675 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 @@ -194,9 +194,9 @@ Single 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 1125 1425 1125 1275 1 3 0 1 0 -1 0 -1 -1 0 1 0.0 1125 1125 150 150 1275 1125 1275 1125 -6 1025 1075 1225 1175 -5 1 0 1 0 -1 0 -1 -1 0 0 1 0 0 1075 1125 1125 1125 1075 1075 1025 1125 -5 1 0 1 0 -1 0 -1 -1 0 0 1 0 0 1175 1125 1125 1125 1175 1175 1225 1125 +6 1025 1089 1225 1161 +5 1 0 1 0 -1 0 -1 -1 0 0 1 0 0 1075 1142 1125 1125 1075 1089 1025 1125 +5 1 0 1 0 -1 0 -1 -1 0 0 1 0 0 1175 1108 1125 1125 1175 1161 1225 1125 -6 2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2 1125 975 1125 825 @@ -328,8 +328,8 @@ Single -6 -6 6 2850 1575 3300 2025 -6 2850 1583 3300 2017 -1 3 0 1 0 -1 0 -1 -1 0 1 0.0 3075 1800 217 217 3292 1800 3292 1800 +6 2850 1583 3300 2018 +1 3 0 1 0 -1 0 -1 -1 0 1 0.0 3075 1800 218 218 3293 1800 3293 1800 -6 -6 6 1275 2250 1650 2550 |