public static void LinesLabelingCurvedWithOffset() { //ExStart: LinesLabelingCurvedWithOffset using (var map = new Map(1000, 634)) { var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; var labeling = new SimpleLabeling(labelAttribute: "name") { HaloSize = 1, Placement = new LineLabelPlacement { Alignment = LineLabelAlignment.Curved, Offset = 5, } }; map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer, labeling); map.Padding = 50; map.Render(dataDir + "lines_labeling_curved_offset_out.svg", Renderers.Svg); } //ExEnd: LinesLabelingCurvedWithOffset }
private void MoveLine(SimpleLine line) { line.x0 = (uint)(Avm.Math.abs(Avm.Math.random()) * stage.stageWidth); line.y0 = (uint)(Avm.Math.abs(Avm.Math.random()) * stage.stageHeight); line.x1 = (uint)(Avm.Math.abs(Avm.Math.random()) * stage.stageWidth); line.y1 = (uint)(Avm.Math.abs(Avm.Math.random()) * stage.stageHeight); }
public SimpleLine[] GetLinesFromSamples(int screenWidth, int yAxis, int chartHeight, List <short> samples) { if (samples == null || samples.Count < 1) { return(new SimpleLine[] { }); } var stepSize = (int)Math.Ceiling(samples.Count / (decimal)5000); var smallBufferArray = GetFilteredArray(samples, stepSize); var sampleLines = new SimpleLine[smallBufferArray.Length]; var arrayMax = (float)smallBufferArray.Max(); var arrayLength = smallBufferArray.Length; for (var i = 0; i < (arrayLength); i++) { float xAnchor = ((float)i / (float)arrayLength) * screenWidth; float lineHeightPercent = (float)smallBufferArray[i] / arrayMax; float lineHeightScaled = (float)lineHeightPercent * (float)chartHeight; var lineHeight = (float)yAxis - (float)lineHeightScaled; sampleLines[i] = new SimpleLine { Start = new System.Drawing.Point((int)xAnchor, yAxis), End = new System.Drawing.Point((int)xAnchor, (int)lineHeight) }; if (i % 10000 == 0) { System.Diagnostics.Debug.WriteLine("linesfromsamples, i is: " + i); } } return(sampleLines); }
static void processSimple(string filename) { var folder = BuildFolder(filename); var lines = SimpleLine .FromFile(filename) .OrderBy(x => x.Address); var groups = LineGroup.MakeGroups(lines); var missing = SourceProcessing.GetMissingOutput(groups, (x) => x.ToString()); File.WriteAllLines(Path.Combine(folder, "with-missing.txt"), missing); var bytecodes = SourceProcessing.GetBadBytecodeConversions(lines); File.WriteAllLines(Path.Combine(folder, "bad-bytecode-conversions.txt"), bytecodes); var allraw = SourceProcessing.GetAllRaw(lines, (x) => x.ToString()); File.WriteAllLines(Path.Combine(folder, "all-raw.txt"), allraw); var allrawOps = SourceProcessing.GetAllRaw(lines, (x) => x.ToLongString()); File.WriteAllLines(Path.Combine(folder, "all-raw-with-ops.txt"), allrawOps); // Code with labels and line breaks var labeled = SourceProcessing.LabelCode(allraw); File.WriteAllLines(Path.Combine(folder, "code-labeled.txt"), labeled); }
private void InitLines() { for (int i = 0; i < maxLineNumber; i++) { SimpleLine line = new SimpleLine(); lines.Add(line); } }
public override void EventFired(object sender, Event e) { if (e is StartEntitySelectionModeEvent start) { Source = start.Source; Callback = start.Callback; MultipleAllowed = start.MultipleLinks; Selected = start.Selected; Mode = MultipleAllowed ? Add : Single; ForbiddenLink = start.ForbiddenLink; foreach (long id in Selected) { ILine line = new SimpleLine(Source, EditorUtil.GetSelectionBounds(Owner.Entities[id]).Center, Color.Aqua, 4); Lines.Add(id, line); Owner.Events.InvokeEvent(new BeginOverlay(line)); } HoverOutline = new EntityOutline(Owner, 0) { Thickness = 4 }; Overlays.Add(HoverOutline); Owner.Events.InvokeEvent(new BeginOverlay(HoverOutline)); HoverLine = new SimpleLine(Source, Source, Color.CadetBlue, 4); Overlays.Add(HoverLine); Owner.Events.InvokeEvent(new BeginOverlay(HoverLine)); } else if (e is ModalChangeEvent changed) { ModalActive = true; CursorSystem.ModalActive = true; CursorSystem.DraggingEnabled = true; if (changed.From != "collision_face_view") { CursorSystem.SwitchToModal = changed.From; } } else if (e is BeginModalChangeEvent bmce) { bmce.SystemName = CursorSystem.SwitchToModal; ModalActive = false; CursorSystem.ModalActive = false; CursorSystem.DraggingEnabled = false; Callback(Selected); Callback = null; foreach (IOverlay overlay in Lines.Values) { Owner.Events.InvokeEvent(new RemoveOverlay(overlay)); } Lines.Clear(); foreach (IOverlay overlay in Overlays) { Owner.Events.InvokeEvent(new RemoveOverlay(overlay)); } Overlays.Clear(); } }
private void DrawLine(Canvas canvas, SimpleLine lineToDraw, Paint paint) { if (lineToDraw == null) { return; } canvas.DrawLine(lineToDraw.Start.X, lineToDraw.Start.Y, lineToDraw.End.X, lineToDraw.End.Y, paint); }
private void _Debug_ShowLine(SimpleLine line, Color color) { var visLine = ShapeManager.AddLine(); visLine.SetFromAbsoluteEndpoints(new Point3D(line.Start.X, line.Start.Y), new Point3D(line.End.X, line.End.Y)); visLine.Color = color; visLine.Visible = true; visLine.Z = 10f; }
private static void CreateShapeLine() { MovableLine zone = CreateGenericShape <MovableLine>("SHAPE: Line"); SimpleLine spline = LineEditor.CreateLineOnGameObject(zone.gameObject); UnityEditor.Editor splineEditorGeneric = UnityEditor.Editor.CreateEditor(zone, typeof(MovableLineEditor)); MovableLineEditor zoneEditor = (MovableLineEditor)splineEditorGeneric; zoneEditor.ConstructSplineZone(spline); }
public static void DefaultLineStyle() { //ExStart: DefaultLineStyle using (var map = new Map(500, 317)) { var symbolizer = new SimpleLine(); map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer); map.Render(dataDir + "lines_out.svg", Renderers.Svg); } //ExEnd: DefaultLineStyle }
private void AddLink(long id) { if (Selected.Contains(id)) { return; } Selected.Add(id); ILine line = new SimpleLine(Source, EditorUtil.GetSelectionBounds(Owner.Entities[id]).Center, Color.Aqua, 4); Lines.Add(id, line); Owner.Events.InvokeEvent(new BeginOverlay(line)); }
public static void ChangeLineStyle() { //ExStart: ChangeLineStyle using (var map = new Map(500, 317)) { var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer); map.Render(dataDir + "lines_out.svg", Renderers.Svg); } //ExEnd: ChangeLineStyle }
/// <summary> /// Helper. /// </summary> protected bool TrySelectLine(Matrix transformationMatrix, bool allowLineSegmentOnly, PointF linePoint1, PointF linePoint2, PointF location, float absoluteSelectionMargin) { float lineSegmentLocation; PointF intersectionPoint; SimpleLine line = new SimpleLine(linePoint1, linePoint2); float? distance = line.DistanceToPoint(location, out lineSegmentLocation, out intersectionPoint); if (MathHelper.GetAbsoluteDistance(transformationMatrix, location, intersectionPoint) <= absoluteSelectionMargin) {// Selection. return(allowLineSegmentOnly == false || (lineSegmentLocation >= 0 && lineSegmentLocation <= 1)); } return(false); }
public static void LinesLabelingFeatureBased() { //ExStart: LinesLabelingFeatureBased using (var map = new Map(1000, 634)) { var lineSymbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xae, 0xd9, 0xfd) }; lineSymbolizer.FeatureBasedConfiguration = (feature, symbolizer) => { if (feature.GetValue <string>("NAM") == "UNK") { symbolizer.Width = 1; symbolizer.Style = StrokeStyle.Dash; } }; var lineLabeling = new SimpleLabeling(labelAttribute: "name") { HaloSize = 1, Placement = new LineLabelPlacement { Alignment = LineLabelAlignment.Parallel, }, FontSize = 20, FeatureBasedConfiguration = (feature, labeling) => { if (feature.GetValue <string>("NAM") == "UNK") { // change labeling properties for some features. labeling.FontStyle = FontStyle.Italic; labeling.FontSize = 10; labeling.Priority = -1; var placement = (LineLabelPlacement)labeling.Placement; placement.Alignment = LineLabelAlignment.Curved; placement.Offset = 5; } } }; map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), lineSymbolizer, lineLabeling); map.Padding = 50; map.Render(dataDir + "lines_labeling_feature_based_out.svg", Renderers.Svg); } //ExEnd: LinesLabelingFeatureBased }
protected override void PopulateData() { using (var session = Domain.OpenSession()) using (var tx = session.OpenTransaction()) { var line = new Line(); line.ItemVersions.Add(new LineVersion()); line.ItemVersions.Add(new LineVersion()); new LineVersion(); var simpleLine = new SimpleLine(); simpleLine.ItemVersions.Add(new SimpleLineVersion()); simpleLine.ItemVersions.Add(new SimpleLineVersion()); new SimpleLineVersion(); tx.Complete(); } }
public static void LinesLabeling() { //ExStart: LinesLabeling using (var map = new Map(1000, 634)) { var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; var labeling = new SimpleLabeling(labelAttribute: "name"); map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer, labeling); map.Padding = 50; map.Render(dataDir + "lines_labeling_out.svg", Renderers.Svg); } //ExEnd: LinesLabeling }
// Update is called once per frame void Update() { // get our line object GameObject Augmentations = GameObject.Find("Augmentations"); SimpleLine line = Augmentations.GetComponent <SimpleLine>(); // get the line renderer and the start/end positions for setting the line collider LineRenderer lineRenderer = line.lineRenderer; Vector3 RenderStartPos = line.RenderStartPos; Vector3 RenderEndPos = line.RenderEndPos; float WidthMultiplier = lineRenderer.widthMultiplier; // get the collider we created BoxCollider lineCollider = GameObject.Find("Augmentations/Collider").GetComponent <BoxCollider>(); // the collider is the child of the line Debug.Log("Box Collider's parent is:" + lineCollider.transform.parent.name); lineCollider.transform.parent = lineRenderer.transform; // get the length of the line float lineLength = Vector3.Distance(RenderStartPos, RenderEndPos); Debug.Log("The length of the box collider is: " + lineLength.ToString()); // size of collider is set where X is the lenght of line, Y is the width of the line, Z will be set as per requirement lineCollider.size = new Vector3(lineLength, WidthMultiplier, 1f); // midpoint Vector3 midPoint = (RenderStartPos + RenderEndPos) / 2; // setting position of collider object lineCollider.transform.position = midPoint; Debug.Log("The central position of the box collider is: " + midPoint.ToString()); // calculate the angle between startPos and endPos using angle = atan(y/x) // calculate abs(y/x) float angle = (Mathf.Abs(RenderStartPos.y - RenderEndPos.y) / Mathf.Abs(RenderStartPos.x - RenderEndPos.x)); // when y/x is negative, we need to add -1 to the above abs(y/x) if ((RenderStartPos.y < RenderEndPos.y && RenderStartPos.x > RenderEndPos.x) || (RenderEndPos.y < RenderStartPos.y && RenderEndPos.x > RenderStartPos.x)) { angle *= -1; } // calculate the angle, notice that the Atan returns radians, which needs to be converted to degree angle = Mathf.Rad2Deg * Mathf.Atan(angle); // rotate the collider lineCollider.transform.Rotate(0, 0, angle); }
public static void ChangeLineStyleComplex() { //ExStart: ChangeLineStyleComplex using (var map = new Map(500, 317)) { var lineSymbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xae, 0xd9, 0xfd) }; lineSymbolizer.FeatureBasedConfiguration = (feature, symbolizer) => { if (feature.GetValue <string>("NAM") == "UNK") { symbolizer.Width = 1; symbolizer.Style = StrokeStyle.Dash; } }; map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), lineSymbolizer); map.Render(dataDir + "lines_out.svg", Renderers.Svg); } //ExEnd: ChangeLineStyleComplex }
public static LineSegment GetInternal(this SimpleLine interval) { return(interval.InternalObject as LineSegment); }
public override void Draw(GraphicsWrapper g, PointF?mousePosition, RectangleF clippingRectangle, RectangleF drawingSpace) { if (Visible == false) { return; } if (_controlPoints.Count < 1) { return; } PointF point1 = _controlPoints[0]; PointF point2; if (mousePosition.HasValue) { point2 = mousePosition.Value; } else { point2 = point1; } if (_controlPoints.Count == 2) { point2 = _controlPoints[1]; } // Clipping opitmization. RectangleF rectangle = new RectangleF( Math.Min(point1.X, point2.X), Math.Min(point1.Y, point2.Y), Math.Abs(point2.X - point1.X), Math.Abs(point2.Y - point1.Y)); if (rectangle.IntersectsWith(clippingRectangle) == false) { return; } SimpleLine line = new SimpleLine(point1, point2); PointF vec = new PointF(line.XDelta, line.YDelta); vec = g.DrawingSpaceToActualSpace(vec, false); vec = new PointF(vec.Y, vec.X); // Rotate PointF vec1 = SimpleLine.RotatePoint(vec, -(float)Math.PI / 2 + 0.3f); PointF vec2 = SimpleLine.RotatePoint(vec, -(float)Math.PI / 2 - 0.3f); // Scale vec1 = new PointF(vec1.X * 0.35f, vec1.Y * 0.35f); vec2 = new PointF(vec2.X * 0.35f, vec2.Y * 0.35f); vec1 = g.ActualSpaceToDrawingSpace(vec1, false); vec2 = g.ActualSpaceToDrawingSpace(vec2, false); g.DrawLine(_pen, point1, point2); g.FillPolygon(_brush, new PointF[] { point2, new PointF(point2.X + vec1.X, point2.Y + vec1.Y), new PointF(point2.X + vec2.X, point2.Y + vec2.Y) }); if (Selected) { DrawControlPoints(g); } }
// Update is called once per frame void Update() { // get our line object GameObject Augmentations = GameObject.Find("Augmentations"); SimpleLine line = Augmentations.GetComponent <SimpleLine>(); // get the line renderer and the start/end positions for setting the line collider LineRenderer lineRenderer = line.lineRenderer; Vector3 RenderStartPos = line.RenderStartPos; Vector3 RenderEndPos = line.RenderEndPos; float WidthMultiplier = lineRenderer.widthMultiplier; // update the laser start position LaserStartPos = RenderEndPos; // Direction should align with the virtual needle direction LaserDirection = RenderEndPos - RenderStartPos; RaycastHit hitInfo; // check if the ray hits the spatial mapping mesh bool hit = Physics.Raycast(LaserStartPos, LaserDirection, out hitInfo, 30.0f, SpatialMapping.PhysicsRaycastMask); if (hit) { // Debug.Log("The laser hits the spatial mesh"); // put the entry point there float dist; if (!placing) { PlacingPosition = hitInfo.point; entryRing.transform.position = PlacingPosition; // Rotate the ring to hug the surface of the hologram Rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal); entryRing.transform.rotation = Rotation; // update the permanent position and rotation information PermanentPosition = PlacingPosition; PermanentRotation = Rotation; // distance between the hit position and the laser start position dist = hitInfo.distance; } else { entryRing.transform.position = PermanentPosition; entryRing.transform.rotation = PermanentRotation; // distance between the ring position and needle tip position dist = Vector3.Distance(PermanentPosition, LaserStartPos); } // determine the distance between the hit position and the laser start position DistanceText = GameObject.Find("ARDisplayHUD/DistToSurface").GetComponent <Text>(); DistanceText.text = "Distance from tip to surface: " + dist.ToString(); lineRendererIn = GameObject.Find("Augmentations/LineIn").GetComponent <LineRenderer>(); lineRendererOut = GameObject.Find("Augmentations/LineOut").GetComponent <LineRenderer>(); // points for occluded part of needle var pointsIn = new Vector3[2]; pointsIn[0] = new Vector3((float)(PlacingPosition.x - 0.005), PlacingPosition.y, PlacingPosition.z); pointsIn[1] = RenderEndPos; // points for outside part of needle var pointsOut = new Vector3[2]; pointsOut[0] = RenderStartPos; pointsOut[1] = new Vector3((float)(PlacingPosition.x - 0.005), PlacingPosition.y, PlacingPosition.z); // gradient color for occluded part of needle lineRendererIn.material.SetFloat("_TopLine", RenderStartPos.y); lineRendererIn.material.SetFloat("_BottomLine", RenderEndPos.y); // if the distance is closed to zero, mark it as inserted and go to the second mode if (dist < 0.02) { isInserted = true; } // if they are too further away, go back to not inserted stage if (dist > 0.3) { isInserted = false; } if (isInserted) { // Debug.Log("Inserted!!!!!!!!!"); // disable the previous linerenderer lineRenderer.enabled = false; // render two lines lineRendererIn.SetPositions(pointsIn); lineRendererOut.SetPositions(pointsOut); lineRendererIn.enabled = true; lineRendererOut.enabled = true; } else { // Debug.Log("Not Inserted"); if (lineRendererIn.enabled == true && lineRendererOut.enabled == true) { lineRendererIn.enabled = false; lineRendererOut.enabled = false; } if (lineRenderer.enabled == false) { lineRenderer.enabled = true; } } } }
private void button6_Click(object sender, EventArgs e) { var sample = new SimpleLine(); sample.ShowDialog(); }
/// <summary> /// Helper - extends the given line segment to the ends of the drawing space. /// </summary> protected void StretchSegmentToDrawingSpace(ref PointF point1, ref PointF point2, RectangleF drawingSpace) { //if (_controlPoints.Count < 2) //{ // return; //} SimpleLine thisLine = new SimpleLine(point1, point2); PointF?[] intersectionPoints = new PointF?[4]; // The order is important, so preserve it. intersectionPoints[0] = thisLine.Intersection(new SimpleLine(new PointF(drawingSpace.X, drawingSpace.Y), new PointF(drawingSpace.X, drawingSpace.Y + drawingSpace.Width))); intersectionPoints[1] = thisLine.Intersection(new SimpleLine(new PointF(drawingSpace.X + drawingSpace.Width, drawingSpace.Y), new PointF(drawingSpace.X + drawingSpace.Width, drawingSpace.Y + drawingSpace.Width))); intersectionPoints[2] = thisLine.Intersection(new SimpleLine(new PointF(drawingSpace.X, drawingSpace.Y), new PointF(drawingSpace.X + drawingSpace.Height, drawingSpace.Y))); intersectionPoints[3] = thisLine.Intersection(new SimpleLine(new PointF(drawingSpace.X, drawingSpace.Y + drawingSpace.Height), new PointF(drawingSpace.X + drawingSpace.Height, drawingSpace.Y + drawingSpace.Height))); if (intersectionPoints[0].HasValue == false) {// Parallel to the 0,0 / 0, 10 line. point1 = new PointF(point1.X, drawingSpace.Y); point2 = new PointF(point1.X, drawingSpace.Y + drawingSpace.Height); return; } else if (intersectionPoints[1].HasValue == false) {// Parallel to the 0,0 / 10, 0 line. point1 = new PointF(drawingSpace.X, point1.Y); point2 = new PointF(drawingSpace.X + drawingSpace.Width, point1.Y); return; } // Establish the best 2 points (shortest line = best performance). int pointIndex1 = -1, pointIndex2 = -1; for (int i = 0; i < intersectionPoints.Length; i++) { if (intersectionPoints[i].HasValue == false) { continue; } // Is the point within drawing space (Contains baseMethod does not deliver needed results). float xCalculationErrorMargin = (drawingSpace.X + drawingSpace.Width) / 100; float yCalculationErrorMargin = (drawingSpace.Y + drawingSpace.Height) / 100; if (intersectionPoints[i].Value.X <drawingSpace.X - xCalculationErrorMargin || intersectionPoints[i].Value.X> drawingSpace.X + drawingSpace.Width + xCalculationErrorMargin || intersectionPoints[i].Value.Y <drawingSpace.Y - yCalculationErrorMargin || intersectionPoints[i].Value.Y> drawingSpace.Y + drawingSpace.Height + yCalculationErrorMargin) {// Point outside. continue; } // Point approved. if (pointIndex1 < 0) { pointIndex1 = i; } else { pointIndex2 = i; break; } } if (pointIndex1 < 0 || pointIndex2 < 0) { //SystemMonitor.Error("This scenario should not happen."); pointIndex1 = 0; pointIndex2 = 1; } point1 = intersectionPoints[pointIndex1].Value; point2 = intersectionPoints[pointIndex2].Value; }