Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

/Tools/Clipper/Clipper Ellipse Test
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Tools/Clipper/Clipper Ellipse Test
This example is the version from Wed, 9th Jan 2018.
Project "Clipper Ellipse Test.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open() dim p as new Picture(Width, Height, 32) dim g as Graphics = p.Graphics //set up the subject and clip polygons ... dim ellipses as new ClipperPathsMBS ellipses.Append ClipperMBS.EllipsePoints(100,100,300,300) ellipses.Append ClipperMBS.EllipsePoints(125,130,275,180) ellipses.Append ClipperMBS.EllipsePoints(125,220,275,270) dim clp as new ClipperPathsMBS clp.Append ClipperMBS.EllipsePoints(140,70,220,320) //display the subject and clip polygons ... DrawPolygons(g, ellipses, &c33FFFF80) DrawPolygons(g, clp, &cFFFF3380) //get the intersection of the subject and clip polygons ... dim clpr as new ClipperEngineMBS call clpr.AddPaths(ellipses, ClipperMBS.PolyType.Subject, true) call clpr.AddPaths(clp, ClipperMBS.PolyType.Clip, true) dim solution as new ClipperPathsMBS if clpr.Execute(ClipperMBS.ClipType.Intersection, solution, ClipperMBS.PolyFillType.EvenOdd, ClipperMBS.PolyFillType.EvenOdd) then //finally draw the intersection polygons ... DrawPolygons(g, solution, &c80808040) end if Backdrop = p End EventHandler
Sub DrawPolygon(g as graphics, p as ClipperPathMBS, c as color, ox as integer = 0, oy as integer = 0) dim coordinates(0) as integer dim points() as ClipperPointMBS = p.Values for each point as ClipperPointMBS in points coordinates.Append point.x + ox coordinates.Append point.y + oy next g.ForeColor = c g.FillPolygon coordinates End Sub
Sub DrawPolygons(g as Graphics, paths as ClipperPathsMBS, c1 as color, c2 as color, ox as integer = 0, oy as integer = 0) dim pathsList() as ClipperPathMBS = paths.Values dim b as Boolean for each p as ClipperPathMBS in pathsList if b then DrawPolygon(g, p, c2, ox, oy) else DrawPolygon(g, p, c1, ox, oy) end if b = not b next End Sub
Sub DrawPolygons(g as Graphics, paths as ClipperPathsMBS, c as color, ox as integer = 0, oy as integer = 0) dim pathsList() as ClipperPathMBS = paths.Values dim b as Boolean for each p as ClipperPathMBS in pathsList DrawPolygon(g, p, c, ox, oy) b = not b next End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Tools Plugin.




Links
MBS Xojo Chart Plugins