Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

New Post: shape random colors

$
0
0
In case somebody is looking at the same, I solved this with a procedure creating the categories (VBA):
Sub CreateLineColors(sf as MapWINGIS.Shapefile, aantal As Integer)

Dim ct As MapWinGIS.ShapefileCategory
Dim i As Integer

For i = 0 To aantal - 1
    Set ct = sf.Categories.Add("Kleur" & i)
    ct.DrawingOptions.LineColor = RGB(RandomColor(225), RandomColor(225), RandomColor(225))
    ct.DrawingOptions.LineWidth = 3
Next i

End Sub

Function RandomColor(MaxValue As Integer) As Integer
    RandomColor = Int((MaxValue * Rnd) + 1)
End Function
(because I don't want almost white colours I maximized the values to 225)

Now after creating the shapefile I call the function with the variables holding my shapefile and the number of colours I want (NrColors). Every shape will now get a category by the following:
shpIndex = sf.EditAddShape(shp)
If shpIndex = -1 Then
    'Something goes wrong!
Else
    sf.ShapeCategory(shpIndex) = shpIndex Mod NrColors
End If

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>