Base 128 is OK (Experimenting a few years ago).
But it is very sensitive to the browser, If I remember correctly firefox added one character at the end which completely ruined the transfer.
Also if I remember correctly one character had to be changed.
viewtopic.php?f=7&t=25744&p=233594&hili ... 2A#p233594
This was experimenting with different bases using gmp to change the whole file to a different base mathematically.(a bit slower of course)
I remember you were also involved later on with base 91 conversions.
Anyway I have fixed my image pointer cycler.
Drawing a moving waveform:
1) The pointer methods all discussed here.
2) Moving an image along the screen and flipping back to the start (circular trig functions)
3) Rotating the waveform in front of the user's eyes, like a huge roundabout.
Some old code for method 3
Code: Select all
Type V3
As Single x,y,z
As Ulong col
End Type
Type Angle 'to optimize rotating many points
As Single sx,sy,sz
As Single cx,cy,cz
Declare Static Function construct(As Single,As Single,As Single) As Angle
End Type
'all the sines and cosines are pre calculated and sent to rotate
Function Angle.construct(x As Single,y As Single,z As Single) As Angle
Return Type (Sin(x),Sin(y),Sin(z), _
Cos(x),Cos(y),Cos(z))
'sx=sin(x), sy=sin(y) ... e.t.c.
End Function
Function Rotate(c As V3,p As V3,a As Angle,scale As V3=Type(1,1,1)) As V3
'note; no trig done, all trig is in parameter angle
Dim As Single dx=p.x-c.x,dy=p.y-c.y,dz=p.z-c.z
Return Type<V3>((scale.x)*((a.cy*a.cz)*dx+(-a.cx*a.sz+a.sx*a.sy*a.cz)*dy+(a.sx*a.sz+a.cx*a.sy*a.cz)*dz)+c.x,_
(scale.y)*((a.cy*a.sz)*dx+(a.cx*a.cz+a.sx*a.sy*a.sz)*dy+(-a.sx*a.cz+a.cx*a.sy*a.sz)*dz)+c.y,_
(scale.z)*((-a.sy)*dx+(a.sx*a.cy)*dy+(a.cx*a.cy)*dz)+c.z,p.col)
End Function
Function perspective(p As V3,eyepoint As V3) As V3
Dim As Single w=1+(p.z/eyepoint.z)
Return Type<V3>((p.x-eyepoint.x)/w+eyepoint.x,_
(p.y-eyepoint.y)/w+eyepoint.y,_
(p.z-eyepoint.z)/w+eyepoint.z,p.col)
End Function
Function ShortSpline(p() As V3,t As Single) As V3
#macro set(n)
0.5 *( (2 * P(2).n) +_
(-1*P(1).n + P(3).n) * t +_
(2*P(1).n - 5*P(2).n + 4*P(3).n - P(4).n) * t*t +_
(-1*P(1).n + 3*P(2).n- 3*P(3).n + P(4).n) * t*t*t)
#endmacro
Dim As V3 G
G.x=set(x):G.y=set(y):G.z=set(z)
Return G
End Function
Sub GetSpline(v() As V3,outarray() As V3,arraysize As Integer=1000)
Dim As V3 p(1 To 4)
Redim outarray(0)
Dim As Single stepsize=(Ubound(v)-1)/(arraysize)
If stepsize>1 Then stepsize=1
For n As Integer=Lbound(v)+1 To Ubound(v)-2
p(1)=v(n-1):p(2)=v(n):p(3)=v(n+1):p(4)=v(n+2)
For t As Single=0 To 1 Step stepsize
Redim Preserve outarray(1 To Ubound(outarray)+1)
outarray(Ubound(outarray))=ShortSpline(p(),t)
Next t
Next n
End Sub
Sub createpoints(a() As v3) 'set up points in a ring
Var numpts=200
Redim a(1 To 2*numpts)
Const pi=4*Atn(1)
Dim As Long r,count,zval
r=200
For z As Single=0 To 2*pi Step 2*pi/numpts
count+=1
a(count).x=400+r*Cos(z)
a(count).y=300-r*Sin(z)
a(count).z=(Rnd*5-Rnd*5)*2
a(count).col=Rgb(255,255,0)
Pset(a(count).x,a(count).y),a(count).col
Next
Redim Preserve a(1 To count+3)
a(count+3)=a(3)
a(count+2)=a(2)
a(count+1)=a(1)
Return
End Sub
Function Regulate(Byval MyFps As Long,Byref fps As Long) As Long
Static As Double timervalue,_lastsleeptime,t3,frames
frames+=1
If (Timer-t3)>=1 Then t3=Timer:fps=frames:frames=0
Var sleeptime=_lastsleeptime+((1/myfps)-Timer+timervalue)*1000
If sleeptime<1 Then sleeptime=1
_lastsleeptime=sleeptime
timervalue=Timer
Return sleeptime
End Function
'============================ ==========================
Screen 19,32,,64
Redim As v3 a(0)
createpoints a()
Locate 1
Print "Initial array points"
Sleep 1000
Line(0,0)-(800,600),Rgba(0,0,0,190),bf 'fade out the initial points
Dim As Double pi=4*Atn(1)
Dim As v3 screencentre = Type(400,300,0)
'PART 1 (x y z)
Dim As Angle A3d=Angle.construct(0,pi/2,0)
For n As Long=Lbound(a) To Ubound(a)
a(n)=rotate(screencentre,a(n),A3D) 'rotate all points by pi/2 around the y axis
Pset(a(n).x,a(n).y),a(n).col 'draw the points
Next
Locate 1
Print "Points are all rotated by 90 degrees around the vertical (y) axis"
Sleep 1000
Redim As V3 rot()'to hold all rotated points(a working array)
Dim As String key
Dim As Long fps
Dim As V3 ang
Dim As v3 eyepoint =Type(400,300,4000) 'for perspective
Redim As v3 catmul()
GetSpline(a(),catmul(),10000)
Redim rot(Lbound(catmul) To Ubound(catmul))
'PART 2
ang.z=pi/2 'offset .z by 90 degrees
ang.y=-pi/100 'start off with a tilt, optional
dim as long t=1
Do
key=Inkey
If key=Chr(255)+"K" Then ang.z-=.005 'left
If key=Chr(255)+"M" Then ang.z+=.005 'right
If key=Chr(255)+"P" Then ang.y-=.005 'down
If key=Chr(255)+"H" Then ang.y+=.005 'up
If key=Chr(32) Then ang.z=pi/2:ang.y=-pi/100 'space
ang.x+=.001 'the rotating speed
If ang.x>=2*pi Then ang.x=0
'use ang and construct parameter 3 for rotate()
A3D=Angle.construct(ang.x,ang.y,ang.z)' ... get the six rotate components (sines, coses .. for rotate())
Screenlock
Cls
Print "fudged axis (x and y apparently interchanged, z has a 90 degree offset)"
Print "X angle ";Int(ang.x*180/pi);Tab(20);" degrees"
Print "Y angle ";Int(ang.y*180/pi);Tab(20);" degrees"
Print "z angle ";Int(ang.z*180/pi);Tab(20);" degrees"
Draw String(50,130),"Framerate "&fps
Draw String(50,150),"Use the arrow and space keys "
Draw String(50,170),"Toggle F10 key "
if multikey(&h44) then t=-t:sleep 100
Var s=10
For n As Long=Lbound(catmul) To Ubound(catmul)
rot(n)=rotate(screencentre,catmul(n),A3D,Type(s,s,s))'scale up by 10 for nicer size
rot(n)=perspective(rot(n),eyepoint)
Next
For n As Long=Lbound(rot) To Ubound(rot)-1
var condition=iif(t=1,rot(n).z<0,rot(n).z)
if condition then line(rot(n).x,rot(n).y)-(rot(n+1).x,rot(n+1).y),rgb(255,255,255)
Next
Screenunlock
Sleep regulate(64,fps),1
Loop Until key=Chr(27)