public SearchResultNode(IDocument document, SearchResult result) { drawDefault = false; this.result = result; startPosition = result.GetStartPosition(document); Point endPosition = result.GetEndPosition(document); positionText = "(" + (startPosition.Y + 1) + ", " + (startPosition.X + 1) + ") "; LineSegment line = document.GetLineSegment(startPosition.Y); drawableLine = new DrawableLine(document, line, RegularMonospacedFont, BoldMonospacedFont); drawableLine.SetBold(0, drawableLine.LineLength, false); if (startPosition.Y == endPosition.Y) { drawableLine.SetBold(startPosition.X, endPosition.X, true); } specialText = result.DisplayText; if (specialText != null) { displayText = positionText + specialText; } else { displayText = positionText + document.GetText(line).Replace("\t", " "); } Text = displayText; }
// Start is called before the first frame update void Start() { m_DrawableLine = GetComponent <DrawableLine>(); m_DrawableArea = GetComponent <DrawableArea>(); m_DrawableVolume = GetComponent <DrawableVolume>(); m_DrawableSphere = GetComponent <DrawableSphere>(); m_DrawablePolygon = GetComponent <DrawablePolygon>(); // For introduction m_DrawableVolume.AddListener(() => { mIntroductionScript.CheckVolume(m_DrawableVolume.m_LastCreatedShape.transform, DrawableVolume.m_SubdivisionScale); }, DrawableVolume.ListenerType.PostFinish); m_CurrentTool = Tool.None; // m_ToolText = GameObject.Find("ActiveToolText").GetComponent<Text>(); mIntroductionScript = FindObjectOfType <IntroductionScript>(); UpdateGridScale(); GlobalGridScale.AddScaleListener(UpdateGridScale); m_Line = m_Shape.transform.Find("Line").gameObject; m_Area = m_Shape.transform.Find("Area").gameObject; m_Volume = m_Shape.transform.Find("Volume").gameObject; m_Mesh = m_Shape.transform.Find("Mesh").gameObject; m_PointerController = m_Pointer.GetComponent <PointerController>(); penInput = FindObjectOfType <PenInputController>(); initialPenPosition = penInput.transform.position; deleteTool = FindObjectOfType <DeleteToolOld>(); initialDeleteToolPosition = deleteTool.transform.position; }
public DrawableSpectrum(string filePath) { this.Player = new AudioPlayback(); this.Analyser = new ShortTimeFourierTransform(filePath, FFT_LENGTH, 0.01); this.Player.Load(filePath, FFT_LENGTH, Analyser); this.Analyser.Processed += Analyser_Processed; int gap = Analyser.WaveFormat.SampleRate / Analyser.FFTLength; if (gap == 0) { gap = 1; } int linesCount = Physics.GetScaledFFTLength(MAX_FREQUENCY, Analyser.FFTLength, Analyser.WaveFormat.SampleRate); this.Lines = new DrawableLine[linesCount]; for (int i = 0; i < Lines.Length; i++) { Lines[i] = new DrawableLine(new Vector2(), new Vector2(), Color.White); } Width = linesCount * PIXEL_GAP; this.Rectangle = new Rectangle(Position.X, Position.Y, Width, HEIGHT); }
public void OnRenderObject() { CreateLineMaterial(); lineMaterial.SetPass(0); GL.PushMatrix(); //GL.MultMatrix(Matrix4x4.identity); GL.MultMatrix(transform.localToWorldMatrix); GL.Begin(GL.LINES); for (int i = 0; i < _linesToDraw.Count; i++) { DrawableLine line = _linesToDraw[i]; GL.Color(line.color); GL.Vertex3(line.a[0], line.a[1], line.a[2]); GL.Vertex3(line.b[0], line.b[1], line.b[2]); } GL.End(); GL.PopMatrix(); _linesToDraw.Clear(); }
public static PointToLineDistance GetClosestPointOnLineSegment(Point point, DrawableLine line) { var P = new Vector(point.X, point.Y); var A = new Vector(line.X1, line.Y1); var B = new Vector(line.X2, line.Y2); var AP = P - A; //Vector from A to P var AB = B - A; //Vector from A to B var magnitudeAB = AB.LengthSquared; //Magnitude of AB vector (it's length squared) var ABAPproduct = Vector.Multiply(AP, AB); //The DOT product of a_to_p and a_to_b var distance = ABAPproduct / magnitudeAB; //The normalized "distance" from a to your closest point if (distance < 0) //Check if P projection is over vectorAB { var pointOnLine = AsPoint(A); return(new PointToLineDistance(Distance(point, pointOnLine), pointOnLine)); } if (distance > 1) { var pointOnLine = AsPoint(B); return(new PointToLineDistance(Distance(point, pointOnLine), pointOnLine)); } else { var pointOnLine = AsPoint(A + AB * distance); return(new PointToLineDistance(Distance(point, pointOnLine), pointOnLine)); } }
private void LoadShapesToCanvas(CanvasControl canvas, IEnumerable <LoadedShape> shapes) { canvas.PreLoad(); foreach (LoadedShape shape in shapes) { Pen pen = CreatePen(shape); string shapeTypeUpper = shape.ShapeType.ToUpperInvariant(); switch (shapeTypeUpper) { case "LINE": DrawableLine line = CreateDrawableLine(shape, pen); canvas.AddLine(line); break; case "RECTANGLE": DrawableRectangle rectangle = CreateDrawableRectangle(shape, pen); canvas.AddRectangle(rectangle); break; case "ELLIPSE": DrawableEllipse ellipse = CreateDrawableEllipse(shape, pen); canvas.AddEllipse(ellipse); break; } } canvas.ResetView(); }
public static void MoveLineTo(DrawableLine line, DrawableLine targetLocation) { line.Line.X1 = targetLocation.Line.X1; line.Line.X2 = targetLocation.Line.X2; line.Line.Y1 = targetLocation.Line.Y1; line.Line.Y2 = targetLocation.Line.Y2; }
public void OnEditModeActivated(DrawableLine source, LineDragEventArgs e) { if (e.Direction is LineResizeGrip.DragDirection.Start) { LineUtilities.ChangeDirection(PreviewLine.Line); } PreviewLine.Show(); }
public static void ChangeDirection(DrawableLine line) { var start = StartPoint(line); line.X1 = line.X2; line.Y1 = line.Y2; line.X2 = start.X; line.Y2 = start.Y; }
static void Main(string[] args) { DrawableCircle circle = new DrawableCircle(0, 0, 3); DrawableLine line = new DrawableLine(0, 0, 1, 1); DrawableRectangle rectangle = new DrawableRectangle(5, 5, 2, 2); DrawableRing ring = new DrawableRing(3, 4, 5, 2); DrawableRound round = new DrawableRound(2, 8, 8); VectorGraphicsEditor.Draw(circle, line, rectangle, ring, round); }
private void OnLineDragged(DrawableLine source, MouseButtonEventArgs e) { if (source is SnappableLine line) { _lineManager.MoveLine(line, LineUtilities.StartPoint(line.Line), e.GetPosition(_grid)); } else { source.Move(LineUtilities.StartPoint(source.Line), e.GetPosition(_grid)); } }
public Sensor() { Radius = 2; Origin = new Vector2f(2, 2); FillColor = Color.Yellow; Angle = 0; Distance = 0; Line = new DrawableLine(Simulation.Robot.Position, Position); ID = 0; HasFoundPoint = false; PreviousCloudPoint = CloudPoint = new CloudPoint(); }
/// <summary> /// Sets the core to use with this editor /// </summary> /// <param name="core">The Streamline Core to use</param> public void SetCore(StreamlineCore core) { // Subscribe to everything needed in the core _core = core; _core.OnBlockAdded += (e, o) => CreateBlock(o); _core.OnBlockDeleted += (e, o) => DeleteBlock(o); _core.OnBlocksConnected += (e, o) => ConnectBlocks(o.Item1, o.Item2); _core.OnBlocksDisconnected += (e, o) => DisconnectBlocks(o.Item1, o.Item2); _core.OnBlockEnabled += (e, o) => Render(); _core.OnBlockDisabled += (e, o) => Render(); _core.OnSchematicLoad += (e, o) => Render(); //_core.OnBlockActivated += (e, o) => SetBlockActive(o); // Create the line that is displayed when connecting component _movingLine = new DrawableLine(core, Vector3.Zero, Vector3.Zero); _movingLine.Visible = false; _renderables.Add(_movingLine.Z, _movingLine); }
public void LineNoize() { var rnd = new Random((int)Environment.TickCount); var count = rnd.Next(6 * Math.Max(_current.Width, _current.Height)); for (int i = 0; i < count; i++) { var x1 = rnd.Next(0, _current.Width); var y1 = rnd.Next(0, _current.Height); var x2 = rnd.Next(-25, 25); var y2 = rnd.Next(-25, 25); byte[] rgb = new byte[3]; rnd.NextBytes(rgb); DrawableFillColor fillColor = new DrawableFillColor(MagickColor.FromRgb(rgb[0], rgb[1], rgb[2])); DrawableLine dl = new DrawableLine(x1, y1, x1 + x2, y1 + y2); _current.Draw(fillColor, dl); } }
public override void MouseUp(MouseEventArgs e) { if (IsDrawing) { IsDrawing = false; // Mouse up means that we want to draw our final result, so we longer need creation shapes. CreationDrawable = null; // The final drawn result. DrawableLine line = GetDrawableLine(true); // Add final result to the Canvas. if (line.StartPoint != line.EndPoint) { Canvas.AddLine(line); } RepaintCanvas(); } }
public static double LengthOf(DrawableLine line) { return(Distance(line.StartPoint, line.EndPoint)); }
public static Point StartPoint(DrawableLine line) { return(new Point(line.X1, line.Y1)); }
public IActionResult Index(PosterModel model) { string originalImage = Path.Combine(webrootPath, "images", "large_Event_Poster_Pasta.png"); string newFilePath = Path.Combine(webrootPath, "images", "poster_with_data.png"); string pdffile = Path.Combine(webrootPath, "images", "poster_with_data.pdf"); string font = Path.Combine(webrootPath, "fonts", "TGSharpSans-Medium.ttf"); string extraBoldFont = Path.Combine(webrootPath, "fonts", "TGSharpSans-Semibold.ttf"); string thinFont = Path.Combine(webrootPath, "fonts", "TGSharpSans-Thin.ttf"); using (MagickImage image = new MagickImage(originalImage)) { // image.Draw(drawables); var readSettings = new MagickReadSettings { FillColor = MagickColors.Black, BackgroundColor = MagickColors.Transparent, // TextGravity = Gravity.Center, Width = 400, StrokeColor = MagickColors.Black, Font = extraBoldFont, FontPointsize = 36, }; using (var caption = new MagickImage($"caption: {model.EventName.Replace('~','\n').ToUpper()}", readSettings)) { image.Composite(caption, 100, 500, CompositeOperator.Over); } readSettings.Font = font; using (var caption = new MagickImage($"caption: {model.EventDate.Replace('~', '\n').ToUpper()}", readSettings)) { image.Composite(caption, 100, 600, CompositeOperator.Over); } readSettings.FontPointsize = 18; using (var caption = new MagickImage($"caption: {model.Location.Replace('~', '\n').ToUpper()}", readSettings)) { image.Composite(caption, 100, 650, CompositeOperator.Over); } DrawableLine line = new DrawableLine(100, 700, 600, 700); image.Draw(line); readSettings.FontPointsize = 14; readSettings.Width = 200; readSettings.Font = thinFont; using (var caption = new MagickImage($"caption: {model.Explanation}", readSettings)) { image.Composite(caption, 100, 725, CompositeOperator.Over); } using (var caption = new MagickImage($"caption: {model.AdditionalDetails}", readSettings)) { image.Composite(caption, 400, 725, CompositeOperator.Over); } //var eventNameDrawable = new Drawables() // .Font(@"H:\publicH\Downloads\TenderGreensSharpSans-Extrabold.woff2",FontStyleType.Bold,FontWeight.Bold, FontStretch.Normal) // .FontPointSize(72) // .StrokeColor(MagickColors.Black) // .Text(100,600, model.EventName.ToUpper()) // .Draw(image); //var drawable = new Drawables() // //.FontPointSize(72) // //.Font(extraBoldFont) // //.StrokeColor(MagickColors.Black) // //.TextAlignment(TextAlignment.Left) // // .Text(100, 600, model.EventName.ToUpper()) // .FontPointSize(36) // .Font(font) // .StrokeColor(MagickColors.Black) // .TextAlignment(TextAlignment.Left) // .Text(100, 700, model.EventDate.ToUpper()) // .Text(100, 800, model.Location.ToUpper()) // //.StrokeColor(new MagickColor(0, Quantum.Max, 0)) // //.FillColor(MagickColors.SaddleBrown) // //.Ellipse(256, 96, 192, 8, 0, 360) // .Draw(image); image.Write(newFilePath); model.ImageSrc = "/images/poster_with_data.png"; image.Write(pdffile); //ExifProfile profile = image.GetExifProfile(); //if (profile == null) { // ViewData["Message"] = "Image does not contain exif information"; //} //else { // string message = ""; // foreach (ExifValue value in profile.Values) { // message += $"{value.Tag} ({value.DataType}): {value.ToString()}<br />"; // } //} } return(View(model)); }
private void OnLineDrag(DrawableLine source, LineDragEventArgs e) { _grid.MouseMove += e.ResizeGrip.OnMouseMove; e.ResizeGrip.MouseUp += _previewLineManager.OnEditModeDeactivated; }
public static Point EndPoint(DrawableLine line) { return(new Point(line.X2, line.Y2)); }