0 Members and 1 Guest are viewing this topic.
Well, this is not unlike normal triangle fill, but seeing I havent this anywhere else I thought it would be good idea to post it here. It basicly works like this, it draws a Line from point 2 to point 3, and on every pixel from that line, it draws line from point 1 to those pixels. It has some bugs (even with default Line drawing function, fixing those it could be ok speed I think? (if optimised properly). Im gonna start on 'normal' style triangle fill next (I never read tutos, just experiment as you see ).Heres the codeZCode: [Select]Const ScreenWidth = 320Const ScreenHeight = 240Graphics ScreenWidth,ScreenHeight,0,2SetBuffer BackBuffer()RepeatLockBufferTriangle MouseX(),MouseY(),50+50*Sin(phase),50+50*Cos(phase),190,90,(Rand(255) Shl 16) + (Rand(255) Shl 8) + Rand(255)UnlockBufferphase = phase + 1FlipClsUntil KeyHit(1)Function Triangle(X1,Y1,X2,Y2,X3,Y3,col)XEro = X2-X3YEro = Y2-Y3Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X2DY# = Y2Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1Line X1,Y1,DX,DY,colDX# = DX# + StepX#DY# = DY# + StepY#Until c >= Matka#End FunctionFunction Line(X1,Y1,X2,Y2,col)XEro = X1-X2YEro = Y1-Y2Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X1DY# = Y1Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1If DX > 0 And DY > 0 And DX + StepX#DY# = DY# + StepY#Until c >= Matka#End Function
Const ScreenWidth = 320Const ScreenHeight = 240Graphics ScreenWidth,ScreenHeight,0,2SetBuffer BackBuffer()RepeatLockBufferTriangle MouseX(),MouseY(),50+50*Sin(phase),50+50*Cos(phase),190,90,(Rand(255) Shl 16) + (Rand(255) Shl 8) + Rand(255)UnlockBufferphase = phase + 1FlipClsUntil KeyHit(1)Function Triangle(X1,Y1,X2,Y2,X3,Y3,col)XEro = X2-X3YEro = Y2-Y3Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X2DY# = Y2Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1Line X1,Y1,DX,DY,colDX# = DX# + StepX#DY# = DY# + StepY#Until c >= Matka#End FunctionFunction Line(X1,Y1,X2,Y2,col)XEro = X1-X2YEro = Y1-Y2Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X1DY# = Y1Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1If DX > 0 And DY > 0 And DX + StepX#DY# = DY# + StepY#Until c >= Matka#End Function
5H0CKW4VE *Administrator*Posts: 7294(27/3/05 15:50)81.155.27.21Reply | Edit | DelezSupporterRe: Weird triangle fill This wont work here.¤´¨)¸.·´¸.·*´¨) ¸.·*¨)(¸.·´ (¸.·`¤... SHOCKWAVE / DBF...¤VISIT DARK BIT FACTORY INTERACTIVE! (please!)
Blitz Amateur DBF: CoderPosts: 54(28/3/05 0:28)67.172.138.160Reply | Edit | DelRe: Weird triangle fill Here's a working versionCode: [Select]Const ScreenWidth = 320Const ScreenHeight = 240Graphics ScreenWidth,ScreenHeight,0,2SetBuffer BackBuffer()RepeatLockBufferTriangle MouseX(),MouseY(),50+50*Sin(phase),50+50*Cos(phase),190,90,(Rand(255) Shl 16) + (Rand(255) Shl 8) + Rand(255)UnlockBufferphase = phase + 1FlipClsUntil KeyHit(1)Function Triangle(X1,Y1,X2,Y2,X3,Y3,col)XEro = X2-X3YEro = Y2-Y3Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X2DY# = Y2Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1Line X1,Y1,DX,DY,colDX# = DX# + StepX#DY# = DY# + StepY#Until c >= Matka#End FunctionFunction Line(X1,Y1,X2,Y2,col)XEro = X1-X2YEro = Y1-Y2Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X1DY# = Y1Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1If DX > 0 And DY > 0 DX# = DX# + StepX#DY# = DY# + StepY#WritePixelFast dx,dy,colEndIfUntil c >= Matka#End Function
Const ScreenWidth = 320Const ScreenHeight = 240Graphics ScreenWidth,ScreenHeight,0,2SetBuffer BackBuffer()RepeatLockBufferTriangle MouseX(),MouseY(),50+50*Sin(phase),50+50*Cos(phase),190,90,(Rand(255) Shl 16) + (Rand(255) Shl 8) + Rand(255)UnlockBufferphase = phase + 1FlipClsUntil KeyHit(1)Function Triangle(X1,Y1,X2,Y2,X3,Y3,col)XEro = X2-X3YEro = Y2-Y3Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X2DY# = Y2Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1Line X1,Y1,DX,DY,colDX# = DX# + StepX#DY# = DY# + StepY#Until c >= Matka#End FunctionFunction Line(X1,Y1,X2,Y2,col)XEro = X1-X2YEro = Y1-Y2Angle# = ATan2(XEro,YEro)StepX# = -Sin(Angle#)StepY# = -Cos(Angle#)DX# = X1DY# = Y1Matka# = Sqr(XEro*XEro+YEro*YEro)Repeatc = c + 1If DX > 0 And DY > 0 DX# = DX# + StepX#DY# = DY# + StepY#WritePixelFast dx,dy,colEndIfUntil c >= Matka#End Function
5H0CKW4VE*Administrator*Posts: 7499(28/8/05 14:26)81.153.61.129Reply | Edit | DelezSupporterRe: Weird triangle fill Interesting technique to fill the triangle there.¤´¨)¸.·´¸.·*´¨) ¸.·*¨)(¸.·´ (¸.·`¤... SHOCKWAVE / DBF...¤VISIT DARK BIT FACTORY INTERACTIVE! (please!)