Drawing a polygon with one color for stroke, and a different one for fill?
You can use
CGContextDrawPath(context, kCGPathFillStroke);
instead of
CGContextFillPath(context);
CGContextStrokePath(context);
The problem is that both CGContextFillPath()
and CGContextStrokePath(context)
clear the current path, so that only the first operation succeeds, and the second
operation draws nothing. CGContextDrawPath()
combines fill and stroke without
clearing the path in between.
Drawing WPF Polygon with a stroke in solid color or transparent around
Starting from @Clemens indication, I elaborate a solution with a series of transformation, without any geometric calculus. Less or more the solution is here, I will try to apply to my context, but in the end is:
<Path MouseLeftButtonUp="PathPolyline_MouseLeftButtonUp"
StrokeThickness="0" Stroke="Transparent" Fill="Gold" ClipToBounds="False">
<Path.Data>
<PathGeometry FillRule="EvenOdd" >
<PathFigure StartPoint="0,0" IsClosed="True">
<PolyLineSegment Points="50,50 0,80"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
and elaboration in C# code will do something as:
private void PathPolyline_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Brush brush = Brushes.Black;
Pen pen = new Pen(brush, 20.0); //thickness double than wanted measure: 20 to reduce 10
//
Path path = sender as Path;
PathGeometry pg = path.Data as PathGeometry;
PathGeometry pg2 = pg.GetWidenedPathGeometry(pen);
//
Transform tr = Transform.Identity;
PathGeometry pg324 = Geometry.Combine(pg, pg2, GeometryCombineMode.Intersect, tr);
pg.AddGeometry(pg324);
}
Stylize polygon stroke and fill differently?
The polygon layer only renders the fill area. To draw an outline of a polygon, use a line layer connected to the same data source. See the second example in the documentation: https://learn.microsoft.com/en-us/azure/azure-maps/map-add-shape
Different stroke of polygon SVG
Draw 2 paths. Make one path the red parts of the polygon and the other the black.
Is it possible to draw object with outline and fill at the same time?
The answer is: you can't. Both color properties (Color
and ColorF
) of SKPaint
set the same SKColorF
value internally (Color
being converted into ColorF
). The 'F' in ColorF
indicates the RGBA values are stored as floats instead of bytes.
Related Topics
iOS 11 - Unable to Change Navigation Bar Height
Could Not Cast Value of Type 'Uiview' (0X112484Eb0) to 'Skview' (0X111646718)
iOS Application Using Facebook -- Rejected
Uipageviewcontroller Gesture Is Calling Viewcontrollerafter: But Doesn't Animate
Admob 7.3.1 and Swift 2.0 - Module Not Found
Download PDF and Save to the "Files" in Iphone, Not to the App Data, Swift
Position a Subview on the Edge of a Circular Shaped View
In Swift, How to Get the Device Orientation Correctly Right After It's Launched
Urlsessiondelegate Function Not Being Called
How to Take Uiimage of Avcapturevideopreviewlayer Instead of Avcapturephotooutput Capture
Instantiateviewcontrollerwithidentifier - Storyboard Id Set But Still Not Working
iOS 11 Search Bar Jumping to Top of Screen
Objective C- Trouble Updating UI on Main Thread
What Does $0 Represent in Closures in Swift
Avplayerviewcontroller Using Audio-Only Avplayer
Swift, Dispatch_Group_Wait Not Waiting
How to Save Custom Objects in Array and Store It in Nsuserdefaults - Iphone