Esempio n. 1
0
        private void drawLandmass(SKCanvas canvas)
        {
            var features = pack.features;
            var chains   = map4Coastline.Paths;
            var paint    = new SKPaint()
            {
                IsAntialias = true
            };

            chains.Keys.forEach(f =>
            {
                var paths = chains[f];
                if (features[f].type == "lake")
                {
                    //landmask
                    paint.Style      = SKPaintStyle.Fill;
                    paint.Color      = Color.Black.SK();
                    paint.MaskFilter = null;
                    paths.ForEach(p => canvas.DrawPath(lineGenZ(p), paint));

                    //lakes
                    var lake    = Lakes.find(l => l.name == features[f].group);
                    paint.Style = SKPaintStyle.Fill;
                    paint.Color = lake.fill.ToColor().Opacity(lake.opacity).SK();
                    paths.ForEach(p => canvas.DrawPath(lineGenZ(p), paint));

                    paint.Style       = SKPaintStyle.Stroke;
                    paint.Color       = lake.stroke.ToColor().Opacity(lake.opacity).SK();
                    paint.StrokeWidth = lake.strokeWidth;
                    paths.ForEach(p => canvas.DrawPath(lineGenZ(p), paint));
                }
                else
                {
                    //landmask
                    paint.Style      = SKPaintStyle.Fill;
                    paint.Color      = Color.White.SK();
                    paint.MaskFilter = null;
                    paths.ForEach(p => canvas.DrawPath(lineGenZ(p), paint));

                    //coastline
                    var g             = features[f].group == "lake_island" ? "lake_island" : "sea_island";
                    var island        = Islands.find(l => l.name == g);
                    paint.Style       = SKPaintStyle.Stroke;
                    paint.Color       = island.stroke.ToColor().Opacity(island.opacity).SK();
                    paint.StrokeWidth = island.strokeWidth;
                    //! TODO 滤镜怎么实现
                    paint.MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 0.2f);
                    paths.ForEach(p => canvas.DrawPath(lineGenZ(p), paint));
                }
            });
        }