public static BlendFuncFactor ToBlendFuncFactor(Blend format) { switch(format) { case Blend.DestinationAlpha : return BlendFuncFactor.DstAlpha; case Blend.DestinationColor : return BlendFuncFactor.DstColor; case Blend.InverseBlendFactor : throw new NotSupportedException(); case Blend.InverseDestinationAlpha : return BlendFuncFactor.OneMinusDstAlpha; case Blend.InverseDestinationColor : return BlendFuncFactor.OneMinusDstColor; case Blend.InverseSourceAlpha : return BlendFuncFactor.OneMinusSrcAlpha; case Blend.InverseSourceColor : return BlendFuncFactor.OneMinusSrcColor; case Blend.One : return BlendFuncFactor.One; case Blend.SourceAlpha : return BlendFuncFactor.SrcAlpha; case Blend.SourceAlphaSaturation : return BlendFuncFactor.SrcAlphaSaturate; case Blend.SourceColor : return BlendFuncFactor.SrcColor; case Blend.Zero : return BlendFuncFactor.Zero; } throw new NotImplementedException(); }
public void SetRenderState() { Device d3dDevice = GuiController.Instance.D3dDevice; //Customizo el renderState d3dDevice.RenderState.ZBufferWriteEnable = false; //AlphaBlend d3dDevice.RenderState.AlphaBlendEnable = true; d3dDevice.RenderState.SourceBlend = Blend.SourceAlpha; blend = d3dDevice.RenderState.DestinationBlend; d3dDevice.RenderState.DestinationBlend = Blend.One; d3dDevice.SetTextureStageState(0, TextureStageStates.AlphaOperation, true); d3dDevice.RenderState.BlendFactor = Color.Black; //Seteo el formato a mostar en pantalla d3dDevice.VertexFormat = CustomVertex.PositionColored.Format; //Atributos del pointSprite d3dDevice.RenderState.PointSpriteEnable = true; d3dDevice.RenderState.PointScaleEnable = true; d3dDevice.RenderState.PointSizeMin = 0f; d3dDevice.RenderState.PointScaleA = 0f; d3dDevice.RenderState.PointScaleB = 0f; d3dDevice.RenderState.PointScaleC = 10f; d3dDevice.RenderState.PointSize = 100f; }
// Constructor public ParticleEmitter() { Name = ""; LifeSpan = 5.0f; MaxParticles = 50; SpawnRate = 0.01f; SpawnRange = new Rectangle(248, 248, 32, 32); NumParticlesToSpit = 1; Gravity = Vector2.Zero; GravitationalPull = 0.0f; ParticleTextures = new List<ParticleTexture>(); AliveParticles = new List<Particle>(); DeadParticles = new List<Particle>(); for (short i = 0; i < MaxParticles; ++i) DeadParticles.Add(new Particle()); StartColor = Color.DarkOrange; EndColor = Color.Firebrick; SourceBlend = Blend.SourceAlpha; DestinationBlend = Blend.One; StartVelocity = new Vector2(0.0f, -200.0f); EndVelocity = Vector2.Zero; StartScale = 1.0f; EndScale = 0.0f; StartRotation = 0.0f; EndRotation = 0.0f; ParticleDuration = 0.5f; ParticleDurationMax = 1.0f; }
public static void PaintBackground(Graphics graphics, Rectangle rectangle, Color colorLight, Color colorDark, Blend blend) { LinearGradientBrush BackgroundBrush = new LinearGradientBrush(rectangle, colorLight, colorDark, LinearGradientMode.Vertical); if (blend != null) { BackgroundBrush.Blend = blend; } graphics.FillRectangle(BackgroundBrush, rectangle); BackgroundBrush.Dispose(); }
/// <summary> /// Creates new instance of blend state /// </summary> /// <param name="mask"></param> /// <param name="src"></param> /// <param name="dst"></param> /// <param name="srcA"></param> /// <param name="dstA"></param> public static BlendState Create ( ColorChannels mask=ColorChannels.All, Blend src = Blend.One, Blend dst = Blend.Zero, Blend srcA = Blend.One, Blend dstA = Blend.Zero ) { BlendState bs = new BlendState(); bs.SrcColor = src; bs.DstColor = dst; bs.SrcAlpha = srcA; bs.DstAlpha = dstA; bs.ColorOp = BlendOp.Add; bs.AlphaOp = BlendOp.Add; bs.WriteMask = mask; bs.MultiSampleMask = -1; bs.BlendFactor = new Color4(0,0,0,0); return bs; }
private static Blend ToAlphaBlend(Blend blend) { switch (blend) { case Blend.SourceColor: return Blend.SourceAlpha; case Blend.InverseSourceColor: return Blend.InverseSourceAlpha; case Blend.DestinationColor: return Blend.DestinationAlpha; case Blend.InverseDestinationColor: return Blend.InverseDestinationAlpha; } return blend; }
private BlendState( string name, Blend colorSourceBlend, Blend alphaSourceBlend, Blend colorDestBlend, Blend alphaDestBlend ) : this() { Name = name; ColorSourceBlend = colorSourceBlend; AlphaSourceBlend = alphaSourceBlend; ColorDestinationBlend = colorDestBlend; AlphaDestinationBlend = alphaDestBlend; }
static private SharpDX.Direct3D11.BlendOption GetBlendOption(Blend blend, bool alpha) { switch (blend) { case Blend.BlendFactor: return SharpDX.Direct3D11.BlendOption.BlendFactor; case Blend.DestinationAlpha: return SharpDX.Direct3D11.BlendOption.DestinationAlpha; case Blend.DestinationColor: return alpha ? SharpDX.Direct3D11.BlendOption.DestinationAlpha : SharpDX.Direct3D11.BlendOption.DestinationColor; case Blend.InverseBlendFactor: return SharpDX.Direct3D11.BlendOption.InverseBlendFactor; case Blend.InverseDestinationAlpha: return SharpDX.Direct3D11.BlendOption.InverseDestinationAlpha; case Blend.InverseDestinationColor: return alpha ? SharpDX.Direct3D11.BlendOption.InverseDestinationAlpha : SharpDX.Direct3D11.BlendOption.InverseDestinationColor; case Blend.InverseSourceAlpha: return SharpDX.Direct3D11.BlendOption.InverseSourceAlpha; case Blend.InverseSourceColor: return alpha ? SharpDX.Direct3D11.BlendOption.InverseSourceAlpha : SharpDX.Direct3D11.BlendOption.InverseSourceColor; case Blend.One: return SharpDX.Direct3D11.BlendOption.One; case Blend.SourceAlpha: return SharpDX.Direct3D11.BlendOption.SourceAlpha; case Blend.SourceAlphaSaturation: return SharpDX.Direct3D11.BlendOption.SourceAlphaSaturate; case Blend.SourceColor: return alpha ? SharpDX.Direct3D11.BlendOption.SourceAlpha : SharpDX.Direct3D11.BlendOption.SourceColor; case Blend.Zero: return SharpDX.Direct3D11.BlendOption.Zero; default: throw new ArgumentException("Invalid blend!"); } }
public LayeredTexture(ulong id, Element element, Document doc, string name) : base(id, element, name) { texture = null; blendMode = Blend.Modulate; alpha = 1; var sc = Parser.GetRequiredScope(element); var BlendModes = sc["BlendModes"]; var Alphas = sc["Alphas"]; if (BlendModes != null) { blendMode = (Blend)Parser.ParseTokenAsInt(Parser.GetRequiredToken(BlendModes, 0)); } if (Alphas != null) { alpha = Parser.ParseTokenAsFloat(Parser.GetRequiredToken(Alphas, 0)); } }
public static BlendingFactorSrc ToOpenGL(Blend blend) { switch (blend) { case Blend.Zero: return BlendingFactorSrc.Zero; case Blend.One: return BlendingFactorSrc.One; case Blend.SourceColor: return (BlendingFactorSrc)BlendingFactorDest.SrcColor; case Blend.InverseSourceColor: return (BlendingFactorSrc)BlendingFactorDest.OneMinusSrcColor; case Blend.SourceAlpha: return BlendingFactorSrc.SrcAlpha; case Blend.InverseSourceAlpha: return BlendingFactorSrc.OneMinusSrcAlpha; case Blend.DestinationAlpha: return BlendingFactorSrc.DstAlpha; case Blend.InverseDestinationAlpha: return BlendingFactorSrc.OneMinusDstAlpha; case Blend.DestinationColor: return BlendingFactorSrc.DstColor; case Blend.InverseDestinationColor: return BlendingFactorSrc.OneMinusDstColor; case Blend.SourceAlphaSaturate: return BlendingFactorSrc.SrcAlphaSaturate; case Blend.BlendFactor: return BlendingFactorSrc.ConstantColor; case Blend.InverseBlendFactor: return BlendingFactorSrc.OneMinusConstantColor; case Blend.SecondarySourceColor: case Blend.InverseSecondarySourceColor: case Blend.SecondarySourceAlpha: case Blend.InverseSecondarySourceAlpha: throw new NotSupportedException(); default: throw new ArgumentOutOfRangeException("blend"); } }
protected override void DrawProgres(System.Drawing.Graphics g) { try { if (this.BouncingMode == BouncingModeEnum.FilledUpDown) { base.DrawProgres(g); } else { //SALVA HEIGHT E WIDTH PER CALCOLI PIU VELOCI int W = this.ClientRectangle.Width; int H = this.ClientRectangle.Height; int BarWidth = 0; int BarHeight = 0; int BarPosition = 0; Rectangle ColoredBar = default(Rectangle); BarHeight = H - 4; if (this.BouncingMode == BouncingModeEnum.RollingStrip) { BarWidth = Convert.ToInt32((W - 3) / 3); BarPosition = Convert.ToInt32(Math.Floor(((W + BarWidth + 4) * (this.Value - Minimum)) / (Maximum - Minimum))); if (!(BarWidth <= 0) & !(BarHeight <= 0)) { ColoredBar = new Rectangle(BarPosition - BarWidth, 2, BarWidth, BarHeight); } } if (this.BouncingMode == BouncingModeEnum.PingPong) { BarWidth = Convert.ToInt32((W - 3) / 3); BarPosition = Convert.ToInt32(Math.Floor(((W + BarWidth + 4) * (this.Value - Minimum)) / (Maximum - Minimum))); if (!(BarWidth <= 0) & !(BarHeight <= 0)) { if (Reverse) { ColoredBar = new Rectangle(BarPosition - BarWidth - 1, 2, BarWidth, BarHeight); } else { ColoredBar = new Rectangle(BarPosition - BarWidth, 2, BarWidth, BarHeight); } } } if (!ColoredBar.Equals(Rectangle.Empty)) { using (LinearGradientBrush brush = new LinearGradientBrush(ColoredBar, this.FillColor, this.BarColor, 90f)) { float[] relativeIntensities = { 0.1f, 1f, 1f, 1f, 1f, 0.85f, 0.1f }; float[] relativePositions = { 0f, 0.2f, 0.5f, 0.5f, 0.5f, 0.8f, 1f }; Blend blend = new Blend(); blend.Factors = relativeIntensities; blend.Positions = relativePositions; brush.Blend = blend; g.FillRectangle(brush, ColoredBar); } } } } catch (Exception ex) { Debug.WriteLine(ex); } }
private void PaintSmoke(PaintEventArgs e) { int X; int Y; SizeF s; Rectangle r = new Rectangle(0, 0, notifier.AdjustedWidth, notifier.AdjustedHeight); Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.InterpolationMode = InterpolationMode.NearestNeighbor; //graphics.FillRectangle(borderBrush, r); Region region = CreateRoundedRegion(this.borderWidth, this.borderTopOffset + this.borderWidth, r.Width - this.borderWidth, (r.Height + this.borderTopOffset) - this.borderWidth, this.radius - this.borderWidth, this.radius - this.borderWidth); graphics.SetClip(region, CombineMode.Exclude); graphics.FillRegion(this.borderBrush, base.Region); graphics.ResetClip(); using (region) { LinearGradientBrush brush = new LinearGradientBrush(region.GetBounds(e.Graphics), this.color1, this.color2, LinearGradientMode.Vertical); using (brush) { Blend blend = new Blend(); float[] numArray = new float[3]; numArray[1] = 0.1f; numArray[2] = 1f; blend.Factors = numArray; float[] numArray2 = new float[3]; numArray2[1] = 0.3f; numArray2[2] = 1f; blend.Positions = numArray2; brush.Blend = blend; graphics.FillRegion(brush, region); } } try { //graphics.FillRectangle(brush, r); X = 4; if (notifier.Glyph != null) { Y = (notifier.AdjustedHeight - notifier.GlyphSize) / 2; e.Graphics.DrawImage(notifier.Glyph, X, Y, notifier.GlyphSize, notifier.GlyphSize); X = X + notifier.GlyphSize + 4; } Y = 4; r = new Rectangle(X, Y, notifier.AdjustedWidth - 4 - X, notifier.AdjustedHeight - 4 - Y); graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; if (!string.IsNullOrEmpty(notifier.Caption)) { Font captionFont = new Font(notifier.Font, FontStyle.Bold); try { SolidBrush captionBrush = new SolidBrush(notifier.CaptionColor); try { StringFormat formatCaption = new StringFormat(); try { formatCaption.Alignment = StringAlignment.Center; formatCaption.Trimming = StringTrimming.EllipsisWord; s = e.Graphics.MeasureString(notifier.Caption, captionFont, notifier.AdjustedWidth, formatCaption); e.Graphics.DrawString(notifier.Caption, captionFont, captionBrush, r, formatCaption); } finally { formatCaption.Dispose(); } } finally { captionBrush.Dispose(); } } finally { captionFont.Dispose(); } Y = (int)(Y + s.Height + 4); e.Graphics.DrawLine(Pens.Gainsboro, new Point(r.Right - 4, Y), new Point(r.Left, Y)); Y += 6; } r.Y = Y; r.Width -= 4; StringFormat formatBody = new StringFormat(); try { formatBody.Alignment = StringAlignment.Near; formatBody.Trimming = StringTrimming.EllipsisWord; Font bodyFont = new Font(notifier.Font, FontStyle.Regular); try { SolidBrush bodyBrush = new SolidBrush(notifier.TextColor); try { e.Graphics.DrawString(notifier.Text, bodyFont, bodyBrush, r, formatBody); } finally { bodyBrush.Dispose(); bodyBrush = null; } } finally { bodyFont.Dispose(); bodyFont = null; } } finally { formatBody.Dispose(); formatBody = null; } } //back color brush finally { } }
/// <summary> /// Sets the blending function /// </summary> /// <param name="sfactor">Source factor</param> /// <param name="dfactor">Destination factor</param> public void BlendFunction(Blend sfactor, Blend dfactor) { GL.glBlendFunc((uint)sfactor, (uint)dfactor); }
private BlendState(Blend sourceBlend, Blend destinationBlend, BlendFunction function) { this.sourceBlend = sourceBlend; this.destinationBlend = destinationBlend; this.function = function; }
/// <summary> /// Configures the rendering pipeline. /// </summary> /// <param name="cull">The polygon culling options.</param> /// <param name="depth">The depth processing options.</param> /// <param name="stencil">The stenciling mode.</param> /// <param name="blend">The blending mode.</param> public static void Use(Cull cull, Depth depth, Stencil stencil, Blend blend) { if (gl.HasPendingPops) { throw new InvalidOperationException("Cannot change GPU state while the attribute stack is active."); } if (currentCull != cull) { if (cull == Cull.None) { gl.Disable(GL.CULL_FACE); } else { gl.Enable(GL.CULL_FACE); switch (cull) { case Cull.Front: gl.CullFace(GL.FRONT); break; case Cull.Back: gl.CullFace(GL.BACK); break; case Cull.Front | Cull.Back: gl.CullFace(GL.FRONT_AND_BACK); break; } } currentCull = cull; } if (currentDepth != depth) { if (depth == Depth.None) { gl.Disable(GL.DEPTH_TEST); } else { gl.Enable(GL.DEPTH_TEST); if ((depth & Depth.Test) == Depth.Test) { if ((depth & Depth.TestReversed) == Depth.TestReversed) { gl.DepthFunc(GL.GREATER); } else { gl.DepthFunc(GL.LEQUAL); } } else { gl.DepthFunc(GL.ALWAYS); } if ((depth & Depth.Write) == Depth.Write) { gl.DepthMask(true); } else { gl.DepthMask(false); } if ((depth & Depth.Clamp) == Depth.Clamp) { gl.Enable(GL.DEPTH_CLAMP); } else { gl.Disable(GL.DEPTH_CLAMP); } if ((depth & Depth.Offset) == Depth.Offset) { gl.Enable(GL.POLYGON_OFFSET_FILL); gl.PolygonOffset(0.02f, 0); } else { gl.Disable(GL.POLYGON_OFFSET_FILL); } } currentDepth = depth; } if (currentStencil != stencil) { if (stencil == Stencil.None) { gl.Disable(GL.STENCIL_TEST); } else { gl.Enable(GL.STENCIL_TEST); switch (stencil) { case Stencil.Shadows: gl.StencilFunc(GL.FRONT_AND_BACK, GL.ALWAYS, 0, 0xFF); gl.StencilOp(GL.FRONT, GL.KEEP, GL.INCR_WRAP, GL.KEEP); // <- increase when going in gl.StencilOp(GL.BACK, GL.KEEP, GL.DECR_WRAP, GL.KEEP); // <- decrease when going out break; case Stencil.Light: gl.StencilFunc(GL.FRONT_AND_BACK, GL.EQUAL, 0, 0xFF); // <- if (stencil != 0) { in shadow } gl.StencilOp(GL.FRONT_AND_BACK, GL.KEEP, GL.KEEP, GL.KEEP); break; } } currentStencil = stencil; } if (currentBlend != blend) { if (blend == Blend.None) { gl.Disable(GL.BLEND); } else { gl.Enable(GL.BLEND); switch (blend) { case Blend.Additive: gl.BlendFunc(GL.ONE, GL.ONE, GL.ONE, GL.ONE); break; case Blend.Alpha: gl.BlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA, GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); break; } } currentBlend = blend; } }
private static extern bool TLN_SetLayerBlendMode(int nlayer, Blend mode, byte factor);
/// <summary> /// Draw horizontal button back on the graphics specified. /// </summary> /// <param name="graphics">Button graphics object.</param> private void DrawHorizontalButtonBack(Graphics graphics) { // Define button radius int radius = (int)Math.Round(this.ClientRectangle.Height / 3.0); // Draw background image VerticalTabControl tabControl = this.Parent as VerticalTabControl; if (tabControl != null && tabControl.BackgroundImage != null) { int height = tabControl.GetButtonHeight() + 1; // Draw image in the background of the tab controls. // Image must be aligne to the bottom-right corner of the tabs area. Rectangle destRect = new Rectangle( tabControl.Right - tabControl.BackgroundImage.Width + tabControl.BackImageOffsetX - this.Left, 0, tabControl.BackgroundImage.Width, height); ImageAttributes imageAttributes = new ImageAttributes(); graphics.DrawImage( tabControl.BackgroundImage, destRect, 0, tabControl.BackImageOffsetY + this.Top, tabControl.BackgroundImage.Width, height, GraphicsUnit.Pixel, imageAttributes); } // Create button border path using (GraphicsPath buttonPath = new GraphicsPath()) { // Left vertical line buttonPath.AddLine( this.ClientRectangle.X, this.ClientRectangle.Bottom, this.ClientRectangle.X, this.ClientRectangle.Y + radius); // Top left arc buttonPath.AddArc( this.ClientRectangle.X, this.ClientRectangle.Y, 2 * radius, 2 * radius, 180, 90); // Top horizontal line buttonPath.AddLine( this.ClientRectangle.X + radius, this.ClientRectangle.Y, this.ClientRectangle.Right - radius, this.ClientRectangle.Y); // Top right arc buttonPath.AddArc( this.ClientRectangle.Right - 1 - 2 * radius, this.ClientRectangle.Y, 2 * radius, 2 * radius, 270, 90); // Right vertical line buttonPath.AddLine( this.ClientRectangle.Right - 1, this.ClientRectangle.Y + radius, this.ClientRectangle.Right - 1, this.ClientRectangle.Bottom); // Bottom horizontal line if (!this.SelectedTab) { buttonPath.AddLine( this.ClientRectangle.X, this.ClientRectangle.Bottom - 1, this.ClientRectangle.Right, this.ClientRectangle.Bottom - 1); } // Fill button background if (this.SelectedTab) { Rectangle brushRect = this.ClientRectangle; using (LinearGradientBrush backBrush = new LinearGradientBrush(brushRect, this.selectedGradientBackColor, this.BackColor, 90)) { Blend blend = new Blend(3); blend.Positions[0] = 0.0f; blend.Positions[1] = 0.8f; blend.Positions[2] = 1.0f; blend.Factors[0] = 0.0f; blend.Factors[1] = 1.0f; blend.Factors[2] = 1.0f; backBrush.Blend = blend; graphics.FillPath(backBrush, buttonPath); } } else { using (SolidBrush backBrush = new SolidBrush((this.SelectedTab) ? this.BackColor : nonSelectedBackColor)) { graphics.FillPath(backBrush, buttonPath); } } // Draw button border using Anti-Aliasing using (Pen pen = new Pen(this.borderColor, 1)) { SmoothingMode oldMode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.DrawPath(pen, buttonPath); graphics.SmoothingMode = oldMode; } } }
protected internal override void RenderShadow(Graphics graphics, IRender render) { if (DrawBackground) { if (Layer == null) { return; } //Use transformed path as shadows are not rotated GraphicsPath shadowPath = Geometry.ScalePath(TransformPath, 1F, 1F); graphics.TranslateTransform(Layer.ShadowOffset.X, Layer.ShadowOffset.Y); graphics.SmoothingMode = SmoothingMode.AntiAlias; //Draw soft shadows if (Layer.SoftShadows && StencilItem != null && ((StencilItem.Options & StencilItemOptions.SoftShadow) == StencilItemOptions.SoftShadow)) { PathGradientBrush brush = new PathGradientBrush(shadowPath); //Calculate position factor based on 0.3 for 100 pixels //0.6 for 50 pixels, 0.15 for 200 pixels float factor = Convert.ToSingle(0.3 * (100 / Rectangle.Width)); //Set up the brush blend Blend blend = new Blend(); blend.Positions = new float[] { 0F, factor, 1F }; blend.Factors = new float[] { 0F, 0.8F, 1F }; brush.Blend = blend; brush.CenterColor = render.AdjustColor(Layer.ShadowColor, 1, Opacity); //brush.CenterColor = Color.FromArgb(brush.CenterColor.A * 30 / 100,brush.CenterColor); brush.SurroundColors = new Color[] { Color.FromArgb(0, Layer.ShadowColor) }; graphics.FillPath(brush, shadowPath); brush.Dispose(); } else { SolidBrush shadowBrush = new SolidBrush(render.AdjustColor(Color.FromArgb(10, Layer.ShadowColor), 1, Opacity)); graphics.FillPath(shadowBrush, shadowPath); } //Restore graphics graphics.TranslateTransform(-Layer.ShadowOffset.X, -Layer.ShadowOffset.Y); graphics.SmoothingMode = SmoothingMode; } else { if (DrawBorder) { if (this.Layer == null) { return; } Layer layer = Layer; Pen shadowPen = new Pen(render.AdjustColor(layer.ShadowColor, BorderWidth, Opacity)); GraphicsPath shadowPath = TransformPath; graphics.TranslateTransform(layer.ShadowOffset.X, layer.ShadowOffset.Y); if (layer.SoftShadows) { graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.DrawPath(shadowPen, shadowPath); graphics.CompositingQuality = render.CompositingQuality; graphics.SmoothingMode = SmoothingMode; } else { graphics.DrawPath(shadowPen, shadowPath); } //Restore graphics graphics.TranslateTransform(-layer.ShadowOffset.X, -layer.ShadowOffset.Y); } } }
/// <summary> /// Initializes a new instance of the <see cref="BlendDescription"/> class. /// </summary> /// <param name="sourceBlend">The source blend.</param> /// <param name="destinationBlend">The destination blend.</param> /// <param name="srcBlendAlpha">The source alpha blend.</param> /// <param name="destBlendAlpha">The destination alpha blend.</param> public BlendDescription(Blend sourceBlend, Blend destinationBlend, Blend srcBlendAlpha, Blend destBlendAlpha) : this() { AlphaToCoverageEnable = false; IndependentBlendEnable = false; for (var i = 0; i < SimultaneousRenderTargetCount; i++) { RenderTarget[i].LogicOpEnable = false; RenderTarget[i].SrcBlend = sourceBlend; RenderTarget[i].DestBlend = destinationBlend; RenderTarget[i].BlendOp = BlendOperation.Add; RenderTarget[i].SrcBlendAlpha = srcBlendAlpha; RenderTarget[i].DestBlendAlpha = destBlendAlpha; RenderTarget[i].BlendOpAlpha = BlendOperation.Add; RenderTarget[i].LogicOp = LogicOp.Noop; RenderTarget[i].RenderTargetWriteMask = ColorWriteEnable.All; RenderTarget[i].BlendEnable = IsBlendEnabled(ref RenderTarget[i]); } }
public FamilyGeometryForm(Autodesk.Revit.DB.GenericForm form) { Id = form.Id.IntegerValue; this.geomVisibility = new GeometryVisibility(form.GetVisibility()); //Autodesk.Revit.DB.Parameter sketchPlaneParam = form.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.SKETCH_PLANE_PARAM); //if(sketchPlaneParam != null) //{ // this. //} IsSolidGeometry = form.IsSolid; if (form.Subcategory == null) { SubcategoryName = ""; } else { SubcategoryName = form.Subcategory.Name; } if (form is Extrusion) { FormType = FormTypeEnum.Extrusion; Extrusion ex = form as Extrusion; Sketch extrusionProfile = ex.Sketch; GeometrySketch gs = new GeometrySketch(extrusionProfile); List_Profiles = new List <GeometrySketch> { gs }; } else if (form is Blend) { FormType = FormTypeEnum.Blend; Blend bl = form as Blend; GeometrySketch TopProfile = new GeometrySketch(bl.TopSketch); GeometrySketch BottomProfile = new GeometrySketch(bl.BottomSketch); List_Profiles = new List <GeometrySketch> { TopProfile, BottomProfile }; } else if (form is Revolution) { FormType = FormTypeEnum.Revolution; Revolution rev = form as Revolution; Sketch revProfile = rev.Sketch; GeometrySketch gs = new GeometrySketch(revProfile); GeometrySketch axis = new GeometrySketch(rev.Axis.Id.IntegerValue, -1, null); List_Profiles = new List <GeometrySketch> { gs, axis }; } else if (form is Sweep) { FormType = FormTypeEnum.Sweep; Sweep sw = form as Sweep; List_Profiles = new List <GeometrySketch>(); if (sw.Path3d != null) { GeometrySketch gs = new GeometrySketch(sw.Path3d); List_Profiles.Add(gs); } else if (sw.PathSketch != null) { GeometrySketch gs = new GeometrySketch(sw.PathSketch); List_Profiles.Add(gs); } if (sw.ProfileSymbol != null) { GeometrySketch gs = new GeometrySketch(sw.ProfileSymbol.Profile.Id.IntegerValue, -1, null); } else if (sw.ProfileSketch != null) { GeometrySketch gs = new GeometrySketch(sw.ProfileSketch); List_Profiles.Add(gs); } } else if (form is SweptBlend) { FormType = FormTypeEnum.SweptBlend; SweptBlend sb = form as SweptBlend; List_Profiles = new List <GeometrySketch>(); if (sb.SelectedPath != null) { Curve path = sb.SelectedPath; GeometrySketch gs = new GeometrySketch(path.Reference.ElementId.IntegerValue, -1, null); List_Profiles.Add(gs); } else if (sb.PathSketch != null) { GeometrySketch gs = new GeometrySketch(sb.PathSketch); List_Profiles.Add(gs); } GeometrySketch gs1 = new GeometrySketch(sb.TopProfile); GeometrySketch gs2 = new GeometrySketch(sb.BottomProfile); List_Profiles.Add(gs1); List_Profiles.Add(gs2); } }
public static BlendOption Convert ( Blend blend ) { switch ( blend ) { case Blend.Zero : return BlendOption.Zero ; case Blend.One : return BlendOption.One ; case Blend.SrcColor : return BlendOption.SourceColor ; case Blend.InvSrcColor : return BlendOption.InverseSourceColor ; case Blend.SrcAlpha : return BlendOption.SourceAlpha ; case Blend.InvSrcAlpha : return BlendOption.InverseSourceAlpha ; case Blend.DstAlpha : return BlendOption.DestinationAlpha ; case Blend.InvDstAlpha : return BlendOption.InverseDestinationAlpha ; case Blend.DstColor : return BlendOption.DestinationColor ; case Blend.InvDstColor : return BlendOption.InverseDestinationColor ; case Blend.SrcAlphaSaturation : return BlendOption.SourceAlphaSaturate ; case Blend.BlendFactor : return BlendOption.BlendFactor ; case Blend.InvBlendFactor : return BlendOption.InverseBlendFactor ; } throw new ArgumentException("Bad blend"); }
private void GlassSphere(Graphics g) { Color c = Color.Blue; int reduct = 200; g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; // Base ellipse Rectangle r1 = new Rectangle(new Point(0, 0), new Size(this.Width - reduct, this.Height - reduct)); Rectangle r2 = new Rectangle(r1.Location, new Size(r1.Size.Width - reduct - 2, r1.Size.Height - reduct - 2)); GraphicsPath path = new GraphicsPath(FillMode.Winding); path.AddEllipse(r2); PathGradientBrush br1 = new PathGradientBrush(path); br1.CenterColor = c; br1.SurroundColors = new Color[] { Color.FromArgb(255, Color.Black) }; //br1.CenterPoint = new PointF((float)(r1.Width / 1.5), r1.Top - Convert.ToInt16(r1.Height * 2)); Blend bl1 = new Blend(5); bl1.Factors = new float[] { 0.5f, 1.0f, 1.0f, 1.0f, 1.0f }; bl1.Positions = new float[] { 0.0f, 0.05f, 0.5f, 0.75f, 1.0f }; br1.Blend = bl1; g.FillPath(br1, path); br1.Dispose(); path.Dispose(); // 1st hilite ellipse int r3w = Convert.ToInt16(r2.Width * 0.8); int r3h = Convert.ToInt16(r2.Height * 0.6); int r3posX = (r2.Width / 2) - (r3w / 2); int r3posY = r2.Top + 1; Rectangle r3 = new Rectangle( new Point(r3posX, r3posY), new Size(r3w, r3h)); Color br3c1 = Color.White; Color br3c2 = Color.Transparent; LinearGradientBrush br2 = new LinearGradientBrush(r3, br3c1, br3c2, 90); br2.WrapMode = WrapMode.TileFlipX; g.FillEllipse(br2, r3); br2.Dispose(); // 2nd hilite ellipse int r4w = Convert.ToInt16(r2.Width * 0.3); int r4h = Convert.ToInt16(r2.Height * 0.2); int r4posX = (r2.Width / 2) + (r4w / 2); int r4posY = r2.Top + Convert.ToInt16(r2.Height * 0.2); Rectangle r4 = new Rectangle( new Point(-(int)(r4w / 2), -(int)(r4h / 2)), new Size(r4w, r4h)); LinearGradientBrush br3 = new LinearGradientBrush(r4, br3c1, br3c2, 90, true); g.TranslateTransform(r4posX, r4posY); g.RotateTransform(30); g.FillEllipse(br3, r4); br3.Dispose(); title = "GlassSphere"; }
/// <summary> /// Converts an Ultraviolet Blend value to the equivalent OpenGL value. /// </summary> /// <param name="blend">The Ultraviolet Blend value to convert.</param> /// <param name="alpha">A value indicating whether alpha blending is enabled.</param> /// <returns>The converted OpenGL value.</returns> private static UInt32 GetBlendGL(Blend blend, Boolean alpha) { switch (blend) { case Blend.Zero: return gl.GL_ZERO; case Blend.One: return gl.GL_ONE; case Blend.SourceColor: return gl.GL_SRC_COLOR; case Blend.InverseSourceColor: return gl.GL_ONE_MINUS_SRC_COLOR; case Blend.SourceAlpha: return gl.GL_SRC_ALPHA; case Blend.InverseSourceAlpha: return gl.GL_ONE_MINUS_SRC_ALPHA; case Blend.DestinationAlpha: return gl.GL_DST_ALPHA; case Blend.InverseDestinationAlpha: return gl.GL_ONE_MINUS_DST_ALPHA; case Blend.DestinationColor: return gl.GL_DST_COLOR; case Blend.InverseDestinationColor: return gl.GL_ONE_MINUS_DST_COLOR; case Blend.SourceAlphaSaturation: return gl.GL_SRC_ALPHA_SATURATE; case Blend.BlendFactor: return alpha ? gl.GL_CONSTANT_ALPHA : gl.GL_CONSTANT_COLOR; case Blend.InverseBlendFactor: return alpha ? gl.GL_ONE_MINUS_CONSTANT_ALPHA : gl.GL_ONE_MINUS_CONSTANT_COLOR; } throw new NotSupportedException(); }
public void ApplyTest2() { var img1 = Accord.Imaging.Image.Clone(Resources.image2); var img2 = Accord.Imaging.Image.Clone(Resources.image2); var img3 = Accord.Imaging.Image.Clone(Resources.image2); var img4 = Accord.Imaging.Image.Clone(Resources.image2); MatrixH homography; Blend blend; homography = new MatrixH(1, 0, 32, 0, 1, 0, 0, 0); blend = new Blend(homography, img1); var img12 = blend.Apply(img2); //ImageBox.Show("Blend of 1 and 2", img12, PictureBoxSizeMode.Zoom); Assert.AreEqual(img12.PixelFormat, PixelFormat.Format32bppArgb); blend = new Blend(homography, img3); var img34 = blend.Apply(img4); //ImageBox.Show("Blend of 3 and 4", img34, PictureBoxSizeMode.Zoom); Assert.AreEqual(img34.PixelFormat, PixelFormat.Format32bppArgb); homography = new MatrixH(1, 0, 64, 0, 1, 0, 0, 0); blend = new Blend(homography, img12); var img1234 = blend.Apply(img34); //ImageBox.Show("Blend of 1, 2, 3, 4", img1234, PictureBoxSizeMode.Zoom); Assert.AreEqual(img1234.PixelFormat, PixelFormat.Format32bppArgb); // Blend of 1 and 5 (8bpp and 32bpp) homography = new MatrixH(1, 0, 0, 0, 1, 32, 0, 0); //ImageBox.Show("Image 1", img1, PictureBoxSizeMode.Zoom); blend = new Blend(homography, img1234); var img15 = blend.Apply(img1); //ImageBox.Show("Blend of 1 and 5", img15, PictureBoxSizeMode.Zoom); Assert.AreEqual(img1234.PixelFormat, PixelFormat.Format32bppArgb); Assert.AreEqual(img1.PixelFormat, PixelFormat.Format8bppIndexed); Assert.AreEqual(img15.PixelFormat, PixelFormat.Format32bppArgb); Assert.AreEqual(128, img15.Width); Assert.AreEqual(64, img15.Height); }
private Brush GetBrush() { int angle = 0; switch (align) { case TabAlignment.Top: angle = 90; break; case TabAlignment.Bottom: angle = 270; break; case TabAlignment.Right: angle = 180; break; } Blend blend; switch (fill) { case TabControlFill.Linear: brush = new LinearGradientBrush(rect, color1, color2, angle, true); break; case TabControlFill.Top: { brush = new LinearGradientBrush(rect, color1, color2, angle, true); blend = new Blend(); float[] relativeIntensities = { 1.0F, 0.8F, 0.6F, 0.4F, 0.2F, 0.0F, 0.0F }; float[] relativePositions = { 0.0F, 0.05F, 0.1F, 0.15F, 0.2F, 0.3F, 1.0F }; blend.Factors = relativeIntensities; blend.Positions = relativePositions; ((LinearGradientBrush)brush).Blend = blend; } break; case TabControlFill.Center: { brush = new LinearGradientBrush(rect, color1, color2, angle, true); blend = new Blend(); float[] relativeIntensities = { 0.0F, 0.5F, 1.0F, 0.5F, 0.0F }; float[] relativePositions = { 0.0F, 0.3F, 0.5F, 0.7F, 1.0F }; blend.Factors = relativeIntensities; blend.Positions = relativePositions; ((LinearGradientBrush)brush).Blend = blend; } break; case TabControlFill.Bottom: { brush = new LinearGradientBrush(rect, color1, color2, angle + 180, true); blend = new Blend(); float[] relativeIntensities = { 1.0F, 0.8F, 0.6F, 0.4F, 0.2F, 0.0F, 0.0F }; float[] relativePositions = { 0.0F, 0.05F, 0.1F, 0.15F, 0.2F, 0.3F, 1.0F }; blend.Factors = relativeIntensities; blend.Positions = relativePositions; ((LinearGradientBrush)brush).Blend = blend; } break; default: brush = new SolidBrush(color1); break; } return(brush); }
private void DrawTabPages(Graphics g) { Rectangle tabRect; Point cusorPoint = PointToClient(MousePosition); bool hover; bool selected; bool hasSetClip = false; bool alignHorizontal = (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom); LinearGradientMode mode = alignHorizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; if (alignHorizontal) { IntPtr upDownButtonHandle = UpDownButtonHandle; bool hasUpDown = upDownButtonHandle != IntPtr.Zero; if (hasUpDown) { if (Win32.IsWindowVisible(upDownButtonHandle)) { RECT upDownButtonRect = new RECT(); Win32.GetWindowRect( upDownButtonHandle, ref upDownButtonRect); Rectangle upDownRect = Rectangle.FromLTRB( upDownButtonRect.left, upDownButtonRect.top, upDownButtonRect.right, upDownButtonRect.bottom); upDownRect = RectangleToClient(upDownRect); switch (Alignment) { case TabAlignment.Top: upDownRect.Y = 0; break; case TabAlignment.Bottom: upDownRect.Y = ClientRectangle.Height - DisplayRectangle.Height; break; } upDownRect.Height = ClientRectangle.Height; g.SetClip(upDownRect, CombineMode.Exclude); hasSetClip = true; } } } for (int index = 0; index < base.TabCount; index++) { TabPage page = TabPages[index]; tabRect = GetTabRect(index); hover = tabRect.Contains(cusorPoint); selected = SelectedIndex == index; Color baseColor = _BaseTabolor; Color borderColor = _BorderColor; Blend blend = new Blend(); blend.Positions = new float[] { 0f, 0.3f, 0.5f, 0.7f, 1.0f }; blend.Factors = new float[] { 0.1f, 0.3f, 0.5f, 0.8f, 1.0f }; if (selected) { baseColor = this._CheckedTabColor; } else if (hover) { baseColor = this._HeightLightTabColor; blend.Positions = new float[] { 0f, 0.3f, 0.6f, 0.8f, 1f }; blend.Factors = new float[] { .2f, 0.4f, 0.6f, 0.5f, .4f }; } Rectangle exRect = new Rectangle(tabRect.Left, tabRect.Bottom, tabRect.Width, 1); g.SetClip(exRect, CombineMode.Exclude); CornerRadius cr = new CornerRadius(this._TabCornerRadius, this._TabCornerRadius, 0, 0); tabRect.X += this._TabMargin; tabRect.Width -= this._TabMargin; tabRect.Y++; tabRect.Height--; RoundRectangle roundRect = new RoundRectangle(tabRect, cr); GDIHelper.InitializeGraphics(g); switch (this._TabStyle) { case EnumTabStyle.AnglesWing: cr = new CornerRadius(this._TabCornerRadius); tabRect.X += this._TabCornerRadius; tabRect.Width -= this._TabCornerRadius * 2; roundRect = new RoundRectangle(tabRect, cr); using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath()) { using (LinearGradientBrush brush = new LinearGradientBrush(roundRect.Rect, baseColor, this._BackColor, LinearGradientMode.Vertical)) { brush.Blend = blend; g.FillPath(brush, path); } } using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath()) { using (Pen pen = new Pen(this._BorderColor, 1)) { g.DrawPath(pen, path); } } break; case EnumTabStyle.Default: GDIHelper.FillPath(g, roundRect, baseColor, this._BackColor, blend); GDIHelper.DrawPathBorder(g, roundRect, this._BorderColor); break; } g.ResetClip(); if (this.Alignment == TabAlignment.Top) { Image img = null; Size imgSize = Size.Empty; if (this.ImageList != null && page.ImageIndex >= 0) { img = this.ImageList.Images[page.ImageIndex]; imgSize = img.Size; } GDIHelper.DrawImageAndString(g, tabRect, img, imgSize, page.Text, this._CaptionFont, this._CaptionForceColor); } else { bool hasImage = DrawTabImage(g, page, tabRect); DrawtabText(g, page, tabRect, hasImage); } } if (hasSetClip) { g.ResetClip(); } }
public static BlendFactor ConvertBlend(Blend blend) { switch (blend) { case Blend.BlendFactor: return BlendFactor.ConstantColor; case Blend.DestinationAlpha: return BlendFactor.DestinationAlpha; case Blend.DestinationColor: return BlendFactor.DestinationColor; case Blend.InverseBlendFactor: return BlendFactor.OneMinusConstantColor; case Blend.InverseDestinationAlpha: return BlendFactor.OneMinusDestinationAlpha; case Blend.InverseDestinationColor: return BlendFactor.OneMinusDestinationColor; case Blend.InverseSecondarySourceAlpha: return BlendFactor.OneMinusSource1Alpha; case Blend.InverseSecondarySourceColor: return BlendFactor.OneMinusSource1Color; case Blend.InverseSourceAlpha: return BlendFactor.OneMinusSourceAlpha; case Blend.InverseSourceColor: return BlendFactor.OneMinusSourceColor; case Blend.One: return BlendFactor.One; case Blend.SecondarySourceAlpha: return BlendFactor.Source1Alpha; case Blend.SecondarySourceColor: return BlendFactor.Source1Color; case Blend.SourceAlpha: return BlendFactor.SourceAlpha; case Blend.SourceAlphaSaturate: return BlendFactor.SourceAlphaSaturate; case Blend.SourceColor: return BlendFactor.SourceColor; case Blend.Zero: return BlendFactor.Zero; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Initializes a new instance of the <see cref="BlendDescription"/> struct. /// </summary> /// <param name="sourceBlend">The source blend.</param> /// <param name="destinationBlend">The destination blend.</param> public BlendDescription(Blend sourceBlend, Blend destinationBlend) : this(sourceBlend, destinationBlend, sourceBlend, destinationBlend) { }
private static extern bool TLN_SetSpriteBlendMode(int nsprite, Blend mode, byte factor);
/// <summary> /// Initializes a new instance of the <see cref="BlendDescription"/> struct. /// </summary> /// <param name="sourceBlend">Specifies the first RGB data source and includes an optional preblend operation.</param> /// <param name="destinationBlend">Specifies the second RGB data source and includes an optional preblend operation.</param> /// <param name="sourceBlendAlpha">The source alpha blend.</param> /// <param name="destinationBlendAlpha">The destination alpha blend.</param> public BlendDescription(Blend sourceBlend, Blend destinationBlend, Blend sourceBlendAlpha, Blend destinationBlendAlpha) { SourceBlend = sourceBlend; DestinationBlend = destinationBlend; BlendOperation = BlendOperation.Add; SourceBlendAlpha = sourceBlendAlpha; DestinationBlendAlpha = destinationBlendAlpha; BlendOperationAlpha = BlendOperation.Add; BlendFactor = default; }
public void GLBlendFunc(int sfactor, int dfactor) { this.AlphaDestinationBlend = (dfactor == 1) ? Blend.One : Blend.InverseSourceAlpha; }
/// <summary> /// This used to be done in the World class but moved here so folks could override a ROL's behavior. /// /// NOTE: Everything under an Icons is rendered using RenderPriority.Icons. If you put any other kind of /// ROL in here it (and it's children) probably wont render. /// </summary> /// <param name="drawArgs"></param> /// <param name="priority"></param> public override void RenderChildren(DrawArgs drawArgs, RenderPriority priority) { //Respect icon set temporal extents if (TimeKeeper.CurrentTimeUtc < EarliestTime || TimeKeeper.CurrentTimeUtc > LatestTime) { return; } if (!isOn) { return; } if (!isInitialized) { return; } if (priority != RenderPriority.Icons) { return; } // render ourselves this.Render(drawArgs); if (m_canUsePointSprites) { pointSprites.Clear(); } // First render everything except icons - we need to do this twice since the other loop is INSIDE the // sprite.begin which can mess up the rendering of other ROs. This is why prerender is in this loop. m_childrenRWLock.AcquireReaderLock(Timeout.Infinite); try { foreach (RenderableObject ro in m_children) { if (!ro.IsOn) { continue; } if (ro is Icon) // && (priority == RenderPriority.Icons)) { Icon icon = ro as Icon; if (icon == null) { continue; } // do this once for both passes icon.DistanceToIcon = Vector3.Length(icon.Position - drawArgs.WorldCamera.Position); // do PreRender regardless of everything else // note that mouseover actions happen one render cycle after mouse is over icon icon.PreRender(drawArgs, (mouseOverIcon != null) && (icon == mouseOverIcon)); } else if (ro is RenderableObjectList) { (ro as RenderableObjectList).RenderChildren(drawArgs, priority); } //// hack to render both surface images and terrain mapped images. //else if (priority == RenderPriority.TerrainMappedImages) //{ // if (ro.RenderPriority == RenderPriority.SurfaceImages || ro.RenderPriority == RenderPriority.TerrainMappedImages) // { // ro.Render(drawArgs); // } //} else // if (ro.RenderPriority == priority) { ro.Render(drawArgs); } } } catch (Exception ex) { Log.Write(ex); } finally { m_childrenRWLock.ReleaseReaderLock(); } m_labelRectangles.Clear(); int closestIconDistanceSquared = int.MaxValue; Icon closestIcon = null; if (priority == RenderPriority.Icons) { try { m_sprite.Begin(SpriteFlags.AlphaBlend); // Now render just the icons m_childrenRWLock.AcquireReaderLock(Timeout.Infinite); try { foreach (RenderableObject ro in m_children) { if (!ro.IsOn) { continue; } Icon icon = ro as Icon; if (icon == null) { continue; } // don't try to render if we aren't in view or too far away if ((drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position)) && (icon.DistanceToIcon <= icon.MaximumDisplayDistance) && (icon.DistanceToIcon >= icon.MinimumDisplayDistance)) { Vector3 translationVector = new Vector3( (float)(icon.PositionD.X - drawArgs.WorldCamera.ReferenceCenter.X), (float)(icon.PositionD.Y - drawArgs.WorldCamera.ReferenceCenter.Y), (float)(icon.PositionD.Z - drawArgs.WorldCamera.ReferenceCenter.Z)); Vector3 projectedPoint = drawArgs.WorldCamera.Project(translationVector); // check if inside bounding box of icon int dx = DrawArgs.LastMousePosition.X - (int)projectedPoint.X; int dy = DrawArgs.LastMousePosition.Y - (int)projectedPoint.Y; if (icon.SelectionRectangle.Contains(dx, dy)) { // Mouse is over, check whether this icon is closest int distanceSquared = dx * dx + dy * dy; if (distanceSquared < closestIconDistanceSquared) { closestIconDistanceSquared = distanceSquared; closestIcon = icon; } } // mouseover is always one render cycle behind...we mark that an icon is the mouseover // icon and render it normally. On the NEXT pass it renders as a mouseover icon if (icon != mouseOverIcon) { // Note: Always render hooked icons as a real icon rather than a sprite. if (icon.UsePointSprite && (icon.DistanceToIcon > icon.PointSpriteDistance) && m_canUsePointSprites && !icon.IsHooked) { PointSpriteVertex pv = new PointSpriteVertex(translationVector.X, translationVector.Y, translationVector.Z, icon.PointSpriteSize, icon.PointSpriteColor.ToArgb()); pointSprites.Add(pv); } else { // add pointsprite anyway if (icon.UsePointSprite && icon.AlwaysRenderPointSprite) { PointSpriteVertex pv = new PointSpriteVertex(translationVector.X, translationVector.Y, translationVector.Z, icon.PointSpriteSize, icon.PointSpriteColor.ToArgb()); pointSprites.Add(pv); } icon.FastRender(drawArgs, m_sprite, projectedPoint, false, m_labelRectangles); } } } else { // do whatever we're supposed to do if we're not in view or too far away icon.NoRender(drawArgs); } // do post rendering even if we don't render // note that mouseover actions happen one render cycle after mouse is over icon icon.PostRender(drawArgs, icon == mouseOverIcon); } } catch (Exception ex) { System.Console.WriteLine(ex.Message.ToString()); } finally { m_childrenRWLock.ReleaseReaderLock(); } // Clear the rectangles so that mouseover label always appears m_labelRectangles.Clear(); // Render the mouse over icon last (on top) if (mouseOverIcon != null) { Vector3 translationVector = new Vector3( (float)(mouseOverIcon.PositionD.X - drawArgs.WorldCamera.ReferenceCenter.X), (float)(mouseOverIcon.PositionD.Y - drawArgs.WorldCamera.ReferenceCenter.Y), (float)(mouseOverIcon.PositionD.Z - drawArgs.WorldCamera.ReferenceCenter.Z)); Vector3 projectedPoint = drawArgs.WorldCamera.Project(translationVector); if (mouseOverIcon.UsePointSprite && mouseOverIcon.AlwaysRenderPointSprite && m_canUsePointSprites) { // add pointsprite anyway PointSpriteVertex pv = new PointSpriteVertex(translationVector.X, translationVector.Y, translationVector.Z, mouseOverIcon.PointSpriteSize, mouseOverIcon.PointSpriteColor.ToArgb()); pointSprites.Add(pv); } mouseOverIcon.FastRender(drawArgs, m_sprite, projectedPoint, true, m_labelRectangles); } // set new mouseover icon mouseOverIcon = closestIcon; } catch (Exception ex) { System.Console.WriteLine(ex.Message.ToString()); } finally { m_sprite.End(); } // render point sprites if any in the list try { if (pointSprites.Count > 0) { // save device state BaseTexture origTexture = drawArgs.device.GetTexture(0); VertexFormat origVertexFormat = drawArgs.device.VertexFormat; float origPointScaleA = drawArgs.device.GetRenderState <float>(RenderState.PointScaleA); float origPointScaleB = drawArgs.device.GetRenderState <float>(RenderState.PointScaleB); float origPointScaleC = drawArgs.device.GetRenderState <float>(RenderState.PointScaleC); bool origPointSpriteEnable = drawArgs.device.GetRenderState <bool>(RenderState.PointSpriteEnable); bool origPointScaleEnable = drawArgs.device.GetRenderState <bool>(RenderState.PointScaleEnable); Blend origSourceBlend = drawArgs.device.GetRenderState <Blend>(RenderState.SourceBlend); Blend origDestBlend = drawArgs.device.GetRenderState <Blend>(RenderState.DestinationBlend); // set device to do point sprites drawArgs.device.SetTexture(0, m_pointTexture.Texture); drawArgs.device.VertexFormat = VertexFormat.Position | VertexFormat.PointSize | VertexFormat.Diffuse; drawArgs.device.SetRenderState(RenderState.PointScaleA, 1f); drawArgs.device.SetRenderState(RenderState.PointScaleB, 0f); drawArgs.device.SetRenderState(RenderState.PointScaleC, 0f); drawArgs.device.SetRenderState(RenderState.PointSpriteEnable, true); drawArgs.device.SetRenderState(RenderState.PointScaleEnable, true); drawArgs.device.SetRenderState(RenderState.SourceBlend, Blend.One); drawArgs.device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); drawArgs.device.SetTextureStageState(0, TextureStage.ColorOperation, (int)TextureOperation.Modulate); drawArgs.device.SetTextureStageState(0, TextureStage.ColorArg1, (int)TextureArgument.Texture); drawArgs.device.SetTextureStageState(0, TextureStage.ColorArg2, (int)TextureArgument.Diffuse); drawArgs.device.DrawUserPrimitives(PrimitiveType.PointList, pointSprites.Count, pointSprites.ToArray()); // restore device state drawArgs.device.SetTexture(0, origTexture); drawArgs.device.VertexFormat = origVertexFormat; drawArgs.device.SetRenderState(RenderState.PointScaleA, origPointScaleA); drawArgs.device.SetRenderState(RenderState.PointScaleB, origPointScaleB); drawArgs.device.SetRenderState(RenderState.PointScaleC, origPointScaleC); drawArgs.device.SetRenderState(RenderState.PointSpriteEnable, origPointSpriteEnable); drawArgs.device.SetRenderState(RenderState.PointScaleEnable, origPointScaleEnable); drawArgs.device.SetRenderState(RenderState.SourceBlend, origSourceBlend); drawArgs.device.SetRenderState(RenderState.DestinationBlend, origDestBlend); } } catch (Exception ex) { System.Console.WriteLine(ex.Message.ToString()); } } }
private void Stream( ArrayList data, Blend blend ) { data.Add( new Snoop.Data.ClassSeparator( typeof( Blend ) ) ); data.Add( new Snoop.Data.Double( "Bottom offset", blend.BottomOffset ) ); data.Add( new Snoop.Data.Object( "Bottom sketch", blend.BottomSketch ) ); data.Add( new Snoop.Data.Object( "Top sketch", blend.TopSketch ) ); data.Add( new Snoop.Data.Double( "Top offset", blend.TopOffset ) ); }
/* * Based on libgdiplus lineargradientbrush.c implementation with a couple of small modifications * for calculating the Normal Distribution. The reason for this change comes * from “The Art of Scientific Computing” by Press et al… * —– * We assume that you know enough never to evaluate a polynomial this way: * p=c[0]+c[1]*x+c[2]*x*x+c[3]*x*x*x+c[4]*x*x*x*x; * or (even worse!), * p=c[0]+c[1]*x+c[2]*pow(x,2.0)+c[3]*pow(x,3.0)+c[4]*pow(x,4.0); * * Come the (computer) revolution, all persons found guilty of such criminal behavior will be * summarily executed, and their programs won’t be! It is a matter of taste, however, whether to write * p=c[0]+x*(c[1]+x*(c[2]+x*(c[3]+x*c[4]))); * or * p=(((c[4]*x+c[3])*x+c[2])*x+c[1])*x+c[0]; * If the number of coefficients c[0..n-1] is large, one writes * p=c[n-1]; * for(j=n-2;j>=0;j–) p=p*x+c[j]; * or * p=c[j=n-1]; * while (j>0) p=p*x+c[--j]; * * where the original routine was using Math.Pow to evaluate the polinomials so with the Phi function * we should have a little speed increase. Not verified though so revert this implementaion if need be. * It is just a funtion that I have used before for CDF. * . */ internal static Blend SigmaBellShape(float focus, float scale) { Blend blend = new Blend(); float pos = 0.0f; int count = 511; /* total no of samples */ int index; float sigma; float mean; float fall_off_len = 2.0f; /* curve fall off length in terms of SIGMA */ float delta; /* distance between two samples */ float phi; /* variable to hold the value of Phi - Normal Distribution - CFD etc... */ /* we get a curve not starting from 0 and not ending at 1. * so we subtract the starting value and divide by the curve * height to make it fit in the 0 to scale range */ float curve_bottom; float curve_top; float curve_height; if (focus == 0 || focus == 1) { count = 256; } if (blend.Positions.Length != count) { blend = new Blend(count); } /* Set the blend colors. We use integral of the Normal Distribution, * i.e. Cumulative Distribution Function (CDF). * * Normal distribution: * * y (x) = (1 / sqrt (2 * PI * sq (sigma))) * exp (-sq (x - mu)/ (2 * sq (sigma))) * * where, y = height of normal curve, * sigma = standard deviation * mu = mean * OR * y (x) = peak * exp ( - z * z / 2) * where, z = (x - mu) / sigma * * In this curve, peak would occur at mean i.e. for x = mu. This results in * a peak value of peak = (1 / sqrt (2 * PI * sq (sigma))). * * Cumulative distribution function: * Ref: http://mathworld.wolfram.com/NormalDistribution.html * see function Phi(x) below - Φ(x) * * D (x) = Phi(z) * where, z = (x - mu) / sigma * */ if (focus == 0) { /* right part of the curve with a complete fall in fall_off_len * SIGMAs */ sigma = 1.0f / fall_off_len; mean = 0.5f; delta = 1.0f / 255.0f; curve_bottom = (float)Phi((1.0f - mean) / sigma); curve_top = (float)Phi((focus - mean) / sigma); curve_height = curve_top - curve_bottom; /* set the start */ blend.Positions[0] = focus; blend.Factors[0] = scale; for (index = 1, pos = delta; index < 255; index++, pos += delta) { blend.Positions[index] = pos; phi = (float)Phi((pos - mean) / sigma); blend.Factors[index] = (scale / curve_height) * (phi - curve_bottom); } /* set the end */ blend.Positions [count - 1] = 1.0f; blend.Factors [count - 1] = 0.0f; } else if (focus == 1) { /* left part of the curve with a complete rise in fall_off_len * SIGMAs */ sigma = 1.0f / fall_off_len; mean = 0.5f; delta = 1.0f / 255.0f; curve_bottom = (float)Phi((0.0f - mean) / sigma); curve_top = (float)Phi((focus - mean) / sigma); curve_height = curve_top - curve_bottom; /* set the start */ blend.Positions[0] = 0.0f; blend.Factors[0] = 0.0f; for (index = 1, pos = delta; index < 255; index++, pos += delta) { blend.Positions[index] = pos; phi = (float)Phi((pos - mean) / sigma); blend.Factors[index] = (scale / curve_height) * (pos - curve_bottom); } /* set the end */ blend.Positions [count - 1] = focus; blend.Factors [count - 1] = scale; } else { /* left part of the curve with a complete fall in fall_off_len * SIGMAs */ sigma = focus / (2 * fall_off_len); mean = focus / 2.0f; delta = focus / 255.0f; /* set the start */ blend.Positions [0] = 0.0f; blend.Factors [0] = 0.0f; curve_bottom = (float)Phi((0.0f - mean) / sigma); curve_top = (float)Phi((focus - mean) / sigma); curve_height = curve_top - curve_bottom; for (index = 1, pos = delta; index < 255; index++, pos += delta) { blend.Positions [index] = pos; phi = (float)Phi((pos - mean) / sigma); blend.Factors [index] = (scale / curve_height) * (phi - curve_bottom); } blend.Positions [index] = focus; blend.Factors [index] = scale; /* right part of the curve with a complete fall in fall_off_len * SIGMAs */ sigma = (1.0f - focus) / (2 * fall_off_len); mean = (1.0f + focus) / 2.0f; delta = (1.0f - focus) / 255.0f; curve_bottom = (float)Phi((1.0f - mean) / sigma); curve_top = (float)Phi((focus - mean) / sigma); curve_height = curve_top - curve_bottom; index++; pos = focus + delta; for (; index < 510; index++, pos += delta) { blend.Positions [index] = pos; phi = (float)Phi((pos - mean) / sigma); blend.Factors [index] = (scale / curve_height) * (phi - curve_bottom); } /* set the end */ blend.Positions [count - 1] = 1.0f; blend.Factors [count - 1] = 0.0f; } return(blend); }
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; var isHeadControl = false; if (toolStrip.Tag != null && toolStrip.Tag.ToString().Contains("$")) { isHeadControl = true; } Graphics graphics = e.Graphics; if (toolStrip is ToolStripDropDown && e.Item is ToolStripMenuItem) { bool drawLogo = DrawLogo(toolStrip); int offsetMargin = drawLogo ? OffsetMargin : 0; Rectangle rect = e.ImageRectangle; if (e.Item.RightToLeft == RightToLeft.Yes) { rect.X -= offsetMargin + 2; } else { rect.X += offsetMargin + 2; } rect.Width = 13; rect.Y += 1; rect.Height -= 3; using (SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics)) { using (GraphicsPath path = new GraphicsPath()) { path.AddRectangle(rect); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = StyleSheet.ToolStripDropDownPressedCenterColor; brush.CenterColor = Color.Red; brush.SurroundColors = new Color[] { isHeadControl?StyleSheet.HeadToolStripItemPressedBackColor : StyleSheet.ControlPressedBackColor }; Blend blend = new Blend(); blend.Positions = new float[] { 0f, 0.3f, 1f }; blend.Factors = new float[] { 0f, 0.5f, 1f }; brush.Blend = blend; graphics.FillRectangle(brush, rect); } } using (Pen pen = new Pen(StyleSheet.HeadToolStripItemPressedBackColor)) { graphics.DrawRectangle(pen, rect); } GraphicsHelper.DrawHollowwRectangle(graphics, rect, isHeadControl ? StyleSheet.HeadToolStripItemCheckedBorderColor : StyleSheet.ControlCheckedBorderColor); } } else { base.OnRenderItemCheck(e); } }
public void UpdateCameraState(Vector3 worldUp, float deltaTime) { Blend.UpdateCameraState(worldUp, deltaTime); State = Blend.State; }
protected void OnRenderImageMargin( //override ToolStripRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics g = e.Graphics; Rectangle bounds = e.AffectedBounds; if (toolStrip is ToolStripDropDown) { bool bDrawLogo = NeedDrawLogo(toolStrip); bool bRightToLeft = toolStrip.RightToLeft == RightToLeft.Yes; Rectangle imageBackRect = bounds; imageBackRect.Width = OffsetMargin; if (bDrawLogo) { Rectangle logoRect = bounds; logoRect.Width = OffsetMargin; if (bRightToLeft) { logoRect.X -= 2; imageBackRect.X = logoRect.X - OffsetMargin; } else { logoRect.X += 2; imageBackRect.X = logoRect.Right; } logoRect.Y += 1; logoRect.Height -= 2; using (LinearGradientBrush brush = new LinearGradientBrush( logoRect, ColorTable.BackHover, ColorTable.BackNormal, 90f)) { Blend blend = new Blend(); blend.Positions = new float[] { 0f, .2f, 1f }; blend.Factors = new float[] { 0f, 0.1f, .9f }; brush.Blend = blend; logoRect.Y += 1; logoRect.Height -= 2; using (GraphicsPath path = GraphicsPathHelper.CreatePath(logoRect, 8, RoundStyle.All, false)) { using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g)) { g.FillPath(brush, path); } } } StringFormat sf = new StringFormat(StringFormatFlags.NoWrap); Font font = new Font( toolStrip.Font.FontFamily, 11, FontStyle.Bold); sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Center; sf.Trimming = StringTrimming.EllipsisCharacter; g.TranslateTransform(logoRect.X, logoRect.Bottom); g.RotateTransform(270f); if (!string.IsNullOrEmpty(MenuLogoString)) { Rectangle newRect = new Rectangle( 0, 0, logoRect.Height, logoRect.Width); using (Brush brush = new SolidBrush(ColorTable.Fore)) { using (TextRenderingHintGraphics tg = new TextRenderingHintGraphics(g)) { g.DrawString( MenuLogoString, font, brush, newRect, sf); } } } g.ResetTransform(); } else { if (bRightToLeft) { imageBackRect.X -= 3; } else { imageBackRect.X += 3; } } imageBackRect.Y += 2; imageBackRect.Height -= 4; using (SolidBrush brush = new SolidBrush(ColorTable.DropDownImageBack)) { g.FillRectangle(brush, imageBackRect); } Point ponitStart; Point pointEnd; if (bRightToLeft) { ponitStart = new Point(imageBackRect.X, imageBackRect.Y); pointEnd = new Point(imageBackRect.X, imageBackRect.Bottom); } else { ponitStart = new Point(imageBackRect.Right - 1, imageBackRect.Y); pointEnd = new Point(imageBackRect.Right - 1, imageBackRect.Bottom); } using (Pen pen = new Pen(ColorTable.DropDownImageSeparator)) { g.DrawLine(pen, ponitStart, pointEnd); } } else { base.OnRenderImageMargin(e); } }
public AlphaBlendState(Blend sourceBlend, Blend destinationBlend) { _mode = 1; SourceBlend = sourceBlend; DestinationBlend = destinationBlend; }
public IBlendState CreateBlendState(bool isBlendEnabled, Blend sourceBlend, Blend destinationBlend, BlendOperation blendOperation, Blend sourceAlphaBlend, Blend destinationAlphaBlend, BlendOperation blendOperationAlpha) { throw new System.NotImplementedException(); }
/// <summary> /// Creates a new <see cref="BlendState"/> used to control the device's output merger blending behavior. /// </summary> /// <param name="isBlendEnabled">A value indicating whether blending is enabled in the <see cref="BlendState"/>.</param> /// <param name="srcBlend">The source blend factor.</param> /// <param name="destBlend">The destination blend factor.</param> /// <param name="blendFunc">The blend function.</param> /// <returns>A new <see cref="BlendState"/>.</returns> public BlendState CreateCustomBlendState( bool isBlendEnabled, Blend srcBlend, Blend destBlend, BlendFunction blendFunc) { return(CreateCustomBlendState(isBlendEnabled, srcBlend, destBlend, blendFunc, srcBlend, destBlend, blendFunc, RgbaFloat.Black)); }
public void Panorama_Example1() { Accord.Math.Random.Generator.Seed = 0; // Let's start with two pictures that have been // taken from slightly different points of view: // Bitmap img1 = Accord.Imaging.Image.Clone(Resources.dc_left); Bitmap img2 = Accord.Imaging.Image.Clone(Resources.dc_right); // Those pictures are shown below: // ImageBox.Show(img1, PictureBoxSizeMode.Zoom, 640, 480); // ImageBox.Show(img2, PictureBoxSizeMode.Zoom, 640, 480); // Step 1: Detect feature points using Surf Corners Detector var surf = new SpeededUpRobustFeaturesDetector(); var points1 = surf.ProcessImage(img1); var points2 = surf.ProcessImage(img2); // Step 2: Match feature points using a k-NN var matcher = new KNearestNeighborMatching(5); var matches = matcher.Match(points1, points2); // Step 3: Create the matrix using a robust estimator var ransac = new RansacHomographyEstimator(0.001, 0.99); MatrixH homographyMatrix = ransac.Estimate(matches); Assert.AreEqual(1.15707409, homographyMatrix.Elements[0], 1e-5); Assert.AreEqual(-0.0233834628, homographyMatrix.Elements[1], 1e-5); Assert.AreEqual(-261.8217, homographyMatrix.Elements[2], 1e-2); Assert.AreEqual(0.08801343, homographyMatrix.Elements[3], 1e-5); Assert.AreEqual(1.12451434, homographyMatrix.Elements[4], 1e-5); Assert.AreEqual(-171.191208, homographyMatrix.Elements[5], 1e-2); Assert.AreEqual(0.000127789128, homographyMatrix.Elements[6], 1e-5); Assert.AreEqual(0.00006173445, homographyMatrix.Elements[7], 1e-5); Assert.AreEqual(8, homographyMatrix.Elements.Length); // Step 4: Project and blend using the homography Blend blend = new Blend(homographyMatrix, img1); // Compute the blending algorithm Bitmap result = blend.Apply(img2); // Show on screen // ImageBox.Show(result, PictureBoxSizeMode.Zoom, 640, 480); result = Accord.Imaging.Image.Clone(result); #if NET35 // result.Save(@"C:\Projects\Accord.NET\framework\Unit Tests\Accord.Tests.Imaging\Resources\blend_net35.png", ImageFormat.Png); Bitmap image = Accord.Imaging.Image.Clone(Resources.blend_net35); #else // result.Save(@"C:\Projects\Accord.NET\framework\Unit Tests\Accord.Tests.Imaging\Resources\blend_net45.png", ImageFormat.Png); Bitmap image = Accord.Imaging.Image.Clone(Resources.blend_net45); #endif double[,] expected; new ImageToMatrix().Convert(image, out expected); double[,] actual; new ImageToMatrix().Convert(result, out actual); Assert.IsTrue(Matrix.IsEqual(expected, actual, atol: 0.1)); }
/// <summary> /// Creates a new <see cref="BlendState"/>, used to control blending behavior in the device's output merger. /// with separate factors for alpha and color blending. /// </summary> /// <param name="isBlendEnabled">A value indicating whether blending is enabled in the <see cref="BlendState"/>.</param> /// <param name="srcAlpha">The source alpha blend factor.</param> /// <param name="destAlpha">The destination alpha blend factor.</param> /// <param name="alphaBlendFunc">The alpha blend function.</param> /// <param name="srcColor">The source color blend factor.</param> /// <param name="destColor">The destenation color blend factor.</param> /// <param name="colorBlendFunc">The color blend function.</param> /// <param name="blendFactor">The blend factor to use for parameterized blend states.</param> /// <returns>A new <see cref="BlendState"/>.</returns> protected abstract BlendState CreateCustomBlendStateCore( bool isBlendEnabled, Blend srcAlpha, Blend destAlpha, BlendFunction alphaBlendFunc, Blend srcColor, Blend destColor, BlendFunction colorBlendFunc, RgbaFloat blendFactor);
protected override void OnRenderImageMargin( ToolStripRenderEventArgs e) { if (e.ToolStrip is ToolStripDropDownMenu) { Rectangle rect = e.AffectedBounds; Graphics g = e.Graphics; rect.Width = OffsetMargin; if (e.ToolStrip.RightToLeft == RightToLeft.Yes) { rect.X -= 2; } else { rect.X += 2; } rect.Y += 1; rect.Height -= 2; g.SmoothingMode = SmoothingMode.AntiAlias; using (LinearGradientBrush brush = new LinearGradientBrush( rect, ColorTable.BackColorHover, Color.White, 90f)) { Blend blend = new Blend(); blend.Positions = new float[] { 0f, .2f, 1f }; blend.Factors = new float[] { 0f, 0.1f, .9f }; brush.Blend = blend; rect.Y += 1; rect.Height -= 2; using (GraphicsPath path = GraphicsPathHelper.CreateFilletRectangle(rect, 8, RoundStyle.All, false)) { g.FillPath(brush, path); } } g.TextRenderingHint = TextRenderingHint.AntiAlias; StringFormat sf = new StringFormat(StringFormatFlags.NoWrap); Font font = new Font( e.ToolStrip.Font.FontFamily, 11, FontStyle.Bold); sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Center; sf.Trimming = StringTrimming.EllipsisCharacter; g.TranslateTransform(rect.X, rect.Bottom); g.RotateTransform(270f); if (!string.IsNullOrEmpty(MenuLogoString)) { Rectangle newRect = new Rectangle( rect.X, rect.Y, rect.Height, rect.Width); using (Brush brush = new SolidBrush(ColorTable.ForeColor)) { g.DrawString( MenuLogoString, font, brush, newRect, sf); } } g.ResetTransform(); return; } base.OnRenderImageMargin(e); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { SolidBrush _brush01, _brush; LinearGradientBrush _brush02, _brush03, _brush04; Pen _pen01, _pen02, _pen03, _pen04, _pen05, _pen06; int X = this.Width; int Y = this.Height; e.Graphics.CompositingQuality = CompositingQuality.GammaCorrected; int y = 0; int x = 0; Point point; int _y = (this.Height - this.Font.Height) / 2; if (image != null) { if (this.Text.Length == 0) { x = (X - image.Width) / 2; } else { x = BT.LeftMargin; } y = (this.Height - image.Height) / 2; point = new Point(BT.LeftMargin + image.Width + BT.TextMargin, _y); } else { Size size = GetTextSize(e.Graphics, this.Text, this.Font, this.Size); int textWidth = size.Width; point = new Point((X - textWidth) / 2, _y); } if (!this.Enabled) { switch (scheme) { case Schemes.OliveGreen: _brush = new SolidBrush(Color.FromArgb(64, 202, 196, 184)); _brush01 = new SolidBrush(Color.FromArgb(246, 242, 233)); _pen01 = new Pen(Color.FromArgb(202, 196, 184)); _pen02 = new Pen(Color.FromArgb(170, 202, 196, 184)); break; case Schemes.Silver: _brush = new SolidBrush(Color.FromArgb(64, 196, 195, 191)); _brush01 = new SolidBrush(Color.FromArgb(241, 241, 237)); _pen01 = new Pen(Color.FromArgb(196, 195, 191)); _pen02 = new Pen(Color.FromArgb(170, 196, 195, 191)); break; default: _brush = new SolidBrush(Color.FromArgb(64, 201, 199, 186)); _brush01 = new SolidBrush(Color.FromArgb(245, 244, 234)); _pen01 = new Pen(Color.FromArgb(201, 199, 186)); _pen02 = new Pen(Color.FromArgb(170, 201, 199, 186)); break; } e.Graphics.FillRectangle(_brush01, 2, 2, X - 4, Y - 4); e.Graphics.DrawLine(_pen01, 3, 1, X - 4, 1); e.Graphics.DrawLine(_pen01, 3, Y - 2, X - 4, Y - 2); e.Graphics.DrawLine(_pen01, 1, 3, 1, Y - 4); e.Graphics.DrawLine(_pen01, X - 2, 3, X - 2, Y - 4); e.Graphics.DrawLine(_pen02, 1, 2, 2, 1); e.Graphics.DrawLine(_pen02, 1, Y - 3, 2, Y - 2); e.Graphics.DrawLine(_pen02, X - 2, 2, X - 3, 1); e.Graphics.DrawLine(_pen02, X - 2, Y - 3, X - 3, Y - 2); e.Graphics.FillRectangles(_brush, rects1); if (image != null) { ControlPaint.DrawImageDisabled(e.Graphics, image, x, y, this.BackColor); } e.Graphics.DrawString(this.Text, this.Font, SystemBrushes.ControlDark, point); _brush.Dispose(); _brush01.Dispose(); _pen01.Dispose(); _pen02.Dispose(); return; } LinearGradientBrush _brush05, _brush06; switch (scheme) { case Schemes.OliveGreen: oliveBrush01 = new LinearGradientBrush(new Rectangle(2, 2, X - 5, Y - 7) , Color.FromArgb(255, 255, 246), Color.FromArgb(246, 243, 224), 90.0f); olivePen01 = new Pen(Color.FromArgb(243, 238, 219)); olivePen02 = new Pen(Color.FromArgb(236, 225, 201)); olivePen03 = new Pen(Color.FromArgb(227, 209, 184)); _brush05 = new LinearGradientBrush(new Rectangle(X - 3, 4, 1, Y - 5) , Color.FromArgb(251, 247, 232), Color.FromArgb(64, 216, 181, 144), 90.0f); _brush06 = new LinearGradientBrush(new Rectangle(X - 2, 4, 1, Y - 5) , Color.FromArgb(246, 241, 224), Color.FromArgb(64, 194, 156, 120), 90.0f); olivePen04 = new Pen(_brush05); olivePen05 = new Pen(_brush06); oliveBrush02 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 8) , Color.FromArgb(177, 203, 128), Color.FromArgb(144, 193, 84), 90.0f); olivePen06 = new Pen(Color.FromArgb(194, 209, 143)); olivePen07 = new Pen(Color.FromArgb(177, 203, 128)); olivePen08 = new Pen(Color.FromArgb(144, 193, 84)); olivePen09 = new Pen(Color.FromArgb(168, 167, 102)); oliveBrush03 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 8) , Color.FromArgb(237, 190, 150), Color.FromArgb(227, 145, 79), 90.0f); olivePen10 = new Pen(Color.FromArgb(252, 197, 149)); olivePen11 = new Pen(Color.FromArgb(237, 190, 150)); olivePen12 = new Pen(Color.FromArgb(227, 145, 79)); olivePen13 = new Pen(Color.FromArgb(207, 114, 37)); brush1 = new SolidBrush(Color.FromArgb(92, 109, 138, 77)); pen0 = new Pen(Color.FromArgb(55, 98, 6)); pen1 = new Pen(Color.FromArgb(109, 138, 77)); pen2 = new Pen(Color.FromArgb(192, 109, 138, 77)); _brush05.Dispose(); _brush06.Dispose(); break; case Schemes.Silver: silverBrush01 = new SolidBrush(Color.White); silverBrush02 = new LinearGradientBrush(new Rectangle(3, 3, X - 6, Y - 7) , Color.FromArgb(253, 253, 253), Color.FromArgb(201, 200, 220), 90.0f); silverBrush03 = new SolidBrush(Color.FromArgb(198, 197, 215)); float[] relativeIntensities = { 0.0f, 0.008f, 1.0f }; float[] relativePositions = { 0.0f, 0.32f, 1.0f }; Blend blend = new Blend(); blend.Factors = relativeIntensities; blend.Positions = relativePositions; silverBrush02.Blend = blend; blueBrush02 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 8) , Color.FromArgb(186, 211, 245), Color.FromArgb(137, 173, 228), 90.0f); bluePen06 = new Pen(Color.FromArgb(206, 231, 255)); bluePen07 = new Pen(Color.FromArgb(188, 212, 246)); bluePen08 = new Pen(Color.FromArgb(137, 173, 228)); bluePen09 = new Pen(Color.FromArgb(105, 130, 238)); blueBrush03 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 8) , Color.FromArgb(253, 216, 137), Color.FromArgb(248, 178, 48), 90.0f); bluePen10 = new Pen(Color.FromArgb(255, 240, 207)); bluePen11 = new Pen(Color.FromArgb(253, 216, 137)); bluePen12 = new Pen(Color.FromArgb(248, 178, 48)); bluePen13 = new Pen(Color.FromArgb(229, 151, 0)); brush1 = new SolidBrush(Color.FromArgb(92, 85, 125, 162)); pen0 = new Pen(Color.FromArgb(0, 60, 116)); pen1 = new Pen(Color.FromArgb(85, 125, 162)); pen2 = new Pen(Color.FromArgb(192, 85, 125, 162)); break; default: blueBrush01 = new LinearGradientBrush(new Rectangle(2, 2, X - 5, Y - 7) , Color.FromArgb(255, 255, 255), Color.FromArgb(240, 240, 234), 90.0f); blueBrush02 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 8) , Color.FromArgb(186, 211, 245), Color.FromArgb(137, 173, 228), 90.0f); bluePen01 = new Pen(Color.FromArgb(236, 235, 230)); bluePen02 = new Pen(Color.FromArgb(226, 223, 214)); bluePen03 = new Pen(Color.FromArgb(214, 208, 197)); _brush05 = new LinearGradientBrush(new Rectangle(X - 3, 4, 1, Y - 5) , Color.FromArgb(245, 244, 242), Color.FromArgb(64, 186, 174, 160), 90.0f); _brush06 = new LinearGradientBrush(new Rectangle(X - 2, 4, 1, Y - 5) , Color.FromArgb(240, 238, 234), Color.FromArgb(64, 175, 168, 142), 90.0f); bluePen04 = new Pen(_brush05); bluePen05 = new Pen(_brush06); bluePen06 = new Pen(Color.FromArgb(206, 231, 255)); bluePen07 = new Pen(Color.FromArgb(188, 212, 246)); bluePen08 = new Pen(Color.FromArgb(137, 173, 228)); bluePen09 = new Pen(Color.FromArgb(105, 130, 238)); blueBrush03 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 8) , Color.FromArgb(253, 216, 137), Color.FromArgb(248, 178, 48), 90.0f); bluePen10 = new Pen(Color.FromArgb(255, 240, 207)); bluePen11 = new Pen(Color.FromArgb(253, 216, 137)); bluePen12 = new Pen(Color.FromArgb(248, 178, 48)); bluePen13 = new Pen(Color.FromArgb(229, 151, 0)); brush1 = new SolidBrush(Color.FromArgb(92, 85, 125, 162)); pen0 = new Pen(Color.FromArgb(0, 60, 116)); pen1 = new Pen(Color.FromArgb(85, 125, 162)); pen2 = new Pen(Color.FromArgb(192, 85, 125, 162)); _brush05.Dispose(); _brush06.Dispose(); break; } LinearGradientBrush brush0 = new LinearGradientBrush(new Rectangle(0, 0, X, Y) , Color.FromArgb(64, 171, 168, 137), Color.FromArgb(92, 255, 255, 255), 85.0f); e.Graphics.FillRectangle(brush0, new Rectangle(0, 0, X, Y)); brush0.Dispose(); switch (state) { case States.Normal: switch (scheme) { case Schemes.Silver: e.Graphics.FillRectangle(silverBrush01, 2, 2, X - 4, Y - 4); e.Graphics.FillRectangle(silverBrush02, 3, 4, X - 6, Y - 8); e.Graphics.FillRectangle(silverBrush03, 2, Y - 4, X - 4, 2); if (selected) { _pen01 = new Pen(Color.White); e.Graphics.FillRectangles(blueBrush02, rects0); e.Graphics.DrawLine(_pen01, 3, 4, 3, Y - 4); e.Graphics.DrawLine(_pen01, X - 4, 4, X - 4, Y - 4); e.Graphics.DrawLine(bluePen06, 2, 2, X - 3, 2); e.Graphics.DrawLine(bluePen07, 2, 3, X - 3, 3); e.Graphics.DrawLine(bluePen08, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(bluePen09, 2, Y - 3, X - 3, Y - 3); _pen01.Dispose(); } break; case Schemes.OliveGreen: e.Graphics.FillRectangle(oliveBrush01, 2, 2, X - 4, Y - 7); e.Graphics.DrawLine(olivePen01, 2, Y - 5, X - 2, Y - 5); e.Graphics.DrawLine(olivePen02, 2, Y - 4, X - 2, Y - 4); e.Graphics.DrawLine(olivePen03, 2, Y - 3, X - 2, Y - 3); e.Graphics.DrawLine(olivePen04, X - 4, 4, X - 4, Y - 5); e.Graphics.DrawLine(olivePen05, X - 3, 4, X - 3, Y - 5); if (selected) { e.Graphics.FillRectangles(oliveBrush02, rects0); e.Graphics.DrawLine(olivePen06, 2, 2, X - 3, 2); e.Graphics.DrawLine(olivePen07, 2, 3, X - 3, 3); e.Graphics.DrawLine(olivePen08, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(olivePen09, 2, Y - 3, X - 3, Y - 3); } break; default: e.Graphics.FillRectangle(blueBrush01, 2, 2, X - 4, Y - 7); e.Graphics.DrawLine(bluePen01, 2, Y - 5, X - 2, Y - 5); e.Graphics.DrawLine(bluePen02, 2, Y - 4, X - 2, Y - 4); e.Graphics.DrawLine(bluePen03, 2, Y - 3, X - 2, Y - 3); e.Graphics.DrawLine(bluePen04, X - 4, 4, X - 4, Y - 5); e.Graphics.DrawLine(bluePen05, X - 3, 4, X - 3, Y - 5); if (selected) { e.Graphics.FillRectangles(blueBrush02, rects0); e.Graphics.DrawLine(bluePen06, 2, 2, X - 3, 2); e.Graphics.DrawLine(bluePen07, 2, 3, X - 3, 3); e.Graphics.DrawLine(bluePen08, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(bluePen09, 2, Y - 3, X - 3, Y - 3); } break; } break; case States.MouseOver: switch (scheme) { case Schemes.Silver: e.Graphics.FillRectangle(silverBrush01, 2, 2, X - 4, Y - 4); e.Graphics.FillRectangle(silverBrush02, 3, 4, X - 6, Y - 8); e.Graphics.FillRectangle(silverBrush03, 2, Y - 4, X - 4, 2); e.Graphics.FillRectangles(blueBrush03, rects0); e.Graphics.DrawLine(bluePen10, 2, 2, X - 3, 2); e.Graphics.DrawLine(bluePen11, 2, 3, X - 3, 3); e.Graphics.DrawLine(bluePen12, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(bluePen13, 2, Y - 3, X - 3, Y - 3); break; case Schemes.OliveGreen: e.Graphics.FillRectangle(oliveBrush01, 2, 2, X - 4, Y - 7); e.Graphics.DrawLine(olivePen01, 2, Y - 5, X - 4, Y - 5); e.Graphics.DrawLine(olivePen02, 2, Y - 4, X - 4, Y - 4); e.Graphics.DrawLine(olivePen03, 2, Y - 3, X - 4, Y - 3); e.Graphics.DrawLine(olivePen04, X - 4, 4, X - 4, Y - 5); e.Graphics.DrawLine(olivePen05, X - 3, 4, X - 3, Y - 5); e.Graphics.FillRectangles(oliveBrush03, rects0); e.Graphics.DrawLine(olivePen10, 2, 2, X - 3, 2); e.Graphics.DrawLine(olivePen11, 2, 3, X - 3, 3); e.Graphics.DrawLine(olivePen12, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(olivePen13, 2, Y - 3, X - 3, Y - 3); break; default: e.Graphics.FillRectangle(blueBrush01, 2, 2, X - 4, Y - 7); e.Graphics.DrawLine(bluePen01, 2, Y - 5, X - 4, Y - 5); e.Graphics.DrawLine(bluePen02, 2, Y - 4, X - 4, Y - 4); e.Graphics.DrawLine(bluePen03, 2, Y - 3, X - 4, Y - 3); e.Graphics.DrawLine(bluePen04, X - 4, 4, X - 4, Y - 5); e.Graphics.DrawLine(bluePen05, X - 3, 4, X - 3, Y - 5); e.Graphics.FillRectangles(blueBrush03, rects0); e.Graphics.DrawLine(bluePen10, 2, 2, X - 3, 2); e.Graphics.DrawLine(bluePen11, 2, 3, X - 3, 3); e.Graphics.DrawLine(bluePen12, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(bluePen13, 2, Y - 3, X - 3, Y - 3); break; } break; case States.Pushed: switch (scheme) { case Schemes.Silver: _brush01 = new SolidBrush(Color.White); _brush02 = new LinearGradientBrush(new Rectangle(3, 3, X - 5, Y - 8) , Color.FromArgb(172, 171, 191), Color.FromArgb(248, 252, 253), 90.0f); float[] relativeIntensities = { 0.0f, 0.992f, 1.0f }; float[] relativePositions = { 0.0f, 0.68f, 1.0f }; Blend blend = new Blend(); blend.Factors = relativeIntensities; blend.Positions = relativePositions; _brush02.Blend = blend; _pen01 = new Pen(Color.FromArgb(172, 171, 189)); e.Graphics.FillRectangle(_brush01, 2, 2, X - 4, Y - 4); e.Graphics.FillRectangle(_brush02, 3, 4, X - 6, Y - 9); e.Graphics.DrawLine(_pen01, 4, 3, X - 4, 3); _brush01.Dispose(); _brush02.Dispose(); _pen01.Dispose(); break; case Schemes.OliveGreen: _brush02 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 7) , Color.FromArgb(228, 212, 191), Color.FromArgb(229, 217, 195), 90.0f); _brush04 = new LinearGradientBrush(new Rectangle(3, 3, X - 4, Y - 7) , Color.FromArgb(232, 219, 197), Color.FromArgb(234, 224, 201), 90.0f); _brush03 = new LinearGradientBrush(new Rectangle(2, 2, X - 5, Y - 7) , Color.FromArgb(238, 230, 210), Color.FromArgb(236, 228, 206), 90.0f); _pen01 = new Pen(Color.FromArgb(223, 205, 180)); _pen02 = new Pen(Color.FromArgb(231, 217, 195)); _pen03 = new Pen(Color.FromArgb(242, 236, 216)); _pen04 = new Pen(Color.FromArgb(248, 244, 228)); _pen05 = new Pen(_brush02); _pen06 = new Pen(_brush04); e.Graphics.FillRectangle(_brush03, 2, 4, X - 4, Y - 8); e.Graphics.DrawLine(_pen05, 2, 3, 2, Y - 4); e.Graphics.DrawLine(_pen06, 3, 3, 3, Y - 4); e.Graphics.DrawLine(_pen01, 2, 2, X - 3, 2); e.Graphics.DrawLine(_pen02, 2, 3, X - 3, 3); e.Graphics.DrawLine(_pen03, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(_pen04, 2, Y - 3, X - 3, Y - 3); _brush02.Dispose(); _brush03.Dispose(); _brush04.Dispose(); _pen01.Dispose(); _pen02.Dispose(); _pen03.Dispose(); _pen04.Dispose(); _pen05.Dispose(); _pen06.Dispose(); break; default: _brush02 = new LinearGradientBrush(new Rectangle(2, 3, X - 4, Y - 7) , Color.FromArgb(216, 212, 203), Color.FromArgb(218, 216, 207), 90.0f); _brush04 = new LinearGradientBrush(new Rectangle(3, 3, X - 4, Y - 7) , Color.FromArgb(221, 218, 209), Color.FromArgb(223, 222, 214), 90.0f); _brush03 = new LinearGradientBrush(new Rectangle(2, 2, X - 5, Y - 7) , Color.FromArgb(229, 228, 221), Color.FromArgb(226, 226, 218), 90.0f); _pen01 = new Pen(Color.FromArgb(209, 204, 192)); _pen02 = new Pen(Color.FromArgb(220, 216, 207)); _pen03 = new Pen(Color.FromArgb(234, 233, 227)); _pen04 = new Pen(Color.FromArgb(242, 241, 238)); _pen05 = new Pen(_brush02); _pen06 = new Pen(_brush04); e.Graphics.FillRectangle(_brush03, 2, 4, X - 4, Y - 8); e.Graphics.DrawLine(_pen05, 2, 3, 2, Y - 4); e.Graphics.DrawLine(_pen06, 3, 3, 3, Y - 4); e.Graphics.DrawLine(_pen01, 2, 2, X - 3, 2); e.Graphics.DrawLine(_pen02, 2, 3, X - 3, 3); e.Graphics.DrawLine(_pen03, 2, Y - 4, X - 3, Y - 4); e.Graphics.DrawLine(_pen04, 2, Y - 3, X - 3, Y - 3); _brush02.Dispose(); _brush03.Dispose(); _brush04.Dispose(); _pen01.Dispose(); _pen02.Dispose(); _pen03.Dispose(); _pen04.Dispose(); _pen05.Dispose(); _pen06.Dispose(); break; } break; } if (image != null) { e.Graphics.DrawImage(image, x, y); } e.Graphics.DrawString(this.Text, this.Font, SystemBrushes.ControlText, point); e.Graphics.DrawLine(pen1, 1, 3, 3, 1); e.Graphics.DrawLine(pen1, X - 2, 3, X - 4, 1); e.Graphics.DrawLine(pen1, 1, Y - 4, 3, Y - 2); e.Graphics.DrawLine(pen1, X - 2, Y - 4, X - 4, Y - 2); e.Graphics.DrawLine(pen2, 1, 2, 2, 1); e.Graphics.DrawLine(pen2, 1, Y - 3, 2, Y - 2); e.Graphics.DrawLine(pen2, X - 2, 2, X - 3, 1); e.Graphics.DrawLine(pen2, X - 2, Y - 3, X - 3, Y - 2); e.Graphics.DrawLine(pen0, 3, 1, X - 4, 1); e.Graphics.DrawLine(pen0, 3, Y - 2, X - 4, Y - 2); e.Graphics.DrawLine(pen0, 1, 3, 1, Y - 4); e.Graphics.DrawLine(pen0, X - 2, 3, X - 2, Y - 4); e.Graphics.FillRectangles(brush1, rects1); DisposePensBrushes(); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fillStyle"></param> /// <param name="backColor"></param> /// <param name="fadeColor"></param> /// <param name="borderStyle"></param> /// <param name="borderColor"></param> /// <param name="graphics"></param> private static void OnPaintBackgroundClassic(int x, int y, int width, int height, FillStyle fillStyle, Color backColor, Color fadeColor, BorderStyle borderStyle, Color borderColor, Graphics graphics) { if (height == 0) { height = 4; } if (width == 0) { width = 4; } if (fillStyle == FillStyle.VistaFading) { Brush brush1 = null, brush2 = null, brush3 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); brush3 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 2), Color.FromArgb(50, ColorManager.ModifyBrightness(backColor, 0.15)), Color.FromArgb(10, ColorManager.ModifyBrightness(backColor, 1.4)), LinearGradientMode.Vertical); Blend bl = new Blend(); bl.Factors = new float[] { 0f, 0.0f, 0.05f, 1.0f }; bl.Positions = new float[] { 0, 0.5f, 0.55f, 1.0f }; ((LinearGradientBrush)brush3).Blend = bl; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f) + 1); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 2); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush3, x + 1, y + (int)((float)height / 2.0f) - 1, width - 3, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); brush3.Dispose(); } else if (fillStyle == FillStyle.VerticalCentreFading) { Brush brush1 = null, brush2 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f)); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); } else { Brush brush = null; if (fillStyle == FillStyle.DiagonalBackward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.BackwardDiagonal); } else if (fillStyle == FillStyle.DiagonalForward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.ForwardDiagonal); } else if (fillStyle == FillStyle.Flat) { brush = new SolidBrush(backColor); } else if (fillStyle == FillStyle.HorizontalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.Horizontal); } else if (fillStyle == FillStyle.VerticalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), fadeColor, backColor, LinearGradientMode.Vertical); //brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), // backColor, fadeColor, LinearGradientMode.Vertical); } graphics.FillRectangle(brush, x, y, width, height); brush.Dispose(); } // now render the other part a bit if (borderStyle == BorderStyle.Dot) { Pen pen = new Pen(borderColor); pen.DashStyle = DashStyle.Dot; graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } else if (borderStyle == BorderStyle.Solid) { Pen pen = new Pen(borderColor); graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } }
/// ------------------------------------------------------------------------------------ protected virtual void DrawWave(PaintEventArgs e, Rectangle rc) { if (!e.ClipRectangle.IntersectsWith(rc)) { return; } var channelRects = GetChannelDisplayRectangles(rc).ToArray(); var dyChannelXAxes = new int[_channels]; // Calculate the midpoint of each rectangle. for (int c = 0; c < _channels; c++) { dyChannelXAxes[c] = channelRects[c].Y + (int)Math.Ceiling(channelRects[c].Height / 2f); } // Draw the X axis through middle of each channel's rectangle. using (var pen = new Pen(ForeColor)) { foreach (var xAxis in dyChannelXAxes) { e.Graphics.DrawLine(pen, rc.X, xAxis, rc.Right, xAxis); } } // If samples per pixel is small or less than zero, we are out of zoom range, so don't display anything. if (SamplesPerPixel <= 0.0000000001d) { return; } // SP-998: If _smaplesToDraw is null, it apparently hasn't been set yet. Not sure how this can happen, // and we haven't been able to reproduce it, but let's hope it's a timing issue and // the problem magically corrects itself. if (_samplesToDraw == null) { Logger.WriteEvent("DrawWave called with null _samplesToDraw. Possible timing issue? (See SP-998)"); return; } // Samples will span from some value between -1 and +1, inclusively. // The top of the client area represents +1 and the bottom represents -1. var blend = new Blend(); blend.Positions = new[] { 0f, 0.15f, 0.5f, 0.85f, 1.0f }; blend.Factors = new[] { 0.65f, 0.85f, 1.0f, 0.85f, 0.65f }; for (int x = e.ClipRectangle.X; x < e.ClipRectangle.X + e.ClipRectangle.Width; x++) { if (x < rc.X) { continue; } var sampleToDraw = x + _offsetOfLeftEdge - rc.X; if (sampleToDraw >= _samplesToDraw.GetLength(0)) { break; } for (int channel = 0; channel < _channels; channel++) { var sampleAmplitudes = _samplesToDraw[sampleToDraw, channel]; if (sampleAmplitudes == null) { var event_msg = "'sampleAmplitudes' was null; 'sampleToDraw' or 'channel' possibly off by one (See SP-1799).\r\n sampleToDraw = {0}\r\n channel = {1}\r\n dimensions = _samplesToDraw[{2}, {3}]"; Logger.WriteEvent(event_msg, sampleToDraw, channel, _samplesToDraw.GetLength(0), _samplesToDraw.GetLength(1)); continue; } if (sampleAmplitudes.Item1.Equals(0f) && sampleAmplitudes.Item2.Equals(0f)) { continue; } int y1 = dyChannelXAxes[channel] - (int)Math.Ceiling(channelRects[channel].Height * (sampleAmplitudes.Item1 / 2f)); int y2 = dyChannelXAxes[channel] - (int)Math.Ceiling(channelRects[channel].Height * (sampleAmplitudes.Item2 / 2f)); if (y2 - y1 <= 1) { continue; } var pt1 = new Point(x, y1); var pt2 = new Point(x, y2); using (var br = new LinearGradientBrush(pt1, pt2, BackColor, ForeColor)) { br.Blend = blend; using (var pen = new Pen(br)) e.Graphics.DrawLine(pen, pt1, pt2); } } } }
public GL10() { int num; this.color = new float[4]; this.clearColor = Color.Black; this.ColorWriteChannels = ColorWriteChannels.All; this.AlphaDestinationBlend = Blend.InverseSourceAlpha; this.depthFunc = CompareFunction.Always; this.textureFilter = TextureFilter.Linear; this.textureAddressU = TextureAddressMode.Clamp; this.textureAddressV = TextureAddressMode.Clamp; this.vertex = new Vertex[8]; this.texture = new Texture[0x100]; this.matrixStack = new Stack<Matrix>(); this.effect = new BasicEffect(GLEx.device); this.effect.VertexColorEnabled = true; this.alphaTestEffect = new AlphaTestEffect(GLEx.device); this.alphaTestEffect.VertexColorEnabled = true; for (num = 0; num < this.vertex.Length; num++) { this.vertex[num] = new Vertex(); } for (num = 0; num < 4; num++) { this.color[num] = 1f; } }
private void RenderItemBackgroundPressed(System.Windows.Forms.ToolStripItemRenderEventArgs e) { if (Theme.Standard.Style == RibbonOrbStyle.Office_2013) { Rectangle rectBorder = new Rectangle(1, 1, e.Item.Width - 1, e.Item.Height - 1); Rectangle rect = new Rectangle(2, 2, e.Item.Width - 2, e.Item.Height - 2); using (SolidBrush b = new SolidBrush(Theme.Standard.RendererColorTable.ButtonPressed_2013)) { using (SolidBrush sb = new SolidBrush(Theme.Standard.RendererColorTable.ButtonBorderOut)) { e.Graphics.FillRectangle(sb, rectBorder); } e.Graphics.FillRectangle(b, rect); } } else { Rectangle rectBorder = new Rectangle(1, 1, e.Item.Width - 1, e.Item.Height - 1); Rectangle rect = new Rectangle(2, 2, e.Item.Width - 2, e.Item.Height - 2); Rectangle innerR = Rectangle.FromLTRB(1, 1, e.Item.Width - 2, e.Item.Height - 2); Rectangle glossyR = Rectangle.FromLTRB(1, 1, e.Item.Width - 2, 1 + Convert.ToInt32((double)e.Item.Bounds.Height * .36)); using (SolidBrush brus = new SolidBrush(Theme.Standard.RendererColorTable.ButtonPressedBgOut)) { e.Graphics.FillRectangle(brus, rectBorder); } //Border using (Pen p = new Pen(Theme.Standard.RendererColorTable.ButtonPressedBorderOut)) { e.Graphics.DrawRectangle(p, rectBorder); } //Inner border Rectangle RoundedRect = Rectangle.Round(innerR); using (Pen p = new Pen(Theme.Standard.RendererColorTable.ButtonPressedBorderIn)) { e.Graphics.DrawRectangle(p, RoundedRect); } #region Main Bg using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(new Rectangle(1, 1, e.Item.Width, e.Item.Height * 2)); path.CloseFigure(); using (PathGradientBrush gradient = new PathGradientBrush(path)) { gradient.WrapMode = WrapMode.Clamp; gradient.CenterPoint = new PointF(Convert.ToSingle(1 + e.Item.Width / 2), Convert.ToSingle(e.Item.Bounds.Height)); gradient.CenterColor = Theme.Standard.RendererColorTable.ButtonPressedBgCenter; gradient.SurroundColors = new Color[] { Theme.Standard.RendererColorTable.ButtonPressedBgOut }; Blend blend = new Blend(3); blend.Factors = new float[] { 0f, 0.8f, 0f }; blend.Positions = new float[] { 0f, 0.30f, 1f }; Region lastClip = e.Graphics.Clip; Region newClip = new Region(rectBorder); newClip.Intersect(lastClip); e.Graphics.SetClip(newClip.GetBounds(e.Graphics)); e.Graphics.FillPath(gradient, path); e.Graphics.Clip = lastClip; } } #endregion //Glossy effect using (GraphicsPath path = new GraphicsPath()) { path.AddRectangle(Rectangle.Round(glossyR)); using (LinearGradientBrush b = new LinearGradientBrush(glossyR, Theme.Standard.RendererColorTable.ButtonPressedGlossyNorth, Theme.Standard.RendererColorTable.ButtonPressedGlossySouth, 90)) { b.WrapMode = WrapMode.TileFlipXY; e.Graphics.FillPath(b, path); } } } }
/// <summary> /// /// </summary> /// <param name="blend"></param> /// <param name="factor"></param> /// <returns></returns> public bool SetBlendMode(Blend blend, byte factor) { return TLN_SetLayerBlendMode(index, blend, factor); }
public static extern bool SetSpriteBlendMode(int nsprite, Blend mode, byte factor);
public static void BlendFunc(Blend source, Blend destination) { uint cmd = (11 << 24) | ((uint)source << 3) | (uint)destination; GDTransport.cmd32(cmd); }
internal static BlendingFactorDest ConvertBlendDest(Blend blend) => (BlendingFactorDest)ConvertBlendSrc(blend);
public GL() { int num; camera = new GLExCamera(); camera.viewMatrix = camera.Result; this.rstateScissor = new RasterizerState(); this.rstateScissor.CullMode = CullMode.None; this.rstateScissor.ScissorTestEnable = true; this.color = new float[4]; this.clearColor = Color.Black; this.ColorWriteChannels = Microsoft.Xna.Framework.Graphics.ColorWriteChannels.All; this.AlphaDestinationBlend = Blend.InverseSourceAlpha; this.depthFunc = CompareFunction.Always; this.vertex = new Vertex[8]; sTextures.Add(null); this.matrixStack = new Stack<Matrix>(); this.matrixStack.Push(Matrix.Identity); this.effect = new BasicEffect(device); this.effect.VertexColorEnabled = true; this.effect.Projection = Microsoft.Xna.Framework.Matrix.CreateOrthographicOffCenter(0f, LSystem.screenRect.width, LSystem.screenRect.height, 0f, -1.0f, 1.0f); this.alphaTestEffect = new AlphaTestEffect(device); this.alphaTestEffect.VertexColorEnabled = true; device.RasterizerState = RasterizerState.CullNone; device.DepthStencilState = DepthStencilState.None; for (num = 0; num < this.vertex.Length; num++) { this.vertex[num] = new Vertex(); } for (num = 0; num < 4; num++) { this.color[num] = 1f; } EnableTextures(); }
protected virtual void OnRenderThumb(PaintThumbEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; ControlState state = e.ControlState; ThumbArrowDirection direction = ThumbArrowDirection.None; Color begin = ColorTable.ThumbBackNormal; Color end = ColorTable.TrackInnerBorder; Color border = ColorTable.ThumbBorderNormal; float mode = base.Orientation == Orientation.Horizontal ? 90f : 0f; switch (base.Orientation) { case Orientation.Horizontal: switch (base.TickStyle) { case TickStyle.None: case TickStyle.BottomRight: direction = ThumbArrowDirection.Down; break; case TickStyle.TopLeft: direction = ThumbArrowDirection.Up; break; case TickStyle.Both: direction = ThumbArrowDirection.None; break; } break; case Orientation.Vertical: switch (base.TickStyle) { case TickStyle.TopLeft: direction = ThumbArrowDirection.Left; break; case TickStyle.None: case TickStyle.BottomRight: direction = ThumbArrowDirection.Right; break; case TickStyle.Both: direction = ThumbArrowDirection.None; break; } break; } switch (state) { case ControlState.Hover: begin = ColorTable.ThumbBackHover; border = ColorTable.ThumbBorderHover; break; } using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g)) { using (GraphicsPath path = GraphicsPathHelper.CreateTrackBarThumbPath( rect, direction)) { using (LinearGradientBrush brush = new LinearGradientBrush( rect, begin, end, mode)) { Blend blend = new Blend(); blend.Positions = new float[] { 0, .2f, .5f, .8f, 1f }; blend.Factors = new float[] { 1f, .7f, 0, .7f, 1f }; brush.Blend = blend; g.FillPath(brush, path); } using (Pen pen = new Pen(border)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreateTrackBarThumbPath( rect, direction)) { using (Pen pen = new Pen(ColorTable.TrackInnerBorder)) { g.DrawPath(pen, path); } } } }
public void SetBlendState(BlendState blendState) { bool newEnable = ( !( blendState.ColorSourceBlend == Blend.One && blendState.ColorDestinationBlend == Blend.Zero && blendState.AlphaSourceBlend == Blend.One && blendState.AlphaDestinationBlend == Blend.Zero ) ); if (newEnable != alphaBlendEnable) { alphaBlendEnable = newEnable; ToggleGLState(GLenum.GL_BLEND, alphaBlendEnable); } if (alphaBlendEnable) { if (blendState.BlendFactor != blendColor) { blendColor = blendState.BlendFactor; glBlendColor( blendColor.R / 255.0f, blendColor.G / 255.0f, blendColor.B / 255.0f, blendColor.A / 255.0f ); } if ( blendState.ColorSourceBlend != srcBlend || blendState.ColorDestinationBlend != dstBlend || blendState.AlphaSourceBlend != srcBlendAlpha || blendState.AlphaDestinationBlend != dstBlendAlpha ) { srcBlend = blendState.ColorSourceBlend; dstBlend = blendState.ColorDestinationBlend; srcBlendAlpha = blendState.AlphaSourceBlend; dstBlendAlpha = blendState.AlphaDestinationBlend; glBlendFuncSeparate( XNAToGL.BlendMode[(int) srcBlend], XNAToGL.BlendMode[(int) dstBlend], XNAToGL.BlendMode[(int) srcBlendAlpha], XNAToGL.BlendMode[(int) dstBlendAlpha] ); } if ( blendState.ColorBlendFunction != blendOp || blendState.AlphaBlendFunction != blendOpAlpha ) { blendOp = blendState.ColorBlendFunction; blendOpAlpha = blendState.AlphaBlendFunction; glBlendEquationSeparate( XNAToGL.BlendEquation[(int) blendOp], XNAToGL.BlendEquation[(int) blendOpAlpha] ); } } if (blendState.ColorWriteChannels != colorWriteEnable) { colorWriteEnable = blendState.ColorWriteChannels; glColorMask( (colorWriteEnable & ColorWriteChannels.Red) != 0, (colorWriteEnable & ColorWriteChannels.Green) != 0, (colorWriteEnable & ColorWriteChannels.Blue) != 0, (colorWriteEnable & ColorWriteChannels.Alpha) != 0 ); } /* FIXME: So how exactly do we factor in * COLORWRITEENABLE for buffer 0? Do we just assume that * the default is just buffer 0, and all other calls * update the other write masks afterward? Or do we * assume that COLORWRITEENABLE only touches 0, and the * other 3 buffers are left alone unless we don't have * EXT_draw_buffers2? * -flibit */ if (blendState.ColorWriteChannels1 != colorWriteEnable1) { colorWriteEnable1 = blendState.ColorWriteChannels1; glColorMaskIndexedEXT( 1, (colorWriteEnable1 & ColorWriteChannels.Red) != 0, (colorWriteEnable1 & ColorWriteChannels.Green) != 0, (colorWriteEnable1 & ColorWriteChannels.Blue) != 0, (colorWriteEnable1 & ColorWriteChannels.Alpha) != 0 ); } if (blendState.ColorWriteChannels2 != colorWriteEnable2) { colorWriteEnable2 = blendState.ColorWriteChannels2; glColorMaskIndexedEXT( 2, (colorWriteEnable2 & ColorWriteChannels.Red) != 0, (colorWriteEnable2 & ColorWriteChannels.Green) != 0, (colorWriteEnable2 & ColorWriteChannels.Blue) != 0, (colorWriteEnable2 & ColorWriteChannels.Alpha) != 0 ); } if (blendState.ColorWriteChannels3 != colorWriteEnable3) { colorWriteEnable3 = blendState.ColorWriteChannels3; glColorMaskIndexedEXT( 3, (colorWriteEnable3 & ColorWriteChannels.Red) != 0, (colorWriteEnable3 & ColorWriteChannels.Green) != 0, (colorWriteEnable3 & ColorWriteChannels.Blue) != 0, (colorWriteEnable3 & ColorWriteChannels.Alpha) != 0 ); } if (blendState.MultiSampleMask != multisampleMask && supportsMultisampling) { if (blendState.MultiSampleMask == -1) { glDisable(GLenum.GL_SAMPLE_MASK); } else { if (multisampleMask == -1) { glEnable(GLenum.GL_SAMPLE_MASK); } // FIXME: index...? -flibit glSampleMaski(0, (uint) blendState.MultiSampleMask); } multisampleMask = blendState.MultiSampleMask; } }
private BlendState(string name, Blend sourceBlend, Blend destinationBlend) : this() { Name = name; ColorSourceBlend = sourceBlend; AlphaSourceBlend = sourceBlend; ColorDestinationBlend = destinationBlend; AlphaDestinationBlend = destinationBlend; _defaultStateObject = true; }
internal static int BlendToOgl(Blend blend, bool isForAlpha = false) { switch (blend) { case Blend.Zero: return (int)BlendingFactorSrc.Zero; case Blend.One: return (int)BlendingFactorSrc.One; case Blend.SourceColor: return (int)BlendingFactorDest.SrcColor; case Blend.InverseSourceColor: return (int)BlendingFactorDest.OneMinusSrcColor; case Blend.SourceAlpha: return (int)BlendingFactorSrc.SrcAlpha; case Blend.InverseSourceAlpha: return (int)BlendingFactorSrc.OneMinusSrcAlpha; case Blend.DestinationAlpha: return (int)BlendingFactorSrc.DstAlpha; case Blend.InverseDestinationAlpha: return (int)BlendingFactorSrc.OneMinusDstAlpha; case Blend.DestinationColor: return (int)BlendingFactorSrc.DstColor; case Blend.InverseDestinationColor: return (int)BlendingFactorSrc.OneMinusDstColor; case Blend.BlendFactor: return (int)((isForAlpha) ? BlendingFactorSrc.ConstantAlpha : BlendingFactorSrc.ConstantColor); case Blend.InverseBlendFactor: return (int)((isForAlpha) ? BlendingFactorSrc.OneMinusConstantAlpha : BlendingFactorSrc.OneMinusConstantColor); // Ignored... // case Blend.SourceAlphaSaturated: // break; //case Blend.Bothsrcalpha: // break; //case Blend.BothInverseSourceAlpha: // break; //case Blend.SourceColor2: // break; //case Blend.InverseSourceColor2: // break; default: throw new ArgumentOutOfRangeException("blend"); } }
/// <summary> /// 填充线性渐变 /// </summary> /// <param name="g">画布</param> /// <param name="rect">填充区域</param> /// <param name="startcolor">开始颜色</param> /// <param name="endcolor">结束颜色</param> /// <param name="angle">角度</param> /// <param name="blend">对象的混合图案</param> private void FillLineGradient(Graphics g, Rectangle rect, Color startcolor, Color endcolor, float angle, Blend blend) { LinearGradientBrush linebrush = new LinearGradientBrush(rect, startcolor, endcolor, angle); if (blend != null) { linebrush.Blend = blend; } GraphicsPath path = new GraphicsPath(); path.AddRectangle(rect); g.SmoothingMode = SmoothingMode.AntiAlias; g.FillPath(linebrush, path); }
static Blend CreateBlend(Document doc) { Debug.Assert(doc.IsFamilyDocument, "this method will only work in a family document"); Application app = doc.Application; Autodesk.Revit.Creation.Application creApp = app.Create; Autodesk.Revit.Creation.FamilyItemFactory factory = doc.FamilyCreate; double startAngle = 0; double midAngle = Math.PI; double endAngle = 2 * Math.PI; XYZ xAxis = XYZ.BasisX; XYZ yAxis = XYZ.BasisY; XYZ center = XYZ.Zero; XYZ normal = -XYZ.BasisZ; double radius = 0.7579; //Arc arc1 = creApp.NewArc( center, radius, startAngle, midAngle, xAxis, yAxis ); // 2013 //Arc arc2 = creApp.NewArc( center, radius, midAngle, endAngle, xAxis, yAxis ); // 2013 Arc arc1 = Arc.Create(center, radius, startAngle, midAngle, xAxis, yAxis); // 2014 Arc arc2 = Arc.Create(center, radius, midAngle, endAngle, xAxis, yAxis); // 2014 CurveArray baseProfile = new CurveArray(); baseProfile.Append(arc1); baseProfile.Append(arc2); // create top profile: CurveArray topProfile = new CurveArray(); bool circular_top = false; if (circular_top) { // create a circular top profile: XYZ center2 = new XYZ(0, 0, 1.27); //Arc arc3 = creApp.NewArc( center2, radius, startAngle, midAngle, xAxis, yAxis ); // 2013 //Arc arc4 = creApp.NewArc( center2, radius, midAngle, endAngle, xAxis, yAxis ); // 2013 Arc arc3 = Arc.Create(center2, radius, startAngle, midAngle, xAxis, yAxis); // 2014 Arc arc4 = Arc.Create(center2, radius, midAngle, endAngle, xAxis, yAxis); // 2014 topProfile.Append(arc3); topProfile.Append(arc4); } else { // create a skewed rectangle top profile: XYZ[] pts = new XYZ[] { new XYZ(0, 0, 3), new XYZ(2, 0, 3), new XYZ(3, 2, 3), new XYZ(0, 4, 3) }; for (int i = 0; i < 4; ++i) { //topProfile.Append( creApp.NewLineBound( // 2013 topProfile.Append(Line.CreateBound( // 2014 pts[0 == i ? 3 : i - 1], pts[i])); } } //Plane basePlane = creApp.NewPlane( normal, center ); // 2016 Plane basePlane = Plane.CreateByNormalAndOrigin(normal, center); // 2017 //SketchPlane sketch = factory.NewSketchPlane( basePlane ); // 2013 SketchPlane sketch = SketchPlane.Create(doc, basePlane); // 2014 Blend blend = factory.NewBlend(true, topProfile, baseProfile, sketch); return(blend); }
void HandleInput() { KeyboardState prevKeyState = keyboardState; keyboardState = Keyboard.GetState(); mouseState = Mouse.GetState(); // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || keyboardState.IsKeyDown(Keys.Escape)) this.Exit(); if (GAME_WINDOW.Focused) { #region mode // MODE if (keyboardState.IsKeyDown(Keys.Z) && prevKeyState != keyboardState) { DRAW_MODE = false; CurrentMode = GameMode.PlayMode; form1.Hide(); } if (keyboardState.IsKeyDown(Keys.X) && prevKeyState != keyboardState) { DRAW_MODE = false; CurrentMode = GameMode.MoveMode; form1.Hide(); } if (keyboardState.IsKeyDown(Keys.C) && prevKeyState != keyboardState) { DRAW_MODE = true; BigChangeList = new List<int>(); CurrentMode = GameMode.TerrainMode; form1.Hide(); } if (keyboardState.IsKeyDown(Keys.V) && prevKeyState != keyboardState) { DRAW_MODE = true; BigChangeList = new List<int>(); CurrentMode = GameMode.ScriptMode; form1.Show(); GAME_WINDOW.Activate(); } #endregion } if (CurrentMode == GameMode.TerrainMode) { #region lights if (keyboardState.IsKeyDown(Keys.P)) { lightPower += 0.1f; } if (keyboardState.IsKeyDown(Keys.O)) { lightPower -= 0.1f; } if (keyboardState.IsKeyDown(Keys.L)) { ambientPower += 0.1f; } if (keyboardState.IsKeyDown(Keys.K)) { ambientPower -= 0.1f; } if (keyboardState.IsKeyDown(Keys.U) && prevKeyState != keyboardState) { lightDir.X += 1.0f; } if (keyboardState.IsKeyDown(Keys.I) && prevKeyState != keyboardState) { lightDir.X -= 1.0f; } if (keyboardState.IsKeyDown(Keys.J) && prevKeyState != keyboardState) { lightDir.Y += 1.0f; } if (keyboardState.IsKeyDown(Keys.H) && prevKeyState != keyboardState) { lightDir.Y -= 1.0f; } if (keyboardState.IsKeyDown(Keys.N) && prevKeyState != keyboardState) { lightDir.Z += 1.0f; } if (keyboardState.IsKeyDown(Keys.B) && prevKeyState != keyboardState) { lightDir.Z -= 1.0f; } #endregion lights #region render/decals if (keyboardState.IsKeyDown(Keys.NumPad1) && prevKeyState != keyboardState) { // TOON LIGHTING toonLighting = toonLighting ? false : true; } if (keyboardState.IsKeyDown(Keys.NumPad2) && prevKeyState != keyboardState) { // DRAW TEXT drawText = drawText ? false : true; } if (keyboardState.IsKeyDown(Keys.NumPad4) && prevKeyState != keyboardState) { // EDGE DETECT edgeDetect = edgeDetect ? false : true; } if (keyboardState.IsKeyDown(Keys.NumPad9) && prevKeyState != keyboardState) { // blend factor blendEnumS += 1; } if (keyboardState.IsKeyDown(Keys.NumPad6) && prevKeyState != keyboardState) { // blend factor blendEnumS -= 1; } if (keyboardState.IsKeyDown(Keys.NumPad8) && prevKeyState != keyboardState) { // blend factor blendEnumD += 1; } if (keyboardState.IsKeyDown(Keys.NumPad5) && prevKeyState != keyboardState) { // blend factor blendEnumD -= 1; } #endregion render/decals #region edgedetect //float NormalThreshold = 0.5; //float DepthThreshold = 0.1; if (keyboardState.IsKeyDown(Keys.D2) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { NormalThreshold += 0.05f; } if (keyboardState.IsKeyDown(Keys.D1) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { NormalThreshold -= 0.05f; } if (keyboardState.IsKeyDown(Keys.D2) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { DepthThreshold += 0.01f; } if (keyboardState.IsKeyDown(Keys.D1) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { DepthThreshold -= 0.01f; } //float NormalSensitivity = 1; //float DepthSensitivity = 10; if (keyboardState.IsKeyDown(Keys.D4) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { NormalSensitivity += 0.05f; } if (keyboardState.IsKeyDown(Keys.D3) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { NormalSensitivity -= 0.05f; } if (keyboardState.IsKeyDown(Keys.D4) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { DepthSensitivity += 1.0f; } if (keyboardState.IsKeyDown(Keys.D3) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { DepthSensitivity -= 1.0f; } //float EdgeWidth = 1; //float EdgeIntensity = 1; if (keyboardState.IsKeyDown(Keys.D6) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { EdgeWidth += 0.05f; } if (keyboardState.IsKeyDown(Keys.D5) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { EdgeWidth -= 0.05f; } if (keyboardState.IsKeyDown(Keys.D6) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { EdgeIntensity += 0.05f; } if (keyboardState.IsKeyDown(Keys.D5) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { EdgeIntensity -= 0.05f; } #endregion #region tank_scale if (mouseState.ScrollWheelValue > prevMouseState.ScrollWheelValue) { playerTank.scale += playerTank.scale * (0.1f); } if (mouseState.ScrollWheelValue < prevMouseState.ScrollWheelValue) { playerTank.scale -= playerTank.scale * (0.1f); } #endregion tank_scale } if (CurrentMode == GameMode.TerrainMode) { #region drawmode //------- DRAW_MODE------------------------ if (mouseState.LeftButton == ButtonState.Pressed) { drawModeString = "Clicked."; ClickInDrawMode(); } if (mouseState.LeftButton == ButtonState.Released) { if (BigChangeList.Count > 0) { ChangeVerticies(changeHeight); } } if (keyboardState.IsKeyDown(Keys.OemMinus) && prevKeyState != keyboardState) { brushWidth -= 1; } if (keyboardState.IsKeyDown(Keys.OemPlus) && prevKeyState != keyboardState) { brushWidth += 1; } if (keyboardState.IsKeyDown(Keys.D0) && prevKeyState != keyboardState) { changeHeight += 0.25f; } if (keyboardState.IsKeyDown(Keys.D9) && prevKeyState != keyboardState) { changeHeight -= 0.25f; } if (keyboardState.IsKeyDown(Keys.D1) && prevKeyState != keyboardState) { mouseCamera.cameraPosition = CAM_POSITION1; mouseCamera.leftrightRot = 0; mouseCamera.updownRot = -MathHelper.PiOver2; } #endregion } if (CurrentMode == GameMode.MoveMode || CurrentMode == GameMode.ScriptMode) { #region camspeed //------- CAM SPEED------------------------ if (keyboardState.IsKeyDown(Keys.OemMinus) && prevKeyState != keyboardState) { mouseCamera.moveSpeed -= 10; } if (keyboardState.IsKeyDown(Keys.OemPlus) && prevKeyState != keyboardState) { mouseCamera.moveSpeed += 10; } #endregion } if (CurrentMode == GameMode.ScriptMode) { VertChangFrame += 1; if (VertChangFrame == 2) { VertChangFrame = 0; //MoveCursorScriptMode(); } } #region loading if (keyboardState.IsKeyDown(Keys.V) && keyboardState.IsKeyDown(Keys.LeftShift) && prevKeyState != keyboardState) { LoadLevel(); } if (keyboardState.IsKeyDown(Keys.V) && keyboardState.IsKeyDown(Keys.LeftControl) && prevKeyState != keyboardState) { //int absValue = (a < 0) ? -a : a; //if true ? this : else that; DrawLoaded = DrawLoaded ? (false) : (true); } #endregion prevMouseState = mouseState; }