Hi,
I’m currently converting an old QBasic listing to Xojo. It is about generating a Fractal set. The Xojo code produces some vague pixel formations which is definitely wrong. In the original code the following statements are used:
‘Screen 12’ switches to VGA (640*480). The ‘window’ statement defines a new set of coordinates I need to convert somewhere but unclear for me how? This is the Xojo code:
Var somePicture As New Picture(Canvas1.Width,Canvas1.Height)
Var surf As RGBSurface = somePicture.RGBSurface
Var A As Double = 0.65
Var B As Double = 0.65
Var C As Double = 0.1
Var D As Double = -0.1
Var F1 As Double = Sqrt(A*A+B*B)
Var F2 As Double = Sqrt(C*C+D*D)
Var Q As Double = F1/(F1+F2)
Var X1 As Double
Var Y1 As Double
Var X As Integer = 1
Var Y As Integer = 0
Var K As Integer = 0
Var R As Double
For K = 0 To 20000
R = Rnd()
If R < Q Then
X1 = A*X-B*Y-1+A
Y1 = B*X+A*Y+B
Else
X1 = C*X-D*Y+1-C
Y1 = D*X+C*Y-D
End If
X=X1
Y=Y1
Surf.Pixel(X,Y) = &c0080FF00
Next
g.DrawPicture(somePicture, 0, 0)
The Window command in QBASIC maps the viewport coordinates; in your case the upper-left becomes -3.5,-2.1, and the lower-right is 2.1,2.1. Your RGBsurface is 0,0 (upper-left) to Canvas1.width, canvas1.height. To transform, map from the QBASIC coordinates to the RGBSurface coordinates:
X = Canvas1.width * (X1+3.5) / 5.6 Y = Canvas1.height * (Y1+2.1) / 4.2