private void StrokeSkiaPath(SKPath skPath, IShape shape) { IBrush?stroke = shape.Stroke; if (stroke != null) { using SKPaint paint = new SKPaint { Style = SKPaintStyle.Stroke, IsAntialias = true }; InitSkiaPaintForBrush(paint, stroke, shape); paint.StrokeWidth = (int)shape.StrokeThickness; paint.StrokeMiter = (float)shape.StrokeMiterLimit; SKStrokeCap strokeCap = shape.StrokeLineCap switch { PenLineCap.Flat => SKStrokeCap.Butt, PenLineCap.Round => SKStrokeCap.Round, PenLineCap.Square => SKStrokeCap.Square, _ => throw new InvalidOperationException($"Unknown PenLineCap value {shape.StrokeLineCap}") }; paint.StrokeCap = strokeCap; SKStrokeJoin strokeJoin = shape.StrokeLineJoin switch { PenLineJoin.Miter => SKStrokeJoin.Miter, PenLineJoin.Bevel => SKStrokeJoin.Bevel, PenLineJoin.Round => SKStrokeJoin.Round, _ => throw new InvalidOperationException($"Unknown PenLineJoin value {shape.StrokeLineJoin}") }; paint.StrokeJoin = strokeJoin; _skCanvas.DrawPath(skPath, paint); } }
public SkiaCanvas(SKCanvas canvas, SKStrokeCap strokeCap, bool antiAlias) { Canvas = canvas; StrokeCap = strokeCap; _paint = new SKPaint { IsAntialias = antiAlias }; }
public Stroke(float size, IBrush brush, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join) { this.Size = size; this.Brush = brush; this.Style = style; this.Cap = cap; this.Join = join; }
public static SKStrokeJoin StrokeJoin(SKStrokeCap cap) { return ((cap == SKStrokeCap.Butt) ? SKStrokeJoin.Bevel : (cap == SKStrokeCap.Round) ? SKStrokeJoin.Round : (cap == SKStrokeCap.Square) ? SKStrokeJoin.Miter : SKStrokeJoin.Bevel); }
internal BaseStrokeContent(ILottieDrawable lottieDrawable, BaseLayer layer, SKStrokeCap cap, SKStrokeJoin join, float miterLimit, AnimatableIntegerValue opacity, AnimatableFloatValue width, List <AnimatableFloatValue> dashPattern, AnimatableFloatValue offset) { _lottieDrawable = lottieDrawable; _layer = layer; Paint.Style = SKPaintStyle.Stroke; Paint.StrokeCap = cap; Paint.StrokeJoin = join; Paint.StrokeMiter = miterLimit; _opacityAnimation = opacity.CreateAnimation(); _widthAnimation = width.CreateAnimation(); if (offset == null) { _dashPatternOffsetAnimation = null; } else { _dashPatternOffsetAnimation = offset.CreateAnimation(); } _dashPatternAnimations = new List <IBaseKeyframeAnimation <float?, float?> >(dashPattern.Count); _dashPatternValues = new float[dashPattern.Count]; for (var i = 0; i < dashPattern.Count; i++) { _dashPatternAnimations.Add(dashPattern[i].CreateAnimation()); } layer.AddAnimation(_opacityAnimation); layer.AddAnimation(_widthAnimation); for (var i = 0; i < _dashPatternAnimations.Count; i++) { layer.AddAnimation(_dashPatternAnimations[i]); } if (_dashPatternOffsetAnimation != null) { layer.AddAnimation(_dashPatternOffsetAnimation); } _opacityAnimation.ValueChanged += OnValueChanged; _widthAnimation.ValueChanged += OnValueChanged; for (var i = 0; i < dashPattern.Count; i++) { _dashPatternAnimations[i].ValueChanged += OnValueChanged; } if (_dashPatternOffsetAnimation != null) { _dashPatternOffsetAnimation.ValueChanged += OnValueChanged; } }
public SkiaCanvas(SKCanvas canvas, SKStrokeCap strokeCap, bool?antiAliasLevel) { Canvas = canvas; StrokeCap = strokeCap; _paint = new SKPaint { IsAntialias = antiAliasLevel != null, SubpixelText = antiAliasLevel == true, HintingLevel = SKPaintHinting.Full }; CurrentStyle = default; CurrentColor = default; DefaultColor = default; }
public SkiaCanvas(SKCanvas canvas, SKStrokeCap strokeCap, AntiAlias antiAliasLevel) { Canvas = canvas; StrokeCap = strokeCap; _paint = new SKPaint { IsAntialias = antiAliasLevel != AntiAlias.Disable, SubpixelText = antiAliasLevel == AntiAlias.WithSubpixelText, HintingLevel = SKPaintHinting.Full }; CurrentStyle = default; CurrentColor = default; DefaultColor = default; }
static public LineCap ToLineCap(this SKStrokeCap strokeCap) { switch (strokeCap) { case SKStrokeCap.Round: return(LineCap.Round); case SKStrokeCap.Square: return(LineCap.Square); default: return(LineCap.Flat); } }
public static AM.PenLineCap ToPenLineCap(this SKStrokeCap strokeCap) { switch (strokeCap) { default: case SKStrokeCap.Butt: return(AM.PenLineCap.Flat); case SKStrokeCap.Round: return(AM.PenLineCap.Round); case SKStrokeCap.Square: return(AM.PenLineCap.Square); } }
private SKPaint GetPaintColor( SKPaintStyle style, string hexColor, float strokeWidth = 0, SKStrokeCap cap = SKStrokeCap.Round, bool isAntialias = true) { return(new SKPaint { Style = style, StrokeWidth = strokeWidth, Color = string.IsNullOrWhiteSpace(hexColor) ? SKColors.White : SKColor.Parse(hexColor), StrokeCap = cap, IsAntialias = isAntialias }); }
public static SKStrokeCap ToSkia(this PenLineCap penLineCap) { SKStrokeCap skStrokeCap = SKStrokeCap.Butt; switch (penLineCap) { case PenLineCap.Flat: skStrokeCap = SKStrokeCap.Butt; break; case PenLineCap.Square: skStrokeCap = SKStrokeCap.Square; break; case PenLineCap.Round: skStrokeCap = SKStrokeCap.Round; break; } return(skStrokeCap); }
public static PenLineCap ToCommon(this SKStrokeCap skStrokeCap) { PenLineCap penLineCap = PenLineCap.Flat; switch (skStrokeCap) { case SKStrokeCap.Butt: penLineCap = PenLineCap.Flat; break; case SKStrokeCap.Square: penLineCap = PenLineCap.Square; break; case SKStrokeCap.Round: penLineCap = PenLineCap.Round; break; } return(penLineCap); }
public static void BindDisplay(this MathKeyboard keyboard, SKCanvasView view, MathPainter settings, SKColor caretColor, CaretShape caretShape = CaretShape.IBeam, SKStrokeCap cap = SKStrokeCap.Butt) { view.EnableTouchEvents = true; view.Touch += (sender, e) => { if (e.ActionType == SKTouchAction.Pressed) { keyboard.MoveCaretToPoint(new System.Drawing.PointF(e.Location.X, e.Location.Y)); } }; keyboard.RedrawRequested += (_, __) => view.InvalidateSurface(); view.PaintSurface += (sender, e) => { var c = e.Surface.Canvas; c.Clear(); MathPainter.DrawDisplay(settings, keyboard.Display, c); keyboard.DrawCaret(new SkiaCanvas(c, cap, AntiAlias.Enable), caretColor.FromNative(), caretShape); }; }
void UpdateStrokeLineCap() { PenLineCap lineCap = Element.StrokeLineCap; SKStrokeCap skStrokeCap = SKStrokeCap.Butt; switch (lineCap) { case PenLineCap.Flat: skStrokeCap = SKStrokeCap.Butt; break; case PenLineCap.Square: skStrokeCap = SKStrokeCap.Square; break; case PenLineCap.Round: skStrokeCap = SKStrokeCap.Round; break; } Control.UpdateStrokeLineCap(skStrokeCap); }
public static CGLineCap LineCap(SKStrokeCap cap) { return((cap == SKStrokeCap.Round) ? CGLineCap.Round : (cap == SKStrokeCap.Butt) ? CGLineCap.Butt : (cap == SKStrokeCap.Square) ? CGLineCap.Square : 0); }
public Path(SKPath path, SKStrokeCap cap, SKStrokeJoin join) { source = path; this.cap = cap; this.join = join; }
public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join) { throw new NotImplementedException(); }
public /*interface Colorer*/ SKPaint LinePaint(float strokeWidth, SKColor color, SKStrokeCap cap = SKStrokeCap.Butt) { return(new SKPaint { IsStroke = true, Style = SKPaintStyle.Stroke, StrokeWidth = strokeWidth, Color = color, IsAntialias = true, StrokeCap = cap, StrokeJoin = StrokeJoin(cap) }); //, StrokeCap = SKStrokeCap.Butt/Round/Square, StrokeJoin = SKStrokeJoin.Bevel/Miter/Round, StrokeMiter = float }
public extern static void sk_paint_set_stroke_cap(sk_paint_t t, SKStrokeCap cap);
public /*interface Colorer*/ SKPaint LinePaint(float strokeWidth, SKColor color, SKStrokeCap cap = SKStrokeCap.Butt) { return(new SKPaint { Style = SKPaintStyle.Stroke, StrokeWidth = strokeWidth, Color = color, IsAntialias = true, StrokeCap = cap, StrokeJoin = SKColorer.StrokeJoin(cap) }); }
/// <summary> /// Paints an annotation object on the specified graphics. /// </summary> /// <param name="graphics"> /// A <see cref="ChartGraphics"/> object, used to paint an annotation object. /// </param> /// <param name="chart"> /// Reference to the <see cref="ChartService"/> owner control. /// </param> override internal void Paint(ChartService chart, ChartGraphics graphics) { // Get annotation position in relative coordinates GetRelativePosition(out SKPoint firstPoint, out SKSize size, out SKPoint anchorPoint); SKPoint secondPoint = new(firstPoint.X + size.Width, firstPoint.Y + size.Height); // Create selection rectangle SKRect selectionRect = new(firstPoint.X, firstPoint.Y, secondPoint.X, secondPoint.Y); // Adjust coordinates AdjustLineCoordinates(ref firstPoint, ref secondPoint, ref selectionRect); // Check if text position is valid if (float.IsNaN(firstPoint.X) || float.IsNaN(firstPoint.Y) || float.IsNaN(secondPoint.X) || float.IsNaN(secondPoint.Y)) { return; } // TODO: this #if false // Set line caps bool capChanged = false; SKStrokeCap oldCap = SKStrokeCap.Butt; if (_startCap != LineAnchorCapStyle.None || _endCap != LineAnchorCapStyle.None) { capChanged = true; oldCap = graphics.Pen.StrokeCap; // Apply anchor cap settings if (_startCap == LineAnchorCapStyle.Arrow) { // Adjust arrow size for small line width if (LineWidth < 4) { int adjustment = 3 - LineWidth; graphics.Pen.StrokeCap = LineCap.Custom; graphics.Pen.CustomStartCap = new AdjustableArrowCap( LineWidth + adjustment, LineWidth + adjustment, true); } else { graphics.Pen.StartCap = LineCap.ArrowAnchor; } } else if (_startCap == LineAnchorCapStyle.Diamond) { graphics.Pen.StartCap = LineCap.DiamondAnchor; } else if (_startCap == LineAnchorCapStyle.Round) { graphics.Pen.StartCap = LineCap.RoundAnchor; } else if (_startCap == LineAnchorCapStyle.Square) { graphics.Pen.StartCap = LineCap.SquareAnchor; } if (_endCap == LineAnchorCapStyle.Arrow) { // Adjust arrow size for small line width if (LineWidth < 4) { int adjustment = 3 - LineWidth; graphics.Pen.StrokeCap = SKStrokeCap.Round; // graphics.Pen.EndCap = LineCap.Custom; // graphics.Pen.CustomEndCap = new AdjustableArrowCap( // this.LineWidth + adjustment, // this.LineWidth + adjustment, // true); } else { graphics.Pen.StrokeCap = SKStrokeCap.Round;//LineCap.ArrowAnchor; } } else if (_endCap == LineAnchorCapStyle.Diamond) { graphics.Pen.EndCap = LineCap.DiamondAnchor; } else if (_endCap == LineAnchorCapStyle.Round) { graphics.Pen.EndCap = LineCap.RoundAnchor; } else if (_endCap == LineAnchorCapStyle.Square) { graphics.Pen.EndCap = LineCap.SquareAnchor; } } if (Common.ProcessModePaint) { // Draw line graphics.DrawLineRel( LineColor, LineWidth, LineDashStyle, firstPoint, secondPoint, ShadowColor, ShadowOffset); } // Restore line caps if (capChanged) { graphics.Pen.StartCap = oldStartCap; graphics.Pen.EndCap = oldEndCap; } #endif // Paint selection handles PaintSelectionHandles(graphics, selectionRect, null); }
public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join) { using (var paint = this.CreatePaint(path)) { paint.StrokeWidth = size; paint.StrokeCap = cap; paint.StrokeJoin = join; paint.Style = SKPaintStyle.Stroke; canvas.DrawPath(path, paint); } }
public void SetFixStrokeCap(SKStrokeCap cap) { variableStrokeCap = false; paint.StrokeCap = cap; }
public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join) { using (var paint = new SKPaint() { IsAntialias = true, StrokeWidth = size, Color = this.Color, Style = SKPaintStyle.Stroke, StrokeCap = cap, StrokeJoin = join, }) { if (style == StrokeStyle.Dotted) { paint.PathEffect = SKPathEffect.CreateDash(new[] { 0, size * 2, 0, size * 2 }, 0); } else if (style == StrokeStyle.Dashed) { paint.PathEffect = SKPathEffect.CreateDash(new[] { size * 6, size * 2 }, 0); } canvas.DrawPath(path, paint); } }
public Icon(SKPath path, SKStrokeCap cap, SKStrokeJoin join) { this.Path = path; this.Cap = cap; this.Join = join; }
public void UpdateStrokeLineCap(SKStrokeCap strokeCap) { _skPaint.StrokeCap = strokeCap; UpdatePathStrokeBounds(); }