home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 May / PCW596.iso / polskie / eduk / genfast / genfast.lzh / DEMO_10.PAK / FUNKCJE.DA_ < prev    next >
Text File  |  1996-03-16  |  7KB  |  308 lines

  1. ; Program przykÆadowy z matematyki. Wykresy funkcji.
  2. ; Na tablicy rysowane så funkcje, które wybiera siæ klawiszami
  3. ; z prawej strony tablicy, w kolorze wybranym w pasku przewijania
  4. ; znajdujåcym siæ pod spodem tablicy.
  5. ; Bajerki: gåbka (wyciera z tablicy wykres(y) narysowane w danym
  6. ; kolorze (klawisze funkcji nie så wtedy aktywne), kreda, którå
  7. ; trzeba wybraì po skoñczeniu wycierania gåbkå oraz biaÆa ₧cierka,
  8. ; wiszåca z lewej strony u doÆu tablicy, którå w dowolnym momencie
  9. ; moºna wytrzeì caÆå tablicæ ze wszystkich wykresów. 
  10. ; Wyj₧cie z programu zapewnia procedura @defkeyboardhandler, która
  11. ; w stronie [50] uruchamia wyj₧cie z programu klawiszem [Esc].
  12.   
  13. [procedure TABLICA]
  14. ; tablica jest czarna, ma niebieskie 'pas-par-tout', a ukÆad wspóÆrzædnych
  15. ; jest narysowany w kolorze szarym
  16. @downarea(100,100,500,400,0)
  17. ; maÆa kreda
  18. @uparea(380,412,395,415,15)
  19. ; gåbka
  20. @uparea(410,395,445,415,6)
  21. @SetColors(7,7)
  22. ; o₧ X
  23. @line(110,250,490,250)
  24. ; strzaÆka na osi X
  25. @line(480,245,490,250)
  26. @line(480,255,490,250)
  27. ; o₧ Y
  28. @line(300,110,300,390)
  29. ; strzaÆka na osi Y
  30. @line(295,120,300,110)
  31. @line(305,120,300,110)
  32. @SetPosition(303,253)
  33. @fastwrite('0,0')
  34. @line(350,250,350,255)
  35. @SetPosition(353,253)
  36. @fastwrite('1,0')
  37. @line(400,250,400,255)
  38. @SetPosition(403,253)
  39. @fastwrite('2,0')
  40. @line(450,250,450,255)
  41. @SetPosition(453,253)
  42. @fastwrite('3,0')
  43. @line(300,200,305,200)
  44. @SetPosition(303,203)
  45. @fastwrite('0,1')
  46. @line(300,150,305,150)
  47. @SetPosition(303,153)
  48. @fastwrite('0,2')
  49. ; linie dodatkowe ujemne na X
  50. @line(150,250,150,255)
  51. @line(200,250,200,255)
  52. @line(250,250,250,255)
  53. ; linie dodatkowe ujemne na Y
  54. @line(300,300,305,300)
  55. @line(300,350,305,350)
  56. @return
  57.  
  58. [procedure FUNKCJA]
  59. @d:=%a-200
  60. @e:=-200
  61. @i:=0;
  62. @repeat:400
  63. ; wszelkie wspóÆczynniki så wynikiem 'kontekstu ekranu'
  64. @if (%g = 11) then begin
  65. @f:=-%e*%e/50
  66. @end
  67. @if (%g = 12) then begin
  68. @if (%e < 0) then goto:2
  69. @f:=-ln(%e*10)*5
  70. @end
  71. @if (%g = 13) then begin
  72. @if (%e < 0) then goto:2
  73. @f:=-exp(%e/20)
  74. @end
  75. @if (%g = 14) then begin
  76. @f:=-log(%e)*30
  77. @end
  78. @if (%g = 15) then begin
  79. @f:=-%e*%e*%e/2000
  80. @end
  81. @if (%g = 16) then begin
  82. @f:=-%e*sin(%e/20)
  83. @end
  84. @if (%g = 17) then begin
  85. @f:=-%e*cos(%e/20)
  86. @end
  87. @if (%g = 18) then begin
  88. @f:=-(%e^2/100)*cos(%e/20)
  89. @end
  90. @if (%g = 19) then begin
  91. @f:=-arctan(%e)*20
  92. @end
  93. @if (%g = 20) then begin
  94. @f:=-arctan(%e)*20+sin(%e)*2
  95. @end
  96. @if (%g = 21) then begin
  97. @f:=-%e*cos(%e/20)*sin(%e/20)
  98. @end
  99. @if (%g = 22) then begin
  100. @if (%e < 0) then goto:2
  101. @f:=-sqrt(%e)*6
  102. @end
  103. @if (%d < 100) then goto:2
  104. @if (%d > 500) then goto:2
  105. @if (%f+%b > 400) then goto:2
  106. @if (%f+%b < 100) then goto:2
  107. @if (%i=0) then begin
  108. @putpixel(%d,%f+%b,%l);
  109. @else
  110. @SetColors(%l,%l);
  111. @line(%i,%j,%d,%f+%b);
  112. @end;
  113. @i:=%d;
  114. @j:=%f+%b;
  115. [2]
  116. @e:=%e+1
  117. @d:=%d+1
  118. @next
  119. @return
  120.  
  121.  
  122. [1]
  123. @a:=300
  124. @b:=250;
  125. @l:=14
  126. @defkeyboardhandler(50)
  127. @disablestatusbar;
  128. @SetColors(8,7)
  129. @bar(270,65,330,86)
  130. @uparea(250,80,350,86,0)
  131. @line(85,479,135,400)
  132. @line(135,400,155,400)
  133. @line(155,400,105,479)
  134. @line(85,479,105,479)
  135. @fillarea(90,477,8)
  136. @line(515,479,465,400)
  137. @line(465,400,445,400)
  138. @line(445,400,495,479)
  139. @line(495,479,515,479)
  140. @fillarea(497,477,8)
  141. @uparea(75,415,525,420,0)
  142. @uparea(85,85,515,415,1)
  143. @call:tablica
  144. ; kreda
  145. @SetColors(0,7)
  146. @rectangle(200,440,400,470)
  147. @SetColors(7,7)
  148. @bar(210,435,310,443)
  149. @SetPosition(217,433)
  150. @SetColors(0,7)
  151. @fastwrite('Kolor kredy')
  152. @SetColors(0,7)
  153. @drawbutton(210,445,240,465,8,23,'<','')
  154. @drawbutton(360,445,390,465,8,24,'>','')
  155. @SetColors(%l,7)
  156. @bar(241,445,359,465)
  157. ; ₧cierka do tablicy
  158. @SetColors(15,7)
  159. @SetPosition(70,416)
  160. @Picture('biala.cgv')
  161. @SetColors(0,7)
  162. @Picture('sciera.cgv')
  163. ; NAPIS "WYKRESY FUNKCJI" - jako zbiór .cgv
  164. @SetColors(15,7)
  165. @SetPosition(120,15)
  166. @Picture('napis.cgv')
  167. @SetColors(0,7)
  168. @SetPosition(122,17)
  169. @Picture('napis.cgv')
  170. ; klawisze zmiany ₧rodka ukÆadu wspóÆrzædnych
  171. @SetColors(8,7)
  172. @bar(5,100,40,400)
  173. @bar(45,100,80,400)
  174. @SetColors(7,7)
  175. @drawbutton(7,102,38,150,7,30,'X+','')
  176. @drawbutton(7,350,38,398,7,31,'X-','')
  177. @drawbutton(47,102,78,150,7,32,'Y+','')
  178. @drawbutton(47,350,78,398,7,33,'Y-','')
  179. @setcolors(15,7)
  180. @writevalue(7,151,38,349,0,0,(%a-300)/50)
  181. @writevalue(47,151,78,349,0,0,(%b-250)/50)
  182. ; klawisze poszczególnych funkcji
  183. @SetColors(7,7)
  184. @setinvisiblebutton(70,420,100,470,28)
  185. @drawbutton(530,90,630,110,7,11,'y=x^2','')
  186. @drawbutton(530,115,630,135,7,12,'y=ln(x)','')
  187. @drawbutton(530,140,630,160,7,13,'y=e^x','')
  188. @drawbutton(530,165,630,185,7,14,'y=log(x)','')
  189. @drawbutton(530,190,630,210,7,15,'y=x^3','')
  190. @drawbutton(530,215,630,235,7,16,'y=x*sin(x)','')
  191. @drawbutton(530,240,630,260,7,17,'y=x*cos(x)','')
  192. @drawbutton(530,265,630,285,7,18,'y=x^2*cos(x)','')
  193. @drawbutton(530,290,630,310,7,19,'y=arctan(x)','')
  194. @drawbutton(530,315,630,335,7,20,'y=arctan*sin','')
  195. @drawbutton(530,340,630,360,7,21,'y=xsinxcosx','')
  196. @drawbutton(530,365,630,385,7,22,'y=sqrt(x)','')
  197. @setinvisiblebutton(380,412,395,415,27)
  198. @setinvisiblebutton(410,395,445,415,25)
  199. @showscreen
  200. @checkevents
  201.  
  202. [11..22]
  203. @getcurrentpage(%k)
  204. @g:=%k
  205. @i:=100;
  206. @call:funkcja
  207. @checkevents
  208. [23]
  209. @l:=%l-1
  210. @if (%l = 7) then begin
  211. @l:=%l-1
  212. @end
  213. @if (%l < 1) then begin
  214. @l:=1
  215. @end
  216. @SetColors(%l,7)
  217. @bar(241,445,359,465)
  218. @checkevents
  219. [24]
  220. @l:=%l+1
  221. @if (%l = 7) then begin
  222. @l:=%l+1
  223. @end
  224. @if (%l > 15) then begin
  225. @l:=15
  226. @end
  227. @SetColors(%l,7)
  228. @bar(241,445,359,465)
  229. @checkevents
  230. [25]
  231. ; wycieranie gåbkå wykresu w wybranym kolorze
  232. @sound(300,100)
  233. @deletebutton;
  234. @setinvisiblebutton(515,0,639,479,60)
  235. @setinvisiblebutton(0,0,1,1,60)
  236. [26]
  237. @deletebutton;
  238. @setinvisiblebutton(100,100,500,400,51)
  239. @checkevents
  240. [51]
  241. @I:=%X
  242. @J:=%Y
  243. @SetColors(%L,0);
  244. @reversearea(%I-5,%J-5,%I+5,%J+5);
  245. @GoTo:26
  246. [27]
  247. ; wytarÆe₧ - teraz weª kredæ!
  248. @sound(200,200)
  249. @deletebutton;
  250. @deletebutton;
  251. @deletebutton;
  252. @setinvisiblebutton(380,412,395,415,27)
  253. @setinvisiblebutton(410,395,445,415,25)
  254. @checkevents
  255. [28]
  256. @call:tablica
  257. @checkevents;
  258.  
  259. [30]
  260. @a:=%a+50
  261. @if (%a > 450) then begin
  262. @a:=450
  263. @end
  264. @SetColors(8,0)
  265. @bar(7,151,38,349)
  266. @setcolors(15,7)
  267. @writevalue(7,151,38,349,0,0,(%a-300)/50)
  268. @checkevents;
  269. [31]
  270. @a:=%a-50
  271. @if (%a < 150) then begin
  272. @a:=150
  273. @end
  274. @SetColors(8,0)
  275. @bar(7,151,38,349)
  276. @setcolors(15,7)
  277. @writevalue(7,151,38,349,0,0,(%a-300)/50)
  278. @checkevents;
  279. [32]
  280. @b:=%b-50
  281. @if (%b < 150) then begin
  282. @b:=150
  283. @end
  284. @SetColors(8,0)
  285. @bar(47,151,78,349)
  286. @setcolors(15,7)
  287. @writevalue(47,151,78,349,0,0,-(%b-250)/50)
  288. @checkevents;
  289. [33]
  290. @b:=%b+50
  291. @if (%b > 350) then begin
  292. @b:=350
  293. @end
  294. @SetColors(8,0)
  295. @bar(47,151,78,349)
  296. @setcolors(15,7)
  297. @writevalue(47,151,78,349,0,0,-(%b-250)/50)
  298. @checkevents;
  299.  
  300. [50]
  301. ; je₧li [Esc] to koniec!
  302. @if (%z = $011B) then goto:0
  303. @checkevents;
  304.  
  305. [60]
  306. ; nic nie rób tylko informuj !
  307. @sound(440,50)
  308. @checkevents