matherp Guru
 Joined: 11/12/2012 Location: United KingdomPosts: 10868 |
| Posted: 08:38am 03 Aug 2025 |
|
|
|
Looks even better in 1280x720 mode 3 (640x360)

MODE 3 ' 640x360 Const SCREEN_HEIGHT = 360 Const Q = 3 Dim XP(Q), YP(Q), ZP(Q) As Integer Dim MX(26,26), MY(26,26) As Integer CLS ' Define charge points XP(1) = 11 : YP(1) = 6 : ZP(1) = 175 XP(2) = 17 : YP(2) = 18 : ZP(2) = -150 XP(3) = 7 : YP(3) = 19 : ZP(3) = 40 ' Projection constants Dim XS , YS As Integer XS = 25: YS = 200 ' Fill matrix with transformed coordinates For X = 0 To 25 For Y = 0 To 25 UPJE = 0 For W = 1 To Q D = Sqr((X - XP(W))^2 + (Y - YP(W))^2) Inc UPJE, ZP(W) * Exp(-D / 2) Next ' Fix grid orientation (X then Y) MX(X,Y) = XS + 11*X + 11*Y ' Flip Y-axis (to match PC-BASIC lower-left origin) MY(X,Y) = SCREEN_HEIGHT - (UPJE + YS - X*4 + Y*4) ' Optional: show control points Pixel MX(X,Y), MY(X,Y), RGB(0,255,255) Next Next ' Draw the surface E = 0 For Y = 25 To 1 Step -1 For X = 0 To 24 X1 = MX(X,Y): Y1 = MY(X,Y) X2 = MX(X+1,Y): Y2 = MY(X+1,Y) X3 = MX(X+1,Y-1): Y3 = MY(X+1,Y-1) X4 = MX(X,Y-1): Y4 = MY(X,Y-1) ' Fill with alternating pattern If (E Mod 2 = 0) Then K = RGB(0,0,255) Else K = RGB(0,128,255) EndIf Triangle X1, Y1, X2, Y2,X3, Y3 ,k,k Triangle X1, Y1, X4, Y4,X3, Y3 ,k,k
XPc = (X1 + X3) YPc = (Y1 + Y3) ' Highlight border K = RGB(255,255,255) Line X1,Y1,X2,Y2,, K Line X2,Y2 ,X3,Y3,, K Line X3,Y3,X4,Y4,, K Line X4,Y4,X1,Y1,, K Inc E Next Next Save image "layer" |