public static void Set_Padding(MyPointRect r) { int padding = 15; r.x -= padding; r.y -= padding; r.width += padding * 2; r.height += padding * 2; }
public static MyPointRect Get_Border_Points(BPaintLine Par_obj) { MyPointRect result = new MyPointRect(); List <MyPoint> data = new List <MyPoint>(); data.Add(Par_obj.StartPosition); data.Add(Par_obj.end); result.x = data.Min(j => j.x); result.y = data.Min(j => j.y); result.width = data.Max(j => j.x) - result.x; result.height = data.Max(j => j.y) - result.y; result.x += Par_obj.PositionChange.x; result.y += Par_obj.PositionChange.y; Set_Padding(result); return(result); }
public void Generate_SVG() { _Svg = new svg { id = "svgPaint", width = par_width, height = par_height, xmlns = "http://www.w3.org/2000/svg", }; _Svg.Children.Add(new rect { width = par_width, height = par_height, fill = "wheat", stroke = "red", stroke_width = 1, }); foreach (var item in (parent as CompBlazorPaint).ObjectsList.OrderBy(x => x.SequenceNumber)) { switch (item.ObjectType) { case BPaintOpbjectType.HandDraw: _Svg.Children.Add(drawPath(item as BPaintHandDraw)); if (item.Selected) { MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintHandDraw); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "red", stroke_width = 1, style = "opacity:0.2", }); } break; case BPaintOpbjectType.Line: BPaintLine currLine = item as BPaintLine; _Svg.Children.Add(drawLine(currLine)); if (item.Selected) { circle c1 = new circle() { cx = currLine.StartPosition.x + currLine.PositionChange.x, cy = currLine.StartPosition.y + currLine.PositionChange.y, r = currLine.width * 1.5, fill = "wheat", stroke = currLine.Color, stroke_width = 2, }; if (currLine.Scale.x != 0 || currLine.Scale.y != 0) { c1.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")"; } _Svg.Children.Add(c1); circle c2 = new circle() { cx = currLine.end.x + currLine.PositionChange.x, cy = currLine.end.y + currLine.PositionChange.y, r = currLine.width * 1.5, fill = "wheat", stroke = currLine.Color, stroke_width = 2, }; if (currLine.Scale.x != 0 || currLine.Scale.y != 0) { c2.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")"; } _Svg.Children.Add(c2); MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintLine); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "red", stroke_width = 1, style = "opacity:0.2", }); } break; default: break; } } }