Draw() public static method

public static Draw ( SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry ) : void
canvas SkiaSharp.SKCanvas
viewport IViewport
style IStyle
geometry IGeometry
return void
コード例 #1
0
ファイル: VectorStyleRenderer.cs プロジェクト: Mapsui/Mapsui
        public bool Draw(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IFeature feature, IStyle style, ISymbolCache symbolCache, long iteration)
        {
            try
            {
                var vectorStyle = (VectorStyle)style;
                var opacity = (float)(layer.Opacity * style.Opacity);

                switch (feature)
                {
                    case RectFeature rectFeature:
                        PolygonRenderer.Draw(canvas, viewport, vectorStyle, rectFeature, rectFeature.Rect.ToPolygon(), opacity);
                        break;
                    case PointFeature pointFeature:
                        SymbolStyleRenderer.DrawSymbol(canvas, viewport, layer, pointFeature.Point.X, pointFeature.Point.Y, new SymbolStyle { Outline = vectorStyle.Outline, Fill = vectorStyle.Fill, Line = vectorStyle.Line });
                        break;
                    case GeometryFeature geometryFeature:
                        switch (geometryFeature.Geometry)
                        {
                            case GeometryCollection collection:
                                for (var i = 0; i < collection.NumGeometries; i++)
                                    Draw(canvas, viewport, layer, new GeometryFeature(collection.GetGeometryN(i)), style, symbolCache, iteration);
                                break;
                            case Point point:
                                Draw(canvas, viewport, layer, new PointFeature(point.X, point.Y), style, symbolCache, iteration);
                                break;
                            case Polygon polygon:
                                PolygonRenderer.Draw(canvas, viewport, vectorStyle, feature, polygon, opacity, symbolCache);
                                break;
                            case LineString lineString:
                                LineStringRenderer.Draw(canvas, viewport, vectorStyle, lineString, opacity);
                                break;
                            default:
                                throw new ArgumentException("Unknown geometry of Feature");
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message, ex);
            }

            return true;
        }
コード例 #2
0
 private void RenderFeature(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature)
 {
     if (feature.Geometry is Point)
     {
         PointRenderer.Draw(canvas, viewport, style, feature, _symbolTextureCache);
     }
     else if (feature.Geometry is LineString)
     {
         LineStringRenderer.Draw(canvas, viewport, style, feature);
     }
     else if (feature.Geometry is Polygon)
     {
         PolygonRenderer.Draw(canvas, viewport, style, feature);
     }
     else if (feature.Geometry is IRaster)
     {
         RasterRenderer.Draw(canvas, viewport, style, feature, _tileTextureCache, _currentIteration);
     }
 }