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

本文介绍了一段使用FB内部绘图函数创建动画的代码示例,并提供了将此动画转换为GDI绘制的方法。示例中包括了创建旋转的3D对象、添加文字和球体等元素的过程。

ScreenGif.gif

这是 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[n]), 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[n].z, 5, 2)
          Circle(rr[n].x, rr[n].y), rad, rr[n].col, , , , f
      Next n
      ScreenUnlock
      Sleep Regulate(30, fps), 1
  Loop Until Len(Inkey)
源码下载:Basic语言编程群 78458582 进QQ群后,在群共享里下载。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值