-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path104.bas
More file actions
132 lines (106 loc) · 2.1 KB
/
Copy path104.bas
File metadata and controls
132 lines (106 loc) · 2.1 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
''' 17.06.2004
'' Save Screen Procedures v2.0 with simple Compression Algorithm
'' a very primitive but maybe usefull way to save screen areas to file
'' (C) 2004 by Carsten (contact: SMALLBasic Forum)
''Draw Testpicture
testpicture
?"Saving Screen Area"
rect 299,199,451,351
SaveScreenC "..\\testpicture.sbb",300,200,450,350
cls
?"Loading Screen Area"
LoadScreenC "..\\testpicture.sbb"
end
''***********************************************
''example picture
''Draw HEXAGON
'' hexagon.bas
'' 28/05/2000
sub testpicture
cls
sf=.95
x=(ymax/2)-10:y=0:cx=xmax/2:cy=ymax/2
c=cos(pi/3):s=sin(pi/3)
c1=cos(pi/36):s1=sin(pi/36)
cls
for j=1 to 30
sx=x+cx:sy=cy-y
pset sx,sy
for i=0 to 6
sx=x+cx:sy=cy-y
line sx,sy color i*6
xn=x*c-y*s
y=x*s+y*c
x=xn
next
xn=sf*(x*c1-y*s1)
y=sf*(x*s1+y*c1)
x=xn
next
end
''********************************************
'' Here are the Save and Load Routines
'' you can use in your programms
''********************************************
''********************************************
'' Save Compressed Screen
'' Needs: Filename, x, y, x1, y1
'' coordinates as in RECT
''********************************************
sub SaveScreenC (Filename,fromx,fromy,tox,toy)
local x,y,dx,dy,colcount,oldcol,h
if fromx>tox
swap fromx,tox
fi
if fromy>toy
swap fromy,toy
fi
dx=tox-fromx
dy=toy-fromy
open Filename for output as #1
print #1,"SBSCREENCOMP"
print #1,dx
print #1,dy
for y=fromy to toy
colcount=1
oldcol=point(fromx,fromy)
for x=fromx+1 to tox
h=point(x,y)
if (h=oldcol and x<tox)
colcount++
else
?#1,colcount
?#1,oldcol
colcount=1:oldcol=h
fi
next x
next y
close #1
'' this is done for windows ...
chmod Filename, 0o666
end
''********************************************
''Load Compressed Screen
''Needs: Filename
''********************************************
sub LoadScreenC(Filename)
local x,y,c,cc
open Filename for input as #1
input #1,name
''is it a sbscreen compressed file?
if name="SBSCREENCOMP"
input #1,xr
input #1,yr
for y=0 to yr
x=0
repeat
input #1,cc
input #1,c
line x,y,x+cc,y,c
x=x+cc
until (x>=xr or eof(1))
next y
fi
close #1
end
'