Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. definepapersize[BookPaperSize][
  2. width=8in,
  3. height=6in,
  4. ]
  5.  
  6. setuppapersize[BookPaperSize]
  7.  
  8. % Specify the width and height here because the inline figures need to
  9. % maintain aspect ratio while setting a pleasing width.
  10. startsetups[BookIllustrationSetups]
  11. setlayerframed[BookIllustrationLayer][
  12. frame=off,
  13. x=zeropoint,
  14. y=1.25in,
  15. width=makeupwidth,
  16. background=BookTimelineOverlay,
  17. ]{}
  18. stopsetups
  19.  
  20. setupbackgrounds[page][
  21. background=BookIllustrationLayer,
  22. setups=BookIllustrationSetups
  23. ]
  24.  
  25. definelayer[BookIllustrationLayer][
  26. width=paperwidth,
  27. height=paperheight,
  28. ]
  29.  
  30. defineoverlay[BookTimelineOverlay][useMPgraphic{BookTimelineGraphic}]
  31.  
  32. startuseMPgraphic{BookTimelineGraphic}
  33. % Define constants
  34. numeric EVENT_BEGAN, TIME_OFFSET;
  35. EVENT_BEGAN := 13799;
  36. TIME_OFFSET := 1.25in;
  37. PATH_THICKNESS := 2pt;
  38.  
  39. % The book timeline title macro contains a number representing when the
  40. % event transpired and additional information.
  41. string sectionTitle, sectionTitleDigits;
  42. sectionTitle := "getspecificstructuretitle{3}";
  43. sectionTitleDigits := "";
  44.  
  45. % Extract only digits and decimals from the book timeline title macro.
  46. for i = 0 upto length( sectionTitle ):
  47. string sectionChar;
  48. sectionChar := substring( i, i + 1 ) of sectionTitle;
  49.  
  50. % A space indicates that the number has no more digits.
  51. if sectionChar = " ":
  52. break;
  53. fi;
  54.  
  55. % Concatentate all the digits together.
  56. if ((sectionChar >= "0") and (sectionChar <= "9")) or (sectionChar = "."):
  57. sectionTitleDigits := sectionTitleDigits & sectionChar;
  58. fi;
  59. endfor;
  60.  
  61. % Convert the digits from a string to a numeric value.
  62. numeric eventTime;
  63. eventTime := 0;
  64.  
  65. for i = scantokens( sectionTitleDigits ):
  66. eventTime := i;
  67. endfor;
  68.  
  69. numeric eventX;
  70. eventX := 1 - (eventTime / EVENT_BEGAN);
  71.  
  72. % Draw the line.
  73. draw (TIME_OFFSET, .5*overlayheight) -- (overlaywidth, .5*overlayheight)
  74. withpen pencircle scaled PATH_THICKNESS;
  75.  
  76. % Draw starting |.
  77. draw (TIME_OFFSET, 0) -- (TIME_OFFSET, overlayheight)
  78. withpen pencircle scaled PATH_THICKNESS;
  79.  
  80. % Draw ending |.
  81. draw (overlaywidth, 0) -- (overlaywidth, overlayheight)
  82. withpen pencircle scaled PATH_THICKNESS;
  83.  
  84. % Draw the timeline's dot relative to the event on the timeline.
  85. filldraw fullcircle scaled 9
  86. shifted(
  87. TIME_OFFSET + eventX * (overlaywidth - TIME_OFFSET), .5*overlayheight
  88. );
  89. stopuseMPgraphic
  90.  
  91. starttext
  92. chapter[title={Inflation Theory},reference={inflation-theory}]
  93. section[title={13,799 ± 0.021},reference={section}]
  94. input ward
  95.  
  96. chapter[title={First Stars},reference={first-stars}]
  97. section[title={13,689 ± 70},reference={section-1}]
  98. input ward
  99. stoptext
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement