Can the shapes be defined by primitive polygon shapes?
Do they overlap?
Does it need to be 100% pixel perfect?
If yes, No and No... how about totalling up polygon/shape areas? In other words, create some polygon representations of your shapes. I'm guessing this would need some overlapping code...hmm.
Tom
Do they overlap?
Does it need to be 100% pixel perfect?
If yes, No and No... how about totalling up polygon/shape areas? In other words, create some polygon representations of your shapes. I'm guessing this would need some overlapping code...hmm.
Type point Field x#,y# Method Set(xx#,yy#) x=xx y=yy End Method End Type Type polygon Field pointList:point[] Function Create:polygon(pointCount:Int = 3) 'minimum for a poly Local p:polygon = New polygon p.pointList = New point[pointCount] For Local i = 0 Until p.pointList.length p.pointList[i] = New point Next Return p End Function Method GetArea:Int() Local i,j Local area For i=0 Until pointList.length j=(i+1) Mod pointList.length area:+ pointList[i].x * pointList[j].y area:- pointList[i].y * pointList[j].x Next area:/ 2 Return area End Method Method Draw() SetColor 0,255,0 Local i,j For i = 0 Until pointList.length j=(i+1) Mod pointList.length DrawLine pointList[i].x,pointList[i].y,pointList[j].x,pointList[j].y,True Next SetColor 255,255,255 End Method End Type Local p:polygon = polygon.Create(4) p.pointList[0].Set(100,100) p.pointList[1].Set(500,100) p.pointList[2].Set(500,500) p.pointList[3].Set(100,500) Graphics 800,600,0 While Not MouseHit(1) Cls p.pointList[2].Set(MouseX(),MouseY()) p.Draw() If MouseHit(2) MoveMouse(500,500) DrawText "When this poly is perfectly square, area should equal 400*400 = 160000",10,10 DrawText "Note! I've found it hard to move my mouse to make a perfect square, so RMB will move it to 500,500 :)",10,30 DrawText "Area of poly = "+p.GetArea()+" pixels",10,60 Flip Wend EndGraphics()
Tom