' $Id$ Import noddybox.vectorgfx Strict Const SCRW=800'1280 Const SCRH=600'1024 SetGraphicsDriver GLMax2DDriver() Graphics SCRW,SCRH,32,60' Or HARDSYNC 'HideMouse() SetBlend(ALPHABLEND) Const SIZE:Int=20 Const MSIZE:Int=40 'Local o1:TVectorGfxObject=New TVectorGfxObject 'Local o2:TVectorGfxObject=New TVectorGfxObject Local o1:TVectorGfxObject=TVectorGfxObject.Load("obj1.2d") Local o2:TVectorGfxObject=TVectorGfxObject.Load("obj2.2d") Local cm:TVectorGfxCollisionMap=TVectorGfxCollisionMap.Create(MSIZE,MSIZE) Local l:TList=CreateList() Rem l.Clear() l.AddLast(TVectorGfxPoint.Create(-SIZE,-SIZE)) l.AddLast(TVectorGfxPoint.Create(SIZE,-SIZE)) l.AddLast(TVectorGfxPoint.Create(SIZE,SIZE)) l.AddLast(TVectorGfxPoint.Create(-SIZE,SIZE)) o1.SetPoints(l.ToArray()) l.Clear() l.AddLast(TVectorGfxLine.Create(0,1,255,0,0,1)) l.AddLast(TVectorGfxLine.Create(1,2,0,255,0,2)) l.AddLast(TVectorGfxLine.Create(2,3,255,0,0,1)) l.AddLast(TVectorGfxLine.Create(3,0,0,255,0,2)) o1.SetLines(l.ToArray()) o1.x=400 o1.y=300 o1.Save("obj1.2d") l.Clear() l.AddLast(TVectorGfxPoint.Create(-SIZE/2,-SIZE/2)) l.AddLast(TVectorGfxPoint.Create(SIZE/2,-SIZE/2)) l.AddLast(TVectorGfxPoint.Create(SIZE/2,SIZE/2)) l.AddLast(TVectorGfxPoint.Create(-SIZE/2,SIZE/2)) o2.SetPoints(l.ToArray()) l.Clear() l.AddLast(TVectorGfxLine.Create(0,1,255,255,255,0)) l.AddLast(TVectorGfxLine.Create(1,2,255,255,255,0)) l.AddLast(TVectorGfxLine.Create(2,3,255,255,255,0)) l.AddLast(TVectorGfxLine.Create(3,0,255,255,255,0)) o2.SetLines(l.ToArray()) o2.Save("obj2.2d") EndRem Type FadeLine Extends TVectorGfxLineStyle Method Draw:Int(x1:Int, y1:Int, x2:Int, y2:Int, r:Int, g:Int, b:Int, id:Int, colmap:TVectorGfxCollisionMap) Local mask:Int=0 Local lp:TList=DoLine(x1,y1,x2,y2) For Local p:TAlgoPoint=EachIn lp SetColor(r,g,b) mask:|colmap.SetCollision(p.x,p.y,id) Plot(p.x,p.y) r=Max(0,r-10) g=Max(0,g-10) b=Max(0,b-10) Next Return mask End Method End Type While Not KeyHit(KEY_ESCAPE) Cls cm.Clear() cm.SetOffset(MouseX()-MSIZE/2,MouseY()-MSIZE/2) If KeyHit(KEY_F1) VectorGfxSetSolid() EndIf If KeyHit(KEY_F2) VectorGfxSetAlpha(0.7,1.0) EndIf If KeyHit(KEY_F3) VectorGfxSetThickAlpha(0.2) EndIf If KeyHit(KEY_F4) VectorGfxSetCustom(New FadeLine) EndIf o1.Draw(cm) o1.ang=(o1.ang+2) Mod 3600 o2.x=MouseX() o2.y=MouseY() o2.Draw(cm) For Local i:Int=0 To 3 Local p:TVectorGfxPoint[]=o1.AdjustedCoords(i) Local v:TVector=o1.Normal(i) SetColor(0,0,255) DrawLine(o1.x+p[0].x,o1.y+p[0].y,o1.x+p[0].x+v.x*20,o1.y+p[0].y+v.y*20) Next DrawText MilliSecs() + ":Col=" + o2.Draw(cm),0,0 Flip FlushMem Wend EndGraphics End