勇芳软件 发表于 2018-3-8 22:56:36

【VFB源码】FB图形例题3D旋转


这是 FB 自己内部绘图专用函数画的动画
当然可以用翻译为 GDI画,这里只是演示代码运行方式
感兴趣的可以下载源码研究。
基本代码:
ScreenRes 800, 600, 32

Dim As Long fps
ReDim As V3 Va()
Dim As String d = "ABCD"
Randomize 13
AddABox(va(), Type < V3 > (400, 300, 0), 350, 2, 2, RGB(250, 100, 0)) 'skewer
'flip 90 degrees on y axis
memcpy(@va(LBound(va)), RotateArray(va(), Type < _float > (0, 1.570796, 0), vct(400, 300, 0), 0), (UBound(va) - LBound(va) + 1) *SizeOf(v3))
'Add text
For n As Long = 0 To Len(d) -1
      Var zv = map(0, (Len(d) -1), n, -250, 250)
      AddAChar(Va(), Chr(d), 150, RGB(Rnd * 255, Rnd * 255, Rnd * 255), "Arial", FS_BOLD, zv)
Next n
'knob at the end
addasphere(va(), Type < V3 > (400, 300, -350), 30, RGB(200, 200, 0), 1)

Dim As Single ang, rad
Dim As v3 Ptr rr

Color, RGB(100, 100, 100)
Do
      ang += .025
      If ang > 1.570796 * 4 Then ang = 0 '2*pi
      rr = RotateArray(va(), Type < _float > (.5, ang, 0), vct(400, 300, 0), 1)
      quicksort(rr, 0, UBound(va) -1)
      ScreenLock
      Cls
      Draw String(10, 10), "FPS =" & fps
      Draw String(10, 30), "Elements = " & UBound(va)
      
      For n As Long = LBound(va) -1 To UBound(va) -1
          rad = map( -500, 500, rr.z, 5, 2)
          Circle(rr.x, rr.y), rad, rr.col, , , , f
      Next n
      ScreenUnlock
      Sleep Regulate(30, fps), 1
Loop Until Len(Inkey)
源码下载:Basic语言编程群 78458582 进QQ群后,在群共享里下载。

xiawan 发表于 2022-5-17 09:56:17


啥也不说了,感谢楼主分享哇!
页: [1]
查看完整版本: 【VFB源码】FB图形例题3D旋转