home *** CD-ROM | disk | FTP | other *** search
/ Global Amiga Experience / globalamigaexperience.iso / graphic / video_presentation / titler_presentation / helm / examples / plotbook (.txt) < prev    next >
Encoding:
Helm Multimedia Book  |  1995-07-10  |  18.3 KB  |  505 lines

  1. PlotBook
  2. Scott Nickerson
  3. 12-09-93
  4. TRIGONOMETRY
  5. on BookOpen
  6. begin
  7.   set the pointer to 6
  8.   set the brushnumber to 1
  9.   clearplot()
  10.   set the pointer to 0
  11. on clearplot
  12. begin
  13.   global cx, cy, TE, BE, LE, RE
  14.   put "\nCLEARING\nPLOT" into textfield "Readout"
  15.   put 6 into Bd
  16. // this is the border size
  17.   put the id of button "theArea" into Bid
  18.   put the topedge of (button id Bid) + Bd into TE
  19.   put the bottomedge of (button id Bid) - Bd into BE
  20.   put the leftedge of (button id Bid) + Bd into LE
  21.   put the rightedge of (button id Bid) - Bd into RE
  22.   put the width of button id Bid into w
  23.   put the height of button id Bid into h
  24.   put the pencolor into tempcolor
  25.   set the apen to 2
  26.   fillbox LE, TE, RE, BE
  27.   set the apen to 5
  28.   put LE + w / 2 - Bd into cx
  29.   put TE + h / 2 - Bd into cy
  30.   fillbox cx, TE, cx, BE
  31.   fillbox LE, cy, RE, cy
  32. // Add horizontal marks
  33.   put textfield "Zoom:" into zm
  34.   put 0 into n
  35.   put 0 into k
  36.   put cx into xp
  37.   put cx into xn
  38.   put cx into Lastx
  39.   while xp <= RE {
  40. if xp - Lastx > 40 {
  41. moveto xp, cy - 3
  42. drawto xp, cy + 3
  43. moveto xp - 3, cy + 15
  44. drawtext k
  45. moveto xn, cy - 3
  46. drawto xn, cy + 3
  47. moveto xn - 12, cy + 15
  48. drawtext k * -1
  49. put xp into Lastx
  50. add zm to n
  51. add 1 to k
  52. put cx - n * zm into xn
  53. put cx + n * zm into xp
  54. // Add vertical marks
  55.   put 0 into n
  56.   put 0 into k
  57.   put cy into yp
  58.   put cy into yn
  59.   put cy into Lasty
  60.   while yp <= BE {
  61. if yp - Lasty > 40 {
  62. if k > 99 put 30 into offset
  63. else if k > 9 put 20 into offset
  64. else put 10 into offset
  65. moveto cx - 3, yp
  66. drawto cx + 3, yp
  67. moveto cx - offset - 10, yp + 3
  68. drawtext k * -1
  69. moveto cx - 3, yn
  70. drawto cx + 3, yn
  71. moveto cx - offset, yn + 3
  72. drawtext k
  73. put yp into Lasty
  74. add zm to n
  75. add 1 to k
  76. put cy - n * zm into yn
  77. put cy + n * zm into yp
  78.   set the apen to tempcolor
  79.   put empty into textfield "Readout"
  80. clearplot
  81. clearplot
  82. CLEARING
  83. Readout
  84. theArea
  85. Zoom:
  86. Readout
  87. New...
  88. Open...
  89. Make Copy...
  90. Streamline...
  91. Preferences...
  92.     Workbench
  93. Help...
  94. About...
  95. Quit...
  96. Paste
  97. Clear
  98. Select All
  99. Cut Page
  100.     Copy Page
  101. Colors
  102. Load...
  103. Save...
  104. Restore Colors
  105. Default Colors
  106. Brush Colors
  107. Image Colors
  108. Last Color Font
  109. Cycle
  110. Grid...
  111. Stop Sound
  112. Show All
  113. Unlock All
  114.     Edit Form
  115. Share
  116.     Next Page
  117. Previous Page
  118. First Page
  119.     Last Page
  120. Backward
  121. Forward
  122.     Last Book
  123.     Browse...
  124. Autobrowse...
  125.     Bookshelf
  126. New Page
  127. Delete Page
  128. New Form
  129. Load Form...
  130. Save Form...
  131. Image
  132. Load...
  133. Save...
  134. Capture...
  135.     Clipboard
  136. Paste
  137. Spare
  138. Swap Frames
  139. Copy to Spare
  140. Merge in Front
  141. Merge in Back
  142. Delete Spare
  143. Frame
  144. Previous
  145. Delete
  146. Copy to All
  147. Color
  148. Remap
  149. Transparency
  150. Paper <-> Pen
  151. Paper ->  Pen
  152. Count
  153. Vertical
  154. Horizontal
  155. Info...
  156. Brush
  157. Load...
  158. Save...
  159. Restore
  160.     Clipboard
  161. Paste
  162. Color
  163. Remap
  164. Transparency
  165. Paper <-> Pen
  166. Paper ->  Pen
  167. Center
  168. Corner
  169.     Any Point
  170. Any Size
  171. Halve
  172. Double
  173. Halve Width
  174. Halve Height
  175. Double Width
  176. Double Height
  177. To PAL
  178. To NTSC
  179. Vertical
  180. Horizontal
  181. Shear
  182. Vertical
  183. Horizontal
  184. Rotate
  185.     Any Angle
  186. Paint
  187. Matte
  188. Color
  189. Replace
  190. Smear
  191. Dissolve
  192. Spare
  193. Cycle
  194. Cycle 2
  195. Gradient
  196. Gradient 2
  197. Smudge
  198. Chaos
  199. Count
  200. Custom
  201. Dither
  202. Edges
  203. Object
  204. Load...
  205. Save...
  206. Bring to Front
  207. Send to Back
  208. Bring Closer
  209. Send Farther
  210. Group
  211. Ungroup
  212. Duplicate...
  213. Align...
  214. Info...
  215. Actions...
  216.     Script...
  217. Load...
  218. Save...
  219. Plain
  220.     Underline
  221. Italic
  222. Shadow
  223. Font...
  224. Spacing...
  225.     Hypertext
  226. Actions...
  227.     Script...
  228. Tools
  229. Coordinates
  230.     Title Bar
  231. Palette
  232. Colors
  233. Patterns
  234. Paint Tools
  235. Paint Types
  236.     Histogram
  237.     Magnifier
  238. Messages
  239. Draw Tools
  240. Layers
  241. Pages
  242. Author
  243. Book...
  244. Form...
  245. Page...
  246. Display...
  247. Narrator...
  248. Hypertext...
  249. Resources...
  250.     Effect...
  251. Effect Area
  252. topaz.fontGLOB
  253. fonts:Book23
  254. ram:TestBook
  255. df1:PlotBook
  256. 0.050
  257. x * x
  258. (x * x) / 20
  259.     3 * sin x
  260.     x * cos x
  261. tan x
  262. abs(3 * sin x)
  263. PlotBook by Eagle Tree Software
  264. (11 December 93)
  265. 7This is a unique book because it compiles a script each
  266. 8time it plots an equation. For the best performance, the
  267. 5equation is concatenated into a long string to make a
  268. 7ploting function. The script is compiled when the 
  269. command changes the form script. Here is a simple event
  270. 6function that also creates and calls another function:
  271.   on SelectUp begin
  272. *    put textfield "Equation" into equation
  273. "    set the script of this page to
  274.     "EvalEquation begin\n" &
  275. &    " put " & equation & " into c\n" &
  276.     " answer c\n" &
  277.         "end"
  278.     EvalEquation()
  279.   end
  280. 7When dynamically creating and calling a function script
  281. 6in this way, remember to put the new script in a place
  282. 8within the current script's event hierarchy. Even though
  283. 4you can change a page script from a form object, you
  284. 8will not be able to call the new script because the page
  285. 8is not in the event hierarchy of a form object. For form
  286. 8objects, you will want to change either the form or book
  287. (script. For page objects, you can change
  288. the page, form, or book script.
  289.     x * cos x
  290. theArea
  291. Start:
  292. theColor
  293. Step:
  294. Zoom:
  295. Elist
  296. @I Information
  297. @C Clear
  298. @B Bookshelf
  299. ~ Plot
  300. @D Default
  301. Lists
  302. @Q Quit
  303. Equation
  304. Presets
  305. Readout
  306. on SelectDown
  307. begin
  308.   popup "1\n2\n3\n4\n5\n10\n15\n20"
  309.   if it is not empty begin
  310. put it into textfield "Zoom:"
  311. set the pointer to 6
  312. clearplot()
  313. set the pointer to 0
  314.   end
  315. Zoom:
  316. clearplot
  317. on SelectDown
  318. begin
  319.   popup "-150\n-100\n-75\n-50\n-25\n-15\n-10\n-5\n 0"
  320.   if it is not empty then put it into textfield "Start:"
  321. Start:
  322. on SelectDown
  323. begin
  324.   popup "1.25\n1.00\n0.75\n0.50\n0.25\n0.10\n0.075\n0.050\n0.025\n0.010"
  325.   if it is not empty then put it into textfield "Step:"
  326. 0.075
  327. 0.050
  328. 0.025
  329. 0.010
  330. Step:
  331. yon SelectDown
  332. begin
  333.   popup "150\n100\n75\n50\n25\n15\n10\n5"
  334.   if it is not empty then put it into textfield "End:"
  335. on SelectUp
  336. begin
  337.   set the pointer to 6
  338.   play notes "c6x"
  339.   lock display
  340.   set the visibility of layer "Info" to TRUE
  341.   set the lock of layer "F1" to TRUE
  342.   unlock display with wipe down
  343.   set the pointer to 0
  344. Ron SelectUp
  345. begin
  346.   set the pointer to 6
  347.   clearplot()
  348.   set the pointer to 0
  349. clearplot
  350. 3on SelectUp
  351. begin
  352.   go to the book "Bookshelf"
  353. Bookshelf
  354. on SelectUp {
  355.   global cx, cy, TE, BE, LE, RE
  356.   set the pointer to 6
  357.   set the apen to selector "theColor"
  358.   put textfield "Equation" into espn
  359.   put the number of characters of espn into NUespn
  360.   put textfield "Zoom:" into zoom
  361.   put (textfield "Start:") * zoom into begun
  362.   put (textfield "End:") * zoom into ended
  363.   put (textfield "Step:") * zoom into theStep
  364.   put 0.0 + begun into z
  365.   while cx + z * zoom < LE
  366. add theStep to z
  367.   if ended <= begun {
  368. answer "Bad number"
  369. break
  370.   put "\nCOMPILING\nFUNCTION" into the textfield "Readout"
  371. //----------------------------------------------------------
  372. set the script of this form to
  373. "plotit x, ended, theStep, zoom {\n" &
  374. "  global cx, cy, TE, BE, LE, RE\n" &
  375. "  put FALSE into fflag\n" &
  376. "  while x <= ended { \n" &
  377. "    put (" & espn & ") into yoff\n" &
  378. "    put cx + x * zoom into theX\n" &
  379. "    put cy + (yoff * -1) * zoom into theY\n" &
  380. "    if theX > RE then break\n" &
  381. "    if theY < TE then put TE into theY\n" &
  382. "    if theY > BE then put BE into theY\n" &
  383. "    if fflag is FALSE { \n" &
  384. "      moveto theX, theY\n" &
  385. "      put theY into LastY\n" &
  386. "      put TRUE into fflag\n" &
  387. "    }\n" &
  388. "    else {\n" &
  389. "      if theY = LastY and (theY = TE or theY = BE) then moveto theX, theY\n" &
  390. "      else drawto theX, theY\n" &
  391. "      put theY into LastY\n" &
  392. "    }\n" &
  393. "    add theStep to x\n" &
  394. "  }\n" &
  395. //----------------------------------------------------------
  396.   put empty into textfield "Readout"  // Gives it a nice blink
  397.   put "\nEXECUTING\nFUNCTION" into textfield "Readout"
  398.   plotit(z, ended, theStep, zoom)
  399.   play notes "c7x c#"
  400.   put empty into textfield "Readout"
  401.   set the pointer to 0
  402. theColor
  403. Equation
  404. Zoom:
  405. Start:
  406. Step:
  407. Bad number
  408. COMPILING
  409. FUNCTION
  410. Readout
  411. plotit x, ended, theStep, zoom {
  412.   global cx, cy, TE, BE, LE, RE
  413.   put FALSE into fflag
  414.   while x <= ended { 
  415.     put (
  416. ) into yoff
  417.     put cx + x * zoom into theX
  418.     put cy + (yoff * -1) * zoom into theY
  419.     if theX > RE then break
  420.     if theY < TE then put TE into theY
  421.     if theY > BE then put BE into theY
  422.     if fflag is FALSE { 
  423.       moveto theX, theY
  424.       put theY into LastY
  425.       put TRUE into fflag
  426.     }
  427.     else {
  428.       if theY = LastY and (theY = TE or theY = BE) then moveto theX, theY
  429.       else drawto theX, theY
  430.       put theY into LastY
  431.     }
  432.     add theStep to x
  433. Readout
  434. EXECUTING
  435. FUNCTION
  436. Readout
  437. plotit
  438. c7x c#
  439. Readout
  440. on SelectUp
  441. begin
  442.   put -5 into textfield "Start:"
  443.   put 5 into textfield "End:"
  444.   put "0.05" into textfield "Step:"
  445.   get textfield "Zoom:"
  446.   if it is not 10 then begin
  447. put 10 into textfield "Zoom:"
  448. clearplot()
  449.   end
  450.   put 6 into selector "theColor"
  451. Start:
  452. Step:
  453. Zoom:
  454. Zoom:
  455. clearplot
  456. theColor
  457. on SelectUp
  458. begin
  459. on SelectDown
  460. begin
  461.   put the bottomedge of me into be
  462.   put the leftedge of me into le
  463.   popup textfield "Elist" topedge be leftedge le
  464.   if it is not empty then put it into textfield "Equation"
  465. Elist
  466. Equation
  467. on SelectUp
  468. begin
  469.   set the pointer to 6
  470.   play notes "c6x"
  471.   lock display
  472.   set the visibility of layer "Info" to false
  473.   set the lock of layer "F1" to false
  474.   clearplot()
  475.   unlock display with wipe down
  476.   set the pointer to 0
  477. clearplot
  478. Yplotit x, ended, theStep, zoom {
  479.   global cx, cy, TE, BE, LE, RE
  480.   put FALSE into fflag
  481.   while x <= ended { 
  482.     put (x * cos x) into yoff
  483.     put cx + x * zoom into theX
  484.     put cy + (yoff * -1) * zoom into theY
  485.     if theX > RE then break
  486.     if theY < TE then put TE into theY
  487.     if theY > BE then put BE into theY
  488.     if fflag is FALSE { 
  489.       moveto theX, theY
  490.       put theY into LastY
  491.       put TRUE into fflag
  492.     }
  493.     else {
  494.       if theY = LastY and (theY = TE or theY = BE) then moveto theX, theY
  495.       else drawto theX, theY
  496.       put theY into LastY
  497.     }
  498.     add theStep to x
  499. plotit
  500. ffUPAGE
  501. 2sumit z, b, c, d
  502. begin
  503.   answer z + b + c + d
  504. sumit
  505.