public override void SetClippingRect(RectangleDouble clippingRect) { cachedClipRect = clippingRect; GL.Scissor((int)Math.Floor(Math.Max(clippingRect.Left, 0)), (int)Math.Floor(Math.Max(clippingRect.Bottom, 0)), (int)Math.Ceiling(Math.Max(clippingRect.Width, 0)), (int)Math.Ceiling(Math.Max(clippingRect.Height, 0))); GL.Enable(EnableCap.ScissorTest); }
public bool Equals(RectangleDouble other, double epsilon) { return Math.Abs(Left - other.Left) <= epsilon && Math.Abs(Bottom - other.Bottom) <= epsilon && Math.Abs(Right - other.Right) <= epsilon && Math.Abs(Top - other.Top) <= epsilon; }
public PlayfieldView(RectangleDouble bounds) { BoundsRelativeToParent = bounds; GameImageSequence menuButtonSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "MenuButtonFromGame"); Button menuButton = new Button(400, 12, new ButtonViewThreeImage(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2))); AddChild(menuButton); menuButton.Click += new Button.ButtonEventHandler(EscapeMenu); }
public override void OnDraw(Graphics2D graphics2D) { int thumbHeight = 10; //graphics2D.Rectangle(LocalBounds, RGBA_Bytes.Black); double bottom = textScrollWidget.Position0To1 * (Height - thumbHeight);// the 2 is the border RectangleDouble thumb = new RectangleDouble(0, bottom, Width, bottom + thumbHeight);// the 1 is the border graphics2D.FillRectangle(thumb, RGBA_Bytes.DarkGray); base.OnDraw(graphics2D); }
public CreditsMenu(RectangleDouble bounds) { BoundsRelativeToParent = bounds; GameImageSequence cancelButtonSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "NumPlayersCancelButton"); Button cancelGameButton = new Button(400, 200, new ButtonViewThreeImage(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2))); AddChild(cancelGameButton); cancelGameButton.Click += new Button.ButtonEventHandler(OnCancelMenuButton); }
public static bool bounding_rect_single(IVertexSource vs, int path_id, ref RectangleDouble rect) { double x1, y1, x2, y2; bool rValue = bounding_rect_single(vs, path_id, out x1, out y1, out x2, out y2); rect.Left = x1; rect.Bottom = y1; rect.Right = x2; rect.Top = y2; return rValue; }
public blur() { m_rbuf2 = new ImageBuffer(); m_shape_bounds = new RectangleDouble(); m_method = new RadioButtonGroup(new Vector2(10.0, 10.0), new Vector2(130.0, 60.0)); m_radius = new Slider(new Vector2(130 + 10.0, 10.0 + 4.0), new Vector2(290, 8.0)); m_shadow_ctrl = new PolygonEditWidget(4); m_channel_r = new CheckBox(10.0, 80.0, "Red"); m_channel_g = new CheckBox(10.0, 95.0, "Green"); m_channel_b = new CheckBox(10.0, 110.0, "Blue"); m_FlattenCurves = new CheckBox(10, 315, "Convert And Flatten Curves"); m_FlattenCurves.Checked = true; AddChild(m_method); m_method.AddRadioButton("Stack Blur"); m_method.AddRadioButton("Recursive Blur"); m_method.AddRadioButton("Channels"); m_method.SelectedIndex = 1; AddChild(m_radius); m_radius.SetRange(0.0, 40.0); m_radius.Value = 15.0; m_radius.Text = "Blur Radius={0:F2}"; AddChild(m_shadow_ctrl); AddChild(m_channel_r); AddChild(m_channel_g); AddChild(m_channel_b); AddChild(m_FlattenCurves); m_channel_g.Checked = true; m_sl = new ScanlineCachePacked8(); StyledTypeFace typeFaceForLargeA = new StyledTypeFace(LiberationSansFont.Instance, 300, flatenCurves: false); m_path = typeFaceForLargeA.GetGlyphForCharacter('a'); Affine shape_mtx = Affine.NewIdentity(); shape_mtx *= Affine.NewTranslation(150, 100); m_path = new VertexSourceApplyTransform(m_path, shape_mtx); m_shape = new FlattenCurves(m_path); bounding_rect.bounding_rect_single(m_shape, 0, ref m_shape_bounds); m_shadow_ctrl.SetXN(0, m_shape_bounds.Left); m_shadow_ctrl.SetYN(0, m_shape_bounds.Bottom); m_shadow_ctrl.SetXN(1, m_shape_bounds.Right); m_shadow_ctrl.SetYN(1, m_shape_bounds.Bottom); m_shadow_ctrl.SetXN(2, m_shape_bounds.Right); m_shadow_ctrl.SetYN(2, m_shape_bounds.Top); m_shadow_ctrl.SetXN(3, m_shape_bounds.Left); m_shadow_ctrl.SetYN(3, m_shape_bounds.Top); m_shadow_ctrl.line_color(new RGBA_Floats(0, 0.3, 0.5, 0.3)); }
public RandomFillWidget(Point2D size) { LocalBounds = new RectangleDouble(0, 0, size.x, size.y); image = new ImageBuffer(size.x, size.y, 32, new BlenderBGRA()); Random rand = new Random(); Graphics2D imageGraphics = image.NewGraphics2D(); for (int i = 0; i < 30; i++) { imageGraphics.Circle(rand.NextDouble() * image.Width, rand.NextDouble() * image.Height, rand.NextDouble() * 10 + 5, RGBA_Bytes.Red); } }
private RectangleDouble GetTrackBounds() { RectangleDouble trackBounds; if (sliderAttachedTo.Orientation == Orientation.Horizontal) { trackBounds = new RectangleDouble(0, -TrackHeight / 2, sliderAttachedTo.TotalWidthInPixels, TrackHeight / 2); } else { trackBounds = new RectangleDouble(-TrackHeight / 2, 0, TrackHeight / 2, sliderAttachedTo.TotalWidthInPixels); } return trackBounds; }
public WindowWidget(RectangleDouble InBounds) { int sizeOfDragBar = 20; BackgroundColor = RGBA_Bytes.White; OriginRelativeParent = new Vector2(InBounds.Left, InBounds.Bottom); LocalBounds = new RectangleDouble(0, 0, InBounds.Width, InBounds.Height); DragBarColor = RGBA_Bytes.LightGray; dragBar = new TitleBarWidget(new RectangleDouble(0, InBounds.Height - sizeOfDragBar, InBounds.Width, InBounds.Height)); //dragBar.DebugShowBounds = true; base.AddChild(dragBar); //clientArea.DebugShowBounds = true; base.AddChild(clientArea); }
public RayTraceWidget(int width = 200, int height = 200) { trackballTumbleWidget = new TrackballTumbleWidget(); trackballTumbleWidget.DoOpenGlDrawing = false; trackballTumbleWidget.DrawRotationHelperCircle = false; //trackballTumbleWidget.DrawGlContent += trackballTumbleWidget_DrawGlContent; trackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; AddChild(trackballTumbleWidget); totalTime.Start(); CreateScene(); LocalBounds = new RectangleDouble(0, 0, width, height); trackballTumbleWidget.TrackBallController.Scale = .03; trackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(0, 0, MathHelper.Tau / 16))); trackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(-MathHelper.Tau * .19, 0, 0))); trackballTumbleWidget.AnchorAll(); }
public override void OnDraw(Agg.Graphics2D graphics2D) { RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, this.borderRadius); graphics2D.Render(rectBorder, borderColor); RectangleDouble insideBounds = Bounds; insideBounds.Inflate(-this.borderWidth); RoundedRect rectInside = new RoundedRect(insideBounds, Math.Max(this.borderRadius - this.borderWidth, 0)); graphics2D.Render(rectInside, this.fillColor); if (this.isUnderlined) { //Printer.TypeFaceStyle.DoUnderline = true; RectangleDouble underline = new RectangleDouble(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Bottom); graphics2D.Rectangle(underline, buttonText.TextColor); } base.OnDraw(graphics2D); }
public void ExpandToInclude(RectangleDouble rectToInclude) { if (Right < rectToInclude.Right) { Right = rectToInclude.Right; } if (Top < rectToInclude.Top) { Top = rectToInclude.Top; } if (Left > rectToInclude.Left) { Left = rectToInclude.Left; } if (Bottom > rectToInclude.Bottom) { Bottom = rectToInclude.Bottom; } }
public void unite_rectangles(RectangleDouble r1, RectangleDouble r2) { Left = r1.Left; Bottom = r1.Bottom; Right = r1.Right; Right = r1.Top; if (Right < r2.Right) { Right = r2.Right; } if (Top < r2.Top) { Top = r2.Top; } if (Left > r2.Left) { Left = r2.Left; } if (Bottom > r2.Bottom) { Bottom = r2.Bottom; } }
public HowManyPlayersMenu(RectangleDouble bounds) { BoundsRelativeToParent = bounds; GameImageSequence onePlayerButtonSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "OnePlayerButton"); Button onePlayerGameButton = new Button(270, 310, new ButtonViewThreeImage(onePlayerButtonSequence.GetImageByIndex(0), onePlayerButtonSequence.GetImageByIndex(1), onePlayerButtonSequence.GetImageByIndex(2))); AddChild(onePlayerGameButton); onePlayerGameButton.Click += new EventHandler(OnStartOnePlayerGameButton); GameImageSequence twoPlayerButtonSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "TwoPlayerButton"); Button twoPlayerGameButton = new Button(400, 310, new ButtonViewThreeImage(twoPlayerButtonSequence.GetImageByIndex(0), twoPlayerButtonSequence.GetImageByIndex(1), twoPlayerButtonSequence.GetImageByIndex(2))); AddChild(twoPlayerGameButton); twoPlayerGameButton.Click += new EventHandler(OnStartTwoPlayerGameButton); GameImageSequence fourPlayerButtonSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "FourPlayerButton"); Button fourPlayerGameButton = new Button(530, 310, new ButtonViewThreeImage(fourPlayerButtonSequence.GetImageByIndex(0), fourPlayerButtonSequence.GetImageByIndex(1), fourPlayerButtonSequence.GetImageByIndex(2))); AddChild(fourPlayerGameButton); fourPlayerGameButton.Click += new EventHandler(OnStartFourPlayerGameButton); GameImageSequence cancelButtonSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "NumPlayersCancelButton"); Button cancelGameButton = new Button(400, 210, new ButtonViewThreeImage(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2))); AddChild(cancelGameButton); cancelGameButton.Click += new EventHandler(OnCancelMenuButton); }
public bool clip(RectangleDouble r) { if (Right > r.Right) { Right = r.Right; } if (Top > r.Top) { Top = r.Top; } if (Left < r.Left) { Left = r.Left; } if (Bottom < r.Bottom) { Bottom = r.Bottom; } return(Left <= Right && Bottom <= Top); }
public override void Clear(IColorType iColor) { RectangleDouble clippingRect = GetClippingRect(); var clippingRectInt = new RectangleInt((int)clippingRect.Left, (int)clippingRect.Bottom, (int)clippingRect.Right, (int)clippingRect.Top); if (DestImage != null) { var color = iColor.ToColor(); byte[] buffer = DestImage.GetBuffer(); switch (DestImage.BitDepth) { case 8: { for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset] = color.blue; bufferOffset += bytesBetweenPixels; } } } break; case 24: for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; bufferOffset += bytesBetweenPixels; } } break; case 32: { for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++) { int bufferOffset = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y); int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; buffer[bufferOffset + 3] = color.alpha; bufferOffset += bytesBetweenPixels; } } } break; default: throw new NotImplementedException(); } DestImage.MarkImageChanged(); } else // it is a float { if (DestImageFloat == null) { throw new Exception("You have to have either a byte or float DestImage."); } var color = iColor.ToColorF(); int height = DestImageFloat.Height; float[] buffer = DestImageFloat.GetBuffer(); switch (DestImageFloat.BitDepth) { case 128: for (int y = 0; y < height; y++) { int bufferOffset = DestImageFloat.GetBufferOffsetXY(clippingRectInt.Left, y); int bytesBetweenPixels = DestImageFloat.GetFloatsBetweenPixelsInclusive(); for (int x = 0; x < clippingRectInt.Width; x++) { buffer[bufferOffset + 0] = color.blue; buffer[bufferOffset + 1] = color.green; buffer[bufferOffset + 2] = color.red; buffer[bufferOffset + 3] = color.alpha; bufferOffset += bytesBetweenPixels; } } break; default: throw new NotImplementedException(); } } }
public override void SetClippingRect(RectangleDouble clippingRect) { Rasterizer.SetVectorClipBox(clippingRect); }
public override void OnDraw(Agg.Graphics2D graphics2D) { base.OnDraw(graphics2D); if (this.isUnderlined) { //Printer.TypeFaceStyle.DoUnderline = true; RectangleDouble underline = new RectangleDouble(LocalBounds.Left, LocalBounds.Bottom, LocalBounds.Right, LocalBounds.Bottom); graphics2D.Rectangle(underline, this.TextColor); } }
private void ScaleMeshToView(List<MeshGroup> loadedMeshGroups) { if (loadedMeshGroups != null) { AxisAlignedBoundingBox meshBounds = GetAxisAlignedBoundingBox(loadedMeshGroups); bool done = false; double scallFraction = .1; RectangleDouble goalBounds = new RectangleDouble(0, 0, size.x, size.y); goalBounds.Inflate(-10); while (!done) { RectangleDouble partScreenBounds = GetScreenBounds(meshBounds); if (!NeedsToBeSmaller(partScreenBounds, goalBounds)) { trackballTumbleWidget.TrackBallController.Scale *= (1 + scallFraction); partScreenBounds = GetScreenBounds(meshBounds); // If it crossed over the goal reduct the amount we are adjusting by. if (NeedsToBeSmaller(partScreenBounds, goalBounds)) { scallFraction /= 2; } } else { trackballTumbleWidget.TrackBallController.Scale *= (1 - scallFraction); partScreenBounds = GetScreenBounds(meshBounds); // If it crossed over the goal reduct the amount we are adjusting by. if (!NeedsToBeSmaller(partScreenBounds, goalBounds)) { scallFraction /= 2; if (scallFraction < .001) { done = true; } } } } } }
public void Rectangle(RectangleDouble rect, RGBA_Bytes color, double strokeWidth = 1) { Rectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, color, strokeWidth); }
public void SetVectorClipBox(RectangleDouble clippingRect) { SetVectorClipBox(clippingRect.Left, clippingRect.Bottom, clippingRect.Right, clippingRect.Top); }
public void unite_rectangles(RectangleDouble r1, RectangleDouble r2) { Left = r1.Left; Bottom = r1.Bottom; Right = r1.Right; Right = r1.Top; if (Right < r2.Right) Right = r2.Right; if (Top < r2.Top) Top = r2.Top; if (Left > r2.Left) Left = r2.Left; if (Bottom > r2.Bottom) Bottom = r2.Bottom; }
public void ExpandToInclude(RectangleDouble rectToInclude) { if (Right < rectToInclude.Right) Right = rectToInclude.Right; if (Top < rectToInclude.Top) Top = rectToInclude.Top; if (Left > rectToInclude.Left) Left = rectToInclude.Left; if (Bottom > rectToInclude.Bottom) Bottom = rectToInclude.Bottom; }
private bool PartsAreInPrintVolume() { if (ActiveSliceSettings.Instance != null && !ActiveSliceSettings.Instance.CenterOnBed() && ActivePrinterProfile.Instance.ActivePrinter != null) { AxisAlignedBoundingBox allBounds = MeshViewerWidget.GetAxisAlignedBoundingBox(MeshGroups); bool onBed = allBounds.minXYZ.z > -.001 && allBounds.minXYZ.z < .001; // really close to the bed RectangleDouble bedRect = new RectangleDouble(0, 0, ActiveSliceSettings.Instance.BedSize.x, ActiveSliceSettings.Instance.BedSize.y); bedRect.Offset(ActiveSliceSettings.Instance.BedCenter - ActiveSliceSettings.Instance.BedSize / 2); bool inBounds = bedRect.Contains(new Vector2(allBounds.minXYZ)) && bedRect.Contains(new Vector2(allBounds.maxXYZ)); return onBed && inBounds; } return true; }
/// <summary> /// Draws an arc representing a portion of an ellipse specified by a Rectangle structure. /// </summary> /// <param name="color">The color to draw in.</param> /// <param name="rect">Structure that defines the boundaries of the ellipse.</param> /// <param name="startAngle">Angle in degrees measured clockwise from the x-axis to the starting point of the arc.</param> /// <param name="sweepAngle">Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.</param> public void DrawArc(Color color, RectangleDouble rect, int startAngle, int sweepAngle) { throw new NotImplementedException(); }
public void SavingFunction() { currentlySaving = true; countThatHaveBeenSaved = 0; // first create images for all the parts foreach (FileNameAndPresentationName stlFileNames in stlFilesToPrint) { Mesh loadedMesh = StlProcessing.Load(stlFileNames.fileName); if (loadedMesh != null) { AxisAlignedBoundingBox aabb = loadedMesh.GetAxisAlignedBoundingBox(); RectangleDouble bounds2D = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y); double widthInMM = bounds2D.Width + PartMarginMM * 2; double textSpaceMM = 5; double heightMM = textSpaceMM + bounds2D.Height + PartMarginMM * 2; TypeFacePrinter typeFacePrinter = new TypeFacePrinter(stlFileNames.presentationName, 28, Vector2.Zero, Justification.Center, Baseline.BoundsCenter); double sizeOfNameX = typeFacePrinter.GetSize().x + PartMarginPixels * 2; Vector2 sizeOfRender = new Vector2(widthInMM * PixelPerMM, heightMM * PixelPerMM); ImageBuffer imageOfPart = new ImageBuffer((int)(Math.Max(sizeOfNameX, sizeOfRender.x)), (int)(sizeOfRender.y), 32, new BlenderBGRA()); typeFacePrinter.Origin = new Vector2(imageOfPart.Width / 2, (textSpaceMM / 2) * PixelPerMM); Graphics2D partGraphics2D = imageOfPart.NewGraphics2D(); RectangleDouble rectBounds = new RectangleDouble(0, 0, imageOfPart.Width, imageOfPart.Height); double strokeWidth = .5 * PixelPerMM; rectBounds.Inflate(-strokeWidth / 2); RoundedRect rect = new RoundedRect(rectBounds, PartMarginMM * PixelPerMM); partGraphics2D.Render(rect, RGBA_Bytes.LightGray); Stroke rectOutline = new Stroke(rect, strokeWidth); partGraphics2D.Render(rectOutline, RGBA_Bytes.DarkGray); PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh, new Vector2(-bounds2D.Left + PartMarginMM, -bounds2D.Bottom + textSpaceMM + PartMarginMM), PixelPerMM, RGBA_Bytes.Black); partGraphics2D.Render(typeFacePrinter, RGBA_Bytes.Black); partImagesToPrint.Add(new PartImage(imageOfPart)); } countThatHaveBeenSaved++; if (UpdateRemainingItems != null) { UpdateRemainingItems(this, new StringEventArgs(Path.GetFileName(stlFileNames.presentationName))); } } partImagesToPrint.Sort(BiggestToLittlestImages); PdfDocument document = new PdfDocument(); document.Info.Title = "MatterHackers Parts Sheet"; document.Info.Author = "MatterHackers Inc."; document.Info.Subject = "This is a list of the parts that are in a queue from MatterControl."; document.Info.Keywords = "MatterControl, STL, 3D Printing"; int nextPartToPrintIndex = 0; int plateNumber = 1; bool done = false; while (!done && nextPartToPrintIndex < partImagesToPrint.Count) { PdfPage pdfPage = document.AddPage(); CreateOnePage(plateNumber++, ref nextPartToPrintIndex, pdfPage); } try { // save the final document document.Save(pathAndFileToSaveTo); // Now try and open the document. This will lanch whatever PDF viewer is on the system and ask it // to show the file (at least on Windows). Process.Start(pathAndFileToSaveTo); } catch (Exception) { } OnDoneSaving(); currentlySaving = false; }
public void Rectangle(RectangleDouble rect, Color color, double strokeWidth = 1) { Rectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, color, strokeWidth); }
public override void OnMouseUp(MouseEventArgs mouseEvent) { int boxSize = 20; // Handle errors in the touch panel that push touch event positions to the screen edge by // proxying all clicks in the target region back into the desired control RectangleDouble topRightHitbox = new RectangleDouble(this.Width - boxSize, this.Height - boxSize, this.Width, this.Height); if (topRightHitbox.Contains(mouseEvent.Position) && this.MouseCaptured) { setupButton.ClickButton(null); return; } base.OnMouseUp(mouseEvent); }
public override void SetClippingRect(RectangleDouble clippingRect) { Rasterizer.SetVectorClipBox(clippingRect); }
public bool IsTouching(RectangleDouble rectToIntersectWith) { RectangleDouble temp = this; return(temp.IntersectWithRectangle(rectToIntersectWith)); }
public abstract void SetClippingRect(RectangleDouble rect_d);
private bool NeedsToBeSmaller(RectangleDouble partScreenBounds, RectangleDouble goalBounds) { if (partScreenBounds.Bottom < goalBounds.Bottom || partScreenBounds.Top > goalBounds.Top || partScreenBounds.Left < goalBounds.Left || partScreenBounds.Right > goalBounds.Right) { return true; } return false; }
public void FillRectangle(RectangleDouble rect, IColorType fillColor) { FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor); }
public static bool get_bounding_rect(PathStorage vs, int[] gi, int start, int num, out RectangleDouble boundingRect) { return(get_bounding_rect(vs, gi, start, num, out boundingRect.Left, out boundingRect.Bottom, out boundingRect.Right, out boundingRect.Top)); }
public abstract void SetClippingRect(RectangleDouble rect_d);
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage); clippingProxy.clear(new ColorF(1, 1, 1)); m_ras.SetVectorClipBox(0, 0, Width, Height); Affine move = Affine.NewTranslation(10, 10); Perspective shadow_persp = new Perspective(m_shape_bounds.Left, m_shape_bounds.Bottom, m_shape_bounds.Right, m_shape_bounds.Top, m_shadow_ctrl.polygon()); IVertexSource shadow_trans; if (m_FlattenCurves.Checked) { shadow_trans = new VertexSourceApplyTransform(m_shape, shadow_persp); } else { shadow_trans = new VertexSourceApplyTransform(m_path, shadow_persp); // this will make it very smooth after the transform //shadow_trans = new conv_curve(shadow_trans); } // Render shadow m_ras.add_path(shadow_trans); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new ColorF(0.2, 0.3, 0).ToColor()); // Calculate the bounding box and extend it by the blur radius RectangleDouble bbox = new RectangleDouble(); bounding_rect.bounding_rect_single(shadow_trans, 0, ref bbox); bbox.Left -= m_radius.Value; bbox.Bottom -= m_radius.Value; bbox.Right += m_radius.Value; bbox.Top += m_radius.Value; if (m_method.SelectedIndex == 1) { // The recursive blur method represents the true Gaussian Blur, // with theoretically infinite kernel. The restricted window size // results in extra influence of edge pixels. It's impossible to // solve correctly, but extending the right and top areas to another // radius value produces fair result. //------------------ bbox.Right += m_radius.Value; bbox.Top += m_radius.Value; } stopwatch.Restart(); if (m_method.SelectedIndex != 2) { // Create a new pixel renderer and attach it to the main one as a child image. // It returns true if the attachment succeeded. It fails if the rectangle // (bbox) is fully clipped. //------------------ #if SourceDepth24 ImageBuffer image2 = new ImageBuffer(new BlenderBGR()); #else ImageBuffer image2 = new ImageBuffer(new BlenderBGRA()); #endif if (image2.Attach(widgetsSubImage, (int)bbox.Left, (int)bbox.Bottom, (int)bbox.Right, (int)bbox.Top)) { // Blur it if (m_method.SelectedIndex == 0) { // More general method, but 30-40% slower. //------------------ //m_stack_blur.blur(pixf2, agg::uround(m_radius.Value)); // Faster, but bore specific. // Works only for 8 bits per channel and only with radii <= 254. //------------------ stack_blur test = new stack_blur(); test.Blur(image2, agg_basics.uround(m_radius.Value), agg_basics.uround(m_radius.Value)); } else { // True Gaussian Blur, 3-5 times slower than Stack Blur, // but still constant time of radius. Very sensitive // to precision, doubles are must here. //------------------ m_recursive_blur.blur(image2, m_radius.Value); } } } else { /* * // Blur separate channels * //------------------ * if(m_channel_r.Checked) * { * typedef agg::pixfmt_alpha_blend_gray< * agg::blender_gray8, * agg::rendering_buffer, * 3, 2> pixfmt_gray8r; * * pixfmt_gray8r pixf2r(m_rbuf2); * if(pixf2r.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) * { * agg::stack_blur_gray8(pixf2r, agg::uround(m_radius.Value), * agg::uround(m_radius.Value)); * } * } * * if(m_channel_g.Checked) * { * typedef agg::pixfmt_alpha_blend_gray< * agg::blender_gray8, * agg::rendering_buffer, * 3, 1> pixfmt_gray8g; * * pixfmt_gray8g pixf2g(m_rbuf2); * if(pixf2g.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) * { * agg::stack_blur_gray8(pixf2g, agg::uround(m_radius.Value), * agg::uround(m_radius.Value)); * } * } * * if(m_channel_b.Checked) * { * typedef agg::pixfmt_alpha_blend_gray< * agg::blender_gray8, * agg::rendering_buffer, * 3, 0> pixfmt_gray8b; * * pixfmt_gray8b pixf2b(m_rbuf2); * if(pixf2b.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) * { * agg::stack_blur_gray8(pixf2b, agg::uround(m_radius.Value), * agg::uround(m_radius.Value)); * } * } */ } double tm = stopwatch.ElapsedMilliseconds; // Render the shape itself //------------------ if (m_FlattenCurves.Checked) { m_ras.add_path(m_shape); } else { m_ras.add_path(m_path); } scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new ColorF(0.6, 0.9, 0.7, 0.8).ToColor()); graphics2D.DrawString(string.Format("{0:F2} ms", tm), 140, 30); base.OnDraw(graphics2D); }
public void FillRectangle(RectangleDouble rect, IColorType fillColor) { FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor); }
public bool clip(RectangleDouble r) { if (Right > r.Right) Right = r.Right; if (Top > r.Top) Top = r.Top; if (Left < r.Left) Left = r.Left; if (Bottom < r.Bottom) Bottom = r.Bottom; return Left <= Right && Bottom <= Top; }
private double PrintTopOfPage(ImageBuffer plateInventoryImage, Graphics2D plateGraphics) { plateGraphics.Clear(RGBA_Bytes.White); double currentlyPrintingHeightPixels = plateInventoryImage.Height - PageMarginMM.Top * PixelPerMM; string logoPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PartSheetLogo.png"); if(File.Exists(logoPathAndFile)) { ImageBuffer logoImage = new ImageBuffer(); ImageIO.LoadImageData(logoPathAndFile, logoImage); currentlyPrintingHeightPixels -= logoImage.Height; plateGraphics.Render(logoImage, (plateInventoryImage.Width - logoImage.Width) / 2, currentlyPrintingHeightPixels); } currentlyPrintingHeightPixels -= PartPaddingPixels; double underlineHeightMM = 1; RectangleDouble lineBounds = new RectangleDouble(0, 0, plateInventoryImage.Width - PageMarginPixels.Left * 2, underlineHeightMM * PixelPerMM); lineBounds.Offset(PageMarginPixels.Left, currentlyPrintingHeightPixels - lineBounds.Height); plateGraphics.FillRectangle(lineBounds, RGBA_Bytes.Black); return currentlyPrintingHeightPixels - (lineBounds.Height + PartPaddingPixels); }
public bool Contains(RectangleDouble innerRect) { if (Contains(innerRect.Left, innerRect.Bottom) && Contains(innerRect.Right, innerRect.Top)) { return true; } return false; }
public ViewGcodeWidget(Vector2 gridSizeMm, Vector2 gridCenterMm) { this.gridSizeMm = gridSizeMm; this.gridCenterMm = gridCenterMm; LocalBounds = new RectangleDouble(0, 0, 100, 100); DoubleBuffer = true; AnchorAll(); }
public bool IntersectWithRectangle(RectangleDouble rectToIntersectWith) { if (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left; if (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom; if (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right; if (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top; if (Left < Right && Bottom < Top) { return true; } return false; }