private void buttonOpen_Click(object sender, EventArgs e) { pictureBox8.Visible = true; pictureBox8.Image = Image.FromFile("D:/1f.gif"); if (open.ShowDialog() == DialogResult.OK) { q.bitmap = new Bitmap(open.FileName); } pictureBox1.Image = q.bitmap; q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.CreateBitmapList(); isDrow = false; isFirst = false; isFirstPoligon = false; Eraser = false; Pipetka = false; textBox3.Visible = false; fill = false; isTop = false; isHanded = false; isZoom = false; isTurn = false; isFigureChanged = false; drowing = true; isColorChanged = false; isGran = false; isThicknessChange = false; toolStripDropDownButton2.Image = topToolStripMenuItem.Image; Fill = null; toolStripDropDownButton1.Image = безЗаливкиToolStripMenuItem.Image; isCollapsed = false; q.heigth = pictureBox1.Height; q.width = pictureBox1.Width; pictureBox8.Visible = false; }
protected GraphicsBase(int x, int y, int width, int height, IFill fill, params GraphicOption[] options) : this(width, height, options) { Left = x; Top = y; Fill = fill; }
private void deleteAll_Click(object sender, EventArgs e) { isDrow = false; isFirst = false; isFirstPoligon = true; q.bitFigure = new Bitmap(pictureBox1.Width, pictureBox1.Height); q.bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = q.bitmap; q.CreateBitmapList(); q.tmp1 = new Bitmap(pictureBox1.Width, pictureBox1.Height); Eraser = false; Pipetka = false; fill = false; textBox3.Visible = false; isTop = false; isHanded = false; isZoom = false; isColorChanged = false; isFigureChanged = false; drowing = true; isTop = false; isTurn = false; isGran = false; toolStripDropDownButton2.Image = topToolStripMenuItem.Image; Fill = null; toolStripDropDownButton1.Image = безЗаливкиToolStripMenuItem.Image; }
private void displayFill_CheckedChanged(object sender, EventArgs e) { if (m_inUpdate) { return; } if (fillStyleEditor.displayFill.Checked) { m_item.Fill = previousFill ?? _factory.CreateDefaultFill(); } else { if (m_item.Fill != null) { previousFill = m_item.Fill; } m_item.Fill = null; } UpdatePreviewResult(); if (Changed != null) { Changed(this, new EventArgs()); } }
/// <summary> /// Merges partial styles. /// </summary> public static void Merge(PartialFontStyle style1, PartialFontStyle style2, float weight, out IFill fill, out Pen pen) { if (style1 == null && style2 == null) { fill = null; pen = null; return; } if (style2 != null && style1 == null) { Merge(style2, style1, 1.0f - weight, out fill, out pen); return; } if (style2 == null) { fill = style1.Fill; pen = style1.Pen; return; } fill = BlendedFill.BlendFills(style1.Fill, style2.Fill, weight); pen = Pen.BlendPens(style1.Pen, style2.Pen, weight); return; }
public Drower(Brush brush, IFigur figur, IFill fill) { this.brush = brush; this.figure = figur; this.fill = fill; points = new List <Point>(); }
/// <summary> /// Blends two fills. /// </summary> public static IFill BlendFills(IFill first, IFill second, float alpha) { // Some quick helpers. if (first == second) { return(first); } if (first == null) { return(second); } if (second == null) { return(first); } if (MathHelper.NearEqual(alpha, 0.0f) || alpha < 0.0f) { return(first); } if (MathHelper.NearEqual(alpha, 1.0f) || alpha > 1.0f) { return(second); } if (first is SolidFill && second is SolidFill) { return(new SolidFill(new Colour((first as SolidFill).Colour.RGBA * (1.0f - alpha) + (second as SolidFill).Colour.RGBA * alpha))); } // TODO: other special case. else { return(new BlendedFill(first, second, alpha)); } }
/// <summary> /// Creates a <c>DrawStyle</c> with a specific pen & fill color. /// </summary> /// <param name="c">The color for the pen & the fill</param> public DrawStyle(Color c) { m_Pen = new Pen(c); m_Fill = new Fill(c); m_Path = new GraphicsPath(); m_PointHeight = new Length(1.0); m_IsFixedStyle = false; }
public void SetFillColor(float r, float g, float b, float a = 1) { m_CurrentFill = new SolidFill() { Color = new Color(r, g, b, a) }; m_FillColor = new Color(r, g, b, a); }
/// <summary> /// A constructor for non-outline font. /// </summary> public FontStyle(Font font, float size, float lineSpacing, TextOptions options, IFill fill) { this.font = font; this.size = size; this.lineSpacing = lineSpacing; this.options = options; this.fill = fill; }
public void FillShape(IFill fill, IArea2f shape, IMapper mapper) { TriangleSoup2f soup = new TriangleSoup2f(); shape.Tesselate(-info.TesselationResolution, soup); FillShape(fill, soup, mapper); }
/// <summary> /// A pen from fill and width. /// </summary> /// <param name="fill">The fill.</param> /// <param name="width">The width.</param> public Pen([NotNull] IFill fill, [MinFloat(0.0f)] float canvasWidth, [MinFloat(0.0f)] float pixelWidth, OutlineEnd endMode) { this.fill = fill; this.widthInCanvas = canvasWidth; this.widthInPixels = pixelWidth; this.lineEnd = endMode; }
public bool Equals(IFill other) { if (other is ImageFill) { ImageFill fill = (ImageFill)other; return(true); } return(false); }
/// <summary> /// Prepares and renders, with customized line starts and lengths. /// </summary> public TextRenderInfo Render(IFill fill, ICanvas canvas, string text, float fontSize, TextOptions optons, Vector2f[] lineStarts, float[] lineLengths) { TextRenderInfo info = Prepare(canvas, text, fontSize, optons, lineStarts, lineLengths); info.Render(fill); return(info); }
// TODO: other preparations /// <summary> /// Prepares and renders, with rectange range. /// </summary> public TextRenderInfo Render(IFill fill, ICanvas canvas, string text, float fontSize, TextOptions options, float lineSpacing, Vector2f leftBottom, Vector2f size) { TextRenderInfo info = Prepare(canvas, text, fontSize, options, lineSpacing, leftBottom, size); info.Render(fill); return(info); }
private void choosePen_Click(object sender, EventArgs e) { abstractFabric = new LineFabric(); Eraser = false; textBox3.Visible = false; Pipetka = false; fill = false; Fill = null; }
public CreatedFigure(Brush brush, IFigur figur, IFill fill) { this.brush = brush; this.figur = figur; this.fill = fill; poin = new List <Point>(); centr = new Point(); f = new Point(); l = new Point(); }
private void button5_Click(object sender, EventArgs e) { abstractFabric = new FigureFabric(); Figure = new Poligon(); textBox3.Visible = true; Eraser = false; Pipetka = false; fill = false; Fill = null; toolStripDropDownButton1.Image = безЗаливкиToolStripMenuItem.Image; }
public ContextProxy(Graphics s, Bitmap bitmap, Pen stroke, IFill fill, bool visible, ICanvasProxy canvasElement) : base(Guid.NewGuid()) { _target = new CanvasRenderingContext2D(s, bitmap, stroke, fill, visible, canvasElement); _target.OnPartialDraw += new OnPartialDrawHanlder(_target_OnPartialDraw); ////////// // Add all members with dispids from the concrete type ////////// base.AddIntrinsicMembers(); _canvasElement = canvasElement; }
private void button4_BackColorChanged(object sender, EventArgs e) { if (Fill is TwoColorFill) { Fill = new TwoColorFill(button4.BackColor); } else if (Fill is SolidFill) { Fill = new SolidFill(button4.BackColor); } }
public static void RenderBorderAndArea(ICanvas canvas, IShapef shape, IPathf border, Area.AreaStyle style, Area.AreaStyle nextStyle, float alpha) { // We first fill background. { // We create background fill. ITransform mappingTransform; IMapper mapper; IFill fill = BackgroundStyle.Merge(style != null ? style.Background : null, nextStyle != null ? nextStyle.Background : null, alpha, out mappingTransform, out mapper); if (fill != null) { if (mappingTransform != null) { canvas.TextureTransform = mappingTransform; } // We fill shape canvas.FillShape(fill, shape, mapper); // Must reset. if (mappingTransform != null) { canvas.TextureTransform = null; } } } // Now we add border over it. { ITransform transform; IMapper mapper; Pen pen = BorderStyle.Merge(style != null ? style.Border : null, nextStyle != null ? nextStyle.Border : null, alpha, out transform, out mapper); if (pen != null && pen.Fill != null) { if (transform != null) { canvas.TextureTransform = transform; } canvas.DrawShape(pen, border, mapper); if (transform != null) { canvas.TextureTransform = null; } } } }
public bool Equals(IFill other) { if (other is SolidFill) { SolidFill fill = (SolidFill)other; if (fill.colour != colour) { return(false); } return(true); } return(false); }
private void button2_Click(object sender, EventArgs e) { Figure = null; abstractFabric = new UncommonPoligon(); textBox3.Visible = false; Eraser = false; Pipetka = false; fill = false; isFirstPoligon = true; Fill = null; toolStripDropDownButton1.Image = безЗаливкиToolStripMenuItem.Image; drower = abstractFabric.CreateDrower(Figure, brush, Fill); }
public ShaderCompiler.Operand[] Compile(ShaderCompiler compiler, ShaderCompiler.Operand[] operands, FixedShaderParameters parameters, ref SharpMedia.Graphics.Shaders.Operations.DualShareContext shareContext) { // We obtain interfaces (CPU resolve). object[] interfaces = InterfaceHelper.ResolveInterfaceArray(inputs[4], parameters); // We first register all our "constants" (for fill IDs). ShaderCompiler.Operand[] integerConstants = new ShaderCompiler.Operand[interfaces.Length]; for (int i = 0; i < integerConstants.Length; i++) { integerConstants[i] = compiler.CreateFixed(PinFormat.Integer, Pin.NotArray, i); } // We pack out "attributes". ShaderCompiler.Operand[] attributes = new ShaderCompiler.Operand[] { operands[2] }; // We create output colour constant. ShaderCompiler.Operand outColour = compiler.CreateTemporary(PinFormat.Floatx4, Pin.NotArray); // We switch compiler.BeginSwitch(operands[3]); // We go through all interfaces. for (int i = 0; i < interfaces.Length; i++) { compiler.BeginCase(integerConstants[i]); // We cast to fill. IFill fill = interfaces[i] as IFill; ShaderCompiler.Operand[] constants = InterfaceHelper.RegisterInterfaceConstants(compiler, string.Format("Fills[{0}]", i), parameters, fill); fill.Compile(compiler, operands[0], operands[1], attributes, null, constants, outColour); compiler.EndCase(); } // We also add "default" handler. compiler.BeginDefault(); compiler.Mov(compiler.CreateFixed(PinFormat.Floatx4, Pin.NotArray, new Math.Vector4f(1.0f, 0.0f, 0.0f, 1.0f)), outColour); compiler.EndCase(); // And end switch. compiler.EndSwitch(); return(new ShaderCompiler.Operand[] { outColour }); }
public bool Equals(IFill other) { if (other is TextureFill) { TextureFill fill = (TextureFill)other; if (!fill.SamplerState.Equals(SamplerState)) { return(false); } if (fill.texture != texture) { return(false); } return(true); } return(false); }
public bool Equals(IFill other) { if (object.ReferenceEquals(this, other)) { return(true); } if (other.GetType() == typeof(BlendedFill)) { BlendedFill other2 = other as BlendedFill; if (other2.alpha == this.alpha && other2.fill1.Equals(fill1) && other2.fill2.Equals(fill1)) { return(true); } } return(false); }
public static void RenderFill(LittleSharpRenderEngine engine, Graphics graphics, System.Drawing.Drawing2D.GraphicsPath path, IFill fill) { Brush brush; if (fill.Pattern != null) { //TODO: Make this return; } else { //TODO: Hatch style brush = new System.Drawing.SolidBrush(fill.ForegroundColor); } using(brush) if (fill.Pattern == null) graphics.FillPath(brush, path); }
/// <summary> /// Merges font styles. /// </summary> /// <returns></returns> public static Font Merge(FontStyle style1, FontStyle style2, float weight, out float size, out float lineSpacing, out TextOptions options, out Pen pen, out IFill fill) { // No font. if (style1 == null && style2 == null) { size = 0; lineSpacing = 0; options = TextOptions.None; pen = null; fill = null; return(null); } // Special case second style only. if (style1 == null && style2 != null) { return(Merge(style2, style1, 1.0f - weight, out size, out lineSpacing, out options, out pen, out fill)); } if (style1 != null && style2 == null) { size = style1.Size; lineSpacing = style1.LineSpacing; options = style1.TextOptions; pen = style1.Pen; fill = style1.Fill; return(style1.Font); } float w1 = 1.0f - weight; size = style1.Size * w1 + style2.Size * weight; lineSpacing = style1.LineSpacing * w1 + style2.LineSpacing * weight; options = style1.TextOptions; pen = Pen.BlendPens(style1.Pen, style2.Pen, weight); fill = BlendedFill.BlendFills(style1.Fill, style2.Fill, weight); return(style1.Font); }
public bool Equals(IFill other) { if (other is RadialFill) { RadialFill fill = (RadialFill)other; if (!Vector2f.NearEqual(fill.centerPosition, centerPosition)) { return(false); } if (innerColour != fill.innerColour) { return(false); } if (outerColour != fill.outerColour) { return(false); } return(true); } return(false); }
/// <summary> /// Renders filled characters. /// </summary> /// <param name="fill"></param> /// <param name="range"></param> public void Render(IFill fill, Vector2i range) { if (range.Y < range.X) { return; } ValidateRange(range); canvas.Begin(CanvasRenderFlags.SoftwarePositionTransform); try { for (int i = range.X; i <= range.Y; i++) { RenderGlyphInfo info = glyphs[i]; if (glyphs[i].RenderingData == null) { continue; } // We set transform. canvas.Transform = new LinearTransform( Matrix4x4f.CreateTranslate(info.LeftBottom.Vec3) * Matrix4x4f.CreateScale(new Vector3f(fontSize, fontSize, fontSize)) ); // We finally render. TriangleSoup2f soup = info.RenderingData.AcquireFilled(canvas.CanvasInfo.TesselationResolution); canvas.FillShape(fill, soup, info.AttachedMapper); } } finally { canvas.End(); } }
public override bool Equals(IFill other) { if (other is Gradient4Fill) { Gradient4Fill fill = (Gradient4Fill)other; if (fill.texcoordMixing != texcoordMixing) { return(false); } if (this.colours.Length != fill.colours.Length) { return(false); } // We compare all colours. for (int i = 0; i < colours.Length; i++) { if (colours[i] != fill.colours[i]) { return(false); } } for (int j = 0; j < positions.Length; j++) { if (positions[j] != fill.positions[j]) { return(false); } } return(true); } return(false); }
public Ellipse(IFill fill, params GraphicOption[] options) : base(fill, options) { }
public Ellipse(IFill fill, IStroke stroke) : base(fill, stroke) { }
public Fractal(IFill fill, params GraphicOption[] options) : base(fill, options) { }
/// <summary> /// Reset Canvas fields to their initial value. /// </summary> private void reset() { SetDefaultValues(); _stroke = _initialConfig.Stroke; _fill = _initialConfig.Fill; SetLineConfig(_initialConfig.Stroke); }
protected GraphicsBase(IFill fill, params GraphicOption[] options) : this(options) { Fill = fill; }
public override Drower CreateDrower(IFigur selectedFigur, Brush brush, IFill fill) { abstractDrower = new ClassLine(brush, null, null); return(abstractDrower); }
public Rect(int width, int height, IFill fill, params GraphicOption[] options) : base(width, height, fill, options) { }
public Rect(IFill fill, IStroke stroke) : base(fill, stroke) { }
public Rect(IFill fill, params GraphicOption[] options) : base(fill, options) { }
public Fractal(int width, int height, IFill fill, IStroke stroke, params GraphicOption[] options) : base(width, height, fill, stroke, options) { }
private void displayFill_CheckedChanged(object sender, EventArgs e) { if (m_inUpdate) return; if (m_item.Symbol.Type == PointSymbolType.Mark) { if (fillStyleEditor.displayFill.Checked) ((IMarkSymbol)m_item.Symbol).Fill = previousFill == null ? _factory.CreateDefaultFill() : previousFill; else { if (((IMarkSymbol)m_item.Symbol).Fill != null) previousFill = ((IMarkSymbol)m_item.Symbol).Fill; ((IMarkSymbol)m_item.Symbol).Fill = null; } } UpdatePreviewResult(); if (Changed != null) Changed(this, new EventArgs()); }
public Fractal(int x, int y, int width, int height, IFill fill, params GraphicOption[] options) : base(x, y, width, height, fill, options) { }
protected GraphicsBase(int width, int height, IFill fill, IStroke stroke, params GraphicOption[] options) : this(width, height, options) { Fill = fill; Stroke = stroke; }
public Rect(int x, int y, int width, int height, IFill fill, IStroke stroke, params GraphicOption[] options) : base(x, y, width, height, fill, stroke, options) { }
public Rect(IFill fill, IStroke stroke, params GraphicOption[] options) : base(fill, stroke, options) { }
protected GraphicsBase(IFill fill, IStroke stroke, params GraphicOption[] options) :this(options) { Fill = fill; Stroke = stroke; }
private void displayFill_CheckedChanged(object sender, EventArgs e) { if (m_inUpdate) return; if (fillStyleEditor.displayFill.Checked) m_item.Fill = previousFill == null ? _factory.CreateDefaultFill() : previousFill; else { if (m_item.Fill != null) previousFill = m_item.Fill; m_item.Fill = null; } UpdatePreviewResult(); if (Changed != null) Changed(this, new EventArgs()); }
/// <summary> /// Create CanvasRenderingContext. Graphics and Bitmap passed into constructor should be related to each other /// </summary> /// <param name="s">Graphics object to get resolution and size data from</param> /// <param name="stroke">initial Pen configuration</param> /// <param name="fill">initial Brush configuration</param> /// <param name="visible">determing is this object be visible inside container</param> public CanvasRenderingContext2D(Graphics s, Bitmap bitmap, Pen stroke, IFill fill, bool visible) { var width = (int) s.VisibleClipBounds.Width; var height = (int) s.VisibleClipBounds.Height; _visible = visible; SetLineConfig(stroke); surface = s; _surfaceBitmap = bitmap; _stroke = stroke; _fill = fill; SetDefaultValues(); //TODO: investigate how can we get all data from fill and stroke to CanvasRenderingContext2D properties //or just avoid such parameters in constructor strokeStyle = "rgba(" + stroke.Color.R + "," + stroke.Color.G + "," + stroke.Color.B + "," + stroke.Color.A + ")"; fillStyle = "rgba(" + fill.color.R + "," + fill.color.G + "," + fill.color.B + "," + fill.color.A + ")"; _initialConfig = new CanvasConfig(stroke.Clone() as Pen, fill.Clone() as Fill); OnPartialDraw += CanvasRenderingContext2D_OnPartialDraw; }
public Fractal(IFill fill, IStroke stroke) : base(fill, stroke) { }
public CanvasRenderingContext2D(Graphics s, Bitmap bitmap, Pen stroke, IFill fill, bool visible, ICanvasProxy canvasElement) : this(s, bitmap, stroke, fill, visible) { _canvasElement = canvasElement; }
public Triangle(IFill fill, params GraphicOption[] options) : base(fill, options) { }