aboutsummaryrefslogtreecommitdiffstats
path: root/initrd/init
blob: a2508224c1b9451a64983e480b914a03358e842a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# graph area
set plotx 50
set ploty 50
set plotw 380
set ploth 220
set cx (plotx + (plotw / 2))
set cy (ploty + (ploth / 2))

# graph range
set xmin (0 - 10)
set xmax 10
set ymin (0 - 10)
set ymax 10

set xinc (plotw / (xmax - xmin))
set yinc (ploth / (ymax - ymin))

color 3 3 3 > mlines

# print axis

func makegrid
	rect plotx ploty plotw ploth 0

	set x plotx
	do
		line x ploty x (ploty + ploth) mlines
		set x (x + xinc)
	while (x <= plotx + plotw)

	set y ploty
	do
		line plotx y (plotx + plotw) y mlines
		set y (y + yinc)
	while (y <= ploty + ploth)

	line cx ploty cx (ploty + ploth) 32767
	line plotx cy (plotx + plotw) cy 32767
end

#
# BIG LOOP - ask for equ, graph it
#

makegrid
set clearcmd "clear"
do
	rect 0 0 480 40

	print "f(x) = "
	gets > Fx

	if (Fx == clearcmd)
		makegrid
	else
		# do function
		set x xmin
		do
			solve Fx > y
			set y (0 - y)
			if ((y > ymin) & (y < ymax))
				pixel (cx + x * xinc) (cy + y * yinc) 511
			end
			set x (x + 1 / xinc)
		while (x < xmax)
	end

	ppos 0 0
while (1)