public Line BuildLine(Vector2 start, Vector2 end, Color color, FloatRectangle?clip) { var st = start; //.Clip(clip); var nd = end; //.Clip(clip); return(new Line(st, nd, color, 1)); }
public void DrawLine(Vector2 tstart, Vector2 tend, Color color, FloatRectangle?clip = null, float brushSize = 1) { Vector2 start = tstart.Clip(clip); Vector2 end = tend.Clip(clip); List <VertexPositionColor> vertices = new List <VertexPositionColor>(); if (brushSize == 1) { vertices.Add(new VertexPositionColor(new Vector3(start.X, start.Y, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(end.X, end.Y, 0), color)); } else { for (float y = -(brushSize / 2); y < (brushSize / 2); y++) { for (float x = -(brushSize / 2); x < (brushSize / 2); x++) { vertices.Add(new VertexPositionColor(new Vector3(start.X + x, start.Y + y, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(end.X + x, end.Y + y, 0), color)); } } } this.DrawUserPrimitives(PrimitiveType.LineList, vertices.ToArray(), 0, vertices.Count / 2); }
public void DrawLines(List <Line> lines, FloatRectangle?clip = null) { List <VertexPositionColor> vertices = new List <VertexPositionColor>(); foreach (Line line in lines) { Vector2 start = line.Start.Clip(clip); Vector2 end = line.End.Clip(clip); if (line.BrushSize == 1) { vertices.Add(new VertexPositionColor(new Vector3(start.X, start.Y, 0), line.Color)); vertices.Add(new VertexPositionColor(new Vector3(end.X, end.Y, 0), line.Color)); } else { for (float y = -(line.BrushSize / 2f); y < (line.BrushSize / 2f); y++) { for (float x = -(line.BrushSize / 2f); x < (line.BrushSize / 2f); x++) { vertices.Add(new VertexPositionColor(new Vector3(start.X + x, start.Y + y, 0), line.Color)); vertices.Add(new VertexPositionColor(new Vector3(end.X + x, end.Y + y, 0), line.Color)); } } } } this.DrawUserPrimitives(PrimitiveType.LineList, vertices.ToArray(), 0, vertices.Count / 2); }
public static Vector2 Clip(this Vector2 input, FloatRectangle?clip) { Vector2 result = new Vector2(input.X, input.Y); if (clip == null) { return(result); } if (result.X < clip.Value.X) { result.X = clip.Value.X; } if (result.Y < clip.Value.Y) { result.Y = clip.Value.Y; } if (result.X > clip.Value.BottomRight.X) { result.X = clip.Value.BottomRight.X; } if (result.Y > clip.Value.BottomRight.Y) { result.X = clip.Value.BottomRight.Y; } return(result); }
public void DoBlur(int blurAmount, Rectangle?scissorRect, FloatRectangle?clip, int noisePerc, Rectangle sprite, Action renderCode) { if (Effect == null) { return; } if (Solids.Settings.EnableBlur) { //// Solids.Instance.SpriteBatch.DoEnd(); //Solids.Instance.SpriteBatch.Scissor = scissorRect; //// Solids.Instance.SpriteBatch.DoEnd(); Effect.CurrentTechnique = Effect.Techniques["AcrylicBlur"]; Effect.Parameters["gfxWidth"].SetValue((float)sprite.Width); Effect.Parameters["gfxHeight"].SetValue((float)sprite.Height); Effect.Parameters["blurSize"].SetValue((int)(blurAmount)); if (noisePerc > 0) { Effect.Parameters["noisePerc"].SetValue(noisePerc); } //Solids.Instance.SpriteBatch.GraphicsDevice.Clear(Color.TransparentBlack); Solids.Instance.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Solids.Instance.SpriteBatch.RasterizerState, Effect, null); renderCode(); Solids.Instance.SpriteBatch.End(); } }
public static FloatRectangle Clamp(this FloatRectangle?rect, Rectangle clamp, bool leftClampOnly = false) { if (rect == null) { return(Clamp(new FloatRectangle(Solids.Instance.Bounds), new FloatRectangle(clamp), leftClampOnly)); } return(Clamp(rect.Value, new FloatRectangle(clamp), leftClampOnly)); }
public static Rectangle ToRectangle(this FloatRectangle?woot) { if (!woot.HasValue) { return(Solids.Instance.Bounds); } return(woot.Value.ToRectangle); }
private void pnlDisplays_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; var pen = new Pen(Color.Black, 1); var selectedPen = new Pen(Color.Black, 5); var dimensions = new Rectangle(5, 5, pnlDisplays.Width - 15, pnlDisplays.Height - 15); g.DrawRectangle(pen, dimensions); //Set default display if we don't have one bool found = false; foreach (var screen in Screen.AllScreens) { if (GetDeviceName(screen.DeviceName) == _currentDisplay) { found = true; break; } } if (!found) { _currentDisplay = GetDeviceName(Screen.PrimaryScreen.DeviceName); } var v = SystemInformation.VirtualScreen; var colors = new Color[] { Color.LightBlue, Color.LightGreen, Color.Pink, Color.LightYellow, Color.PowderBlue, Color.LightSalmon }; FloatRectangle?selected = null; for (int i = 0; i < Screen.AllScreens.Length; i++) { float x = (float)dimensions.X + ((((float)Screen.AllScreens[i].Bounds.X - (float)v.X) / (float)v.Width) * (float)dimensions.Width); float y = (float)dimensions.Y + ((((float)Screen.AllScreens[i].Bounds.Y - (float)v.Y) / (float)v.Height) * (float)dimensions.Height); float width = (float)Math.Round((float)((float)Screen.AllScreens[i].Bounds.Width / (float)v.Width) * (float)dimensions.Width, 0); float height = (float)Math.Round((float)((float)Screen.AllScreens[i].Bounds.Height / (float)v.Height) * (float)dimensions.Height, 0); g.FillRectangle(new SolidBrush(colors[i % colors.Length]), x, y, width, height); if (_currentDisplay == GetDeviceName(Screen.AllScreens[i].DeviceName)) { selected = new FloatRectangle(x, y, width, height); } g.DrawRectangle(pen, x, y, width, height); } if (selected != null) { g.DrawRectangle(selectedPen, selected.Value.X, selected.Value.Y, selected.Value.Width, selected.Value.Height); } }
public Effect StartBlur(int blurAmount, Rectangle?scissorRect, FloatRectangle?clip, int noisePerc, Rectangle sprite) { if (Solids.Settings.EnableBlur) { Effect.CurrentTechnique = Effect.Techniques["AcrylicBlur"]; Effect.Parameters["gfxWidth"].SetValue((float)sprite.Width); Effect.Parameters["gfxHeight"].SetValue((float)sprite.Height); Effect.Parameters["blurSize"].SetValue((int)(blurAmount)); if (noisePerc > 0) { Effect.Parameters["noisePerc"].SetValue(noisePerc); } } return(Effect); }
public static FloatRectangle Clamp(this FloatRectangle?rect, Rectangle?clamp, bool leftClampOnly = false) { if (!clamp.HasValue) { if (rect.HasValue) { return(rect.Value); } else { return(new FloatRectangle(Solids.Instance.Bounds)); } } return(Clamp(rect.Value, new FloatRectangle(clamp.Value), leftClampOnly)); }
public static FloatRectangle Clip(this FloatRectangle rect, FloatRectangle?clip) { if (clip == null) { return(rect); } float x = rect.X; float y = rect.Y; float x2 = rect.Right; float y2 = rect.Bottom; if (x < clip.Value.X) { x = (int)clip.Value.X; } if (y < clip.Value.Y) { y = (int)clip.Value.Y; } if (x > clip.Value.X + clip.Value.Width) { x = (int)(clip.Value.X + clip.Value.Width); } if (y > clip.Value.Y + clip.Value.Height) { y = (int)(clip.Value.Y + clip.Value.Height); } if (x2 < clip.Value.X) { x2 = (int)clip.Value.X; } if (y2 < clip.Value.Y) { y2 = (int)clip.Value.Y; } if (x2 > clip.Value.X + clip.Value.Width) { x2 = (int)(clip.Value.X + clip.Value.Width); } if (y2 > clip.Value.Y + clip.Value.Height) { y2 = (int)(clip.Value.Y + clip.Value.Height); } return(new FloatRectangle(x, y, x2 - x, y2 - y)); }
public void DrawLine(Vector2[] points, Color fromColor, Color toColor, FloatRectangle?clip = null, float brushSize = 1) { //using (new BenchMark()) { Vector2[] sanityPoints = new Vector2[points.Length]; for (int i = 0; i < points.Length; i++) { sanityPoints[i] = points[i].Clip(clip); } Color color = fromColor; List <VertexPositionColor> vertices = new List <VertexPositionColor>(); for (int i = 0; i < points.Length - 1; i = i + 1) { color = Color.Lerp(fromColor, toColor, i / (float)points.Length); Vector2 start = sanityPoints[i]; Vector2 end = sanityPoints[i + 1]; { if (brushSize == 1) { vertices.Add(new VertexPositionColor(new Vector3(start.X, start.Y, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(end.X, end.Y, 0), color)); } else { for (float y = -(brushSize / 2); y < (brushSize / 2); y++) { for (float x = -(brushSize / 2); x < (brushSize / 2); x++) { vertices.Add(new VertexPositionColor(new Vector3(start.X + x, start.Y + y, 0), color)); vertices.Add(new VertexPositionColor(new Vector3(end.X + x, end.Y + y, 0), color)); } } } } } this.DrawUserPrimitives(PrimitiveType.LineList, vertices.ToArray(), 0, vertices.Count / 2); } }
public static FloatRectangle Clamp(this FloatRectangle rect, FloatRectangle?clamp, bool leftClampOnly = false) { // using (new BenchMark()) { if (clamp.HasValue == false) { return(rect); } float tx = rect.X; float ty = rect.Y; float bx = rect.BottomRight.X; float by = rect.BottomRight.Y; if (tx < clamp.Value.X) { tx = clamp.Value.X; } if (ty < clamp.Value.Y) { ty = clamp.Value.Y; } if (!leftClampOnly) { if (bx > clamp.Value.BottomRight.X) { bx = clamp.Value.BottomRight.X; } if (by > clamp.Value.BottomRight.Y) { by = clamp.Value.BottomRight.Y; } } float width = bx - tx; float height = by - ty; if (width < 0 | height < 0) { return(new FloatRectangle(0, 0, 0, 0)); } return(new FloatRectangle(tx, ty, width, height)); } }
public void DrawSolidRectangle(FloatRectangle rect, Color color, FloatRectangle?clip = null) { var temp = rect.Clamp(clip); //temp = rect; Vector3 topLeft = new Vector3(temp.X, temp.Y, 0); Vector3 bottomLeft = new Vector3(temp.X, temp.Y + temp.Height, 0); Vector3 bottomRight = new Vector3(temp.X + temp.Width, temp.Y + temp.Height, 0); Vector3 topRight = new Vector3(temp.X + temp.Width, temp.Y, 0); VertexPositionColor[] vertices = new VertexPositionColor[6]; vertices[0] = new VertexPositionColor(topLeft, color); vertices[1] = new VertexPositionColor(topRight, color); vertices[2] = new VertexPositionColor(bottomRight, color); vertices[3] = new VertexPositionColor(bottomRight, color); vertices[4] = new VertexPositionColor(bottomLeft, color); vertices[5] = new VertexPositionColor(topLeft, color); this.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2); }
public static FloatRectangle?Move(this FloatRectangle?fr, Vector2?vector2d) { if (fr.HasValue) { if (vector2d.HasValue) { Vector2 vector2 = vector2d.Value; return(new FloatRectangle(fr.Value.X + vector2.X, fr.Value.Y + vector2.Y, fr.Value.Width, fr.Value.Height)); } else { return(fr.Value); } } else { return(null); } }
public FloatRectangle?Translate(FloatRectangle?input) { if (!input.HasValue) { return(null); } var b = bounds; if (input.Value.Boundless) { b = new FloatRectangle(Solids.Instance.Bounds); } return(new FloatRectangle( b.X + (b.Width * input.Value.X), b.Y + (b.Height * input.Value.Y), b.Width * input.Value.Width, b.Height * input.Value.Height )); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { if (Solids.Instance.InputService.IsPressed(InputService.ShiftKeys.LeftShift1)) { // return; } if (Texture2D != null) { FloatRectangle?pos = screen.Translate(Position.Value.Move(scrollOffset)); FloatRectangle?translatedClip = screen.Translate(clip); Rectangle?fixedSource = SourceRectangle.Value; (Rectangle position, Rectangle? source)thing = TextureHelpers.GetAdjustedDestAndSourceAfterClip(pos, fixedSource, translatedClip); using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch)) { //spriteBatch.Draw(Texture2D.Value, thing.Item1, thing.Item2, ImageColor.Value * opacity, Rotation.Value, new Vector2(thing.Item1.Width/2f, thing.Item1.Height/2f),SpriteEffects.None,1f); spriteBatch.Draw(Texture2D.Value, pos.Value.ToRectangle, null, ImageColor.Value * opacity); } } }
public void DrawText(SmartSpriteBatch spriteBatch, float x, float y, string text, Color?color = null, Vector2?scale = null, float rotation = 1, float depth = 1, SpriteEffects effect = SpriteEffects.None, FloatRectangle?clip = null) { if (_texture == null || text == null) { return; } Vector2 scaling = Vector2.One; float xscale = 1; float yscale = 1; if (scale != null) { xscale = ((Vector2)scale).X; yscale = ((Vector2)scale).Y; scaling = (Vector2)scale; } Color col = Color.White; if (color != null) { col = (Color)color; } float currentX = x; float currentY = y; foreach (char c in text) { FontChar fontChar; if (_characterMap.TryGetValue(c, out fontChar)) { Rectangle sourceRectangle = new Rectangle(fontChar.X, fontChar.Y, fontChar.Width, fontChar.Height); Vector2 position = new Vector2(currentX + (fontChar.XOffset * xscale), currentY + (fontChar.YOffset * yscale)); Rectangle positionRect = new Rectangle((int)position.X, (int)position.Y, (int)(fontChar.Width * scaling.X), (int)(fontChar.Height * scaling.Y)); spriteBatch.Draw(_texture, positionRect, sourceRectangle, col, rotation, Vector2.Zero, effect, depth); currentX += (fontChar.XAdvance * xscale); } } }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { float width = ActualPosition.Width; float height = ActualPosition.Height; float barHeight = BarHeight.Value(); if (barHeight == 0) { barHeight = 0.001f; } float availableHeight = height - barHeight; float percentage = Value.Value() / MaxValue.Value(); float sliderWidth = SliderWidth.Value(); if (sliderWidth == 0) { sliderWidth = 0.001f; } float sliderLeft = (width / 2f) - (sliderWidth / 2f); FloatRectangle sliderRect = new FloatRectangle( sliderLeft + ActualPosition.X, ActualPosition.Y, sliderWidth, height); FloatRectangle barRect = new FloatRectangle( ActualPosition.X, (availableHeight - (availableHeight * percentage)) + ActualPosition.Y, width, barHeight); if (SliderTexture.HasValue()) { using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch)) { spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture(SliderTexture.Value(), true), screen.Translate(sliderRect).Value.ToRectangle, Color.White); } } else { spriteBatch.DrawSolidRectangle(screen.Translate(sliderRect).Value, SliderColor.Value().Value *opacity, clip); } if (BarTexture.HasValue()) { using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch)) { spriteBatch.Draw(Solids.Instance.AssetLibrary.GetTexture(BarTexture.Value(), true), screen.Translate(barRect).Value.ToRectangle, Color.White); } } else { spriteBatch.DrawSolidRectangle(screen.Translate(barRect).Value, BarColor.Value().Value *opacity, clip); } if (ActiveColor.HasValue() && this.State.Value == ButtonState.Hover) { spriteBatch.DrawSolidRectangle(screen.Translate(ActualPosition).Value, ActiveColor.Value().Value *opacity, clip); } }
public SmartSpriteBatchManager(SmartSpriteBatch smartSpriteBatch, SpriteSortMode sortMode = SpriteSortMode.Immediate, BlendState blendState = null, SamplerState samplerState = null, DepthStencilState depthStencilState = null, RasterizerState rasterizerState = null, Effect effect = null, Matrix?transformMatrix = null, FloatRectangle?scissorRect = null) { this.smartSpriteBatch = smartSpriteBatch; if (blendState == null) { blendState = BlendState.NonPremultiplied; } if (scissorRect.HasValue) { this.smartSpriteBatch.GraphicsDevice.ScissorRectangle = scissorRect.ToRectangle(); } this.smartSpriteBatch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, transformMatrix, scissorRect.ToRectangle()); }
public void DoBlur(Texture2D sprite, int blurAmount, Color color, Rectangle rect, Rectangle?scissorRect, FloatRectangle?clip, int noisePerc = 0) { if (Effect == null) { return; } if (sprite == null) { return; } rect = new FloatRectangle(rect).Clamp(clip).ToRectangle; if (Solids.Settings.EnableBlur) { //// Solids.Instance.SpriteBatch.DoEnd(); //Solids.Instance.SpriteBatch.Scissor = scissorRect; //// Solids.Instance.SpriteBatch.DoEnd(); Effect.CurrentTechnique = Effect.Techniques["AcrylicBlur"]; Effect.Parameters["gfxWidth"].SetValue((float)sprite.Width); Effect.Parameters["gfxHeight"].SetValue((float)sprite.Height); Effect.Parameters["blurSize"].SetValue((int)(blurAmount)); if (noisePerc > 0) { Effect.Parameters["noisePerc"].SetValue(noisePerc); } //Solids.Instance.SpriteBatch.GraphicsDevice.Clear(Color.TransparentBlack); using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch, SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Solids.Instance.SpriteBatch.RasterizerState, Effect, null)) { Solids.Instance.SpriteBatch.Draw(sprite, rect, rect, color); } } }
public virtual void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { throw new NotImplementedException(); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { ctx = 0; var items = Items?.Value(); string hash = ""; hash = items?.GetHashCode().ToString(); if (previousHash != hash) { if (items != null) { this.Children.Value = new List <DataboundAsset>(); foreach (VirtualizedDataContext dataContext in items) { var newItem = screenResources.GetTemplate(Template.Value()); newItem.VirtualizedDataContext = dataContext; newItem.ParentAsset = this; this.Children.Value.Add(newItem); } this.FixParentChildRelationship(); this.FixBinds(); } previousHash = hash; } float pos = 0; foreach (DataboundAsset item in Children.Value) { if (item.Margin != null && item.Margin.Value != null) { pos = pos + item.Margin.Value.Top; } float height = item.Position.Value.Height; if (item.ActualSize.Y > 0) { height = item.ActualSize.Y; } float lm = 0; float bm = 0; if (item.Margin != null && item.Margin.Value != null) { lm = item.Margin.Value.Left; bm = item.Margin.Value.Bottom; } item.Position.Value = new FloatRectangle(lm, pos, item.Position.Value.Width, item.Position.Value.Height); pos = pos + height + bm; } this.ActualSize = new Vector2(this.Position.Value.Width, pos - this.Position.ToVector2().Y); SetChildrenOriginToMyOrigin(); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { ctx = 0; var items = Items?.Value(); string hash = ""; hash = items?.GetHashCode().ToString(); if (previousHash != hash) { this.Children.Value = new List <DataboundAsset>(); if (items != null) { foreach (VirtualizedDataContext dataContext in items) { var newItem = screenResources.GetTemplate(Template.Value()); newItem.VirtualizedDataContext = dataContext; newItem.ParentAsset = this; this.Children.Value.Add(newItem); } } this.FixParentChildRelationship(); this.FixBinds(); previousHash = hash; } SetChildrenOriginToMyOrigin(); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { if (!haveLoadedTemplate) { string template = Template.Value(); List <DataboundAsset> children = this.Children.Value; DataboundAsset templateContent = screenResources.GetTemplate(template); templateContent.ParentAsset = this; if (templateContent is DataboundContainterAsset containerAsset) { //containerAsset.Children.Value = children; List <DataboundAsset> contentAssets = containerAsset.FindChildrenOfType <ContentAsset>(); if (contentAssets.Count > 0) { foreach (var contentAsset in contentAssets) { ((DataboundContainterAsset)contentAsset.ParentAsset).Children.Value = children; } } } this.Children.Value = new List <DataboundAsset> { templateContent }; this.FixParentChildRelationship(); this.FixBinds(); haveLoadedTemplate = true; } SetChildrenOriginToMyOrigin(); if (ActualSize == Vector2.Zero) { this.ActualSize = this.Children.Value.First().ActualSize; } }
public override void Draw(SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null) { int y = (int)BaseScreen.AllAssets.Max(t => t.Position.Bottom); var x = (int)BaseScreen.AllAssets.Max(t => t.Position.Right); if (BaseScreen.RenderTarget == null || BaseScreen.RenderTarget.Width != (int)x || BaseScreen.RenderTarget.Height != (int)y) { BaseScreen.RenderTarget = new RenderTarget2D(Solids.SpriteBatch.GraphicsDevice, x, y); } Solids.SpriteBatch.GraphicsDevice.SetRenderTarget(BaseScreen.RenderTarget); Solids.SpriteBatch.GraphicsDevice.Clear(Color.Transparent); // Solids.SpriteBatch.ForceBegin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullNone, null, null); using (new SmartSpriteBatchManager(Solids.SpriteBatch)) { BaseScreen.Draw(new GameTime(), BaseScreen.OpenCloseOpacity, null); } Solids.SpriteBatch.GraphicsDevice.SetRenderTarget(ParentScreen.RenderTarget); // Solids.SpriteBatch.ForceEnd(); //previousTexture = screen.RenderTarget; base.Draw(spriteBatch, screen, opacity, clip, bgTexture); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { SetChildrenOriginToMyOrigin(); this.ActualSize = this.Children.Value.First().ActualSize; }
public void DrawRectangle(Rectangle rectangle, Color color, Color?bgColor = null, FloatRectangle?clip = null) { DrawRectangle(new FloatRectangle(rectangle), color, bgColor, clip); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { if (clip.HasValue && ParentPosition.HasValue) { clip = clip.Value.ConstrainTo(ParentPosition.Value); } clip = screen.Translate(clip); var t = Position.Value(); FloatRectangle tmp = screen.Translate(ActualPosition.AdjustForMargin(Margin)).Value; if (clip.HasValue) { if (tmp.Right < clip.Value.X || tmp.X > clip.Value.Right) { return; } } if (BlurAmount.Value() > 0) { Solids.GaussianBlur.DoBlur(bgTexture, BlurAmount.Value(), (BackgroundColor.Value().Value *opacity) * ((BlurAmount.Value() / Solids.MaxBlur)), tmp.ToRectangle, ScissorRect, clip, NoisePerc.Value()); } if (BackgroundColor.Value().HasValue&& FillTexture.Value() == null) { spriteBatch.DrawSolidRectangle(tmp, BackgroundColor.Value().Value *opacity, clip); } if (FillTexture.Value() != null) { using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch)) { spriteBatch.DrawTexturedRectangle(tmp, BackgroundColor.Value().Value *opacity, Solids.Instance.AssetLibrary.GetTexture(FillTexture.Value()), TilingMode.Value, clip); } } if (BrushSize.Value() > 0) { spriteBatch.DrawBorder(tmp, BorderColor.Value() * opacity, BrushSize.Value(), clip); } this.ActualSize = new Vector2(Position.Value().Width, Position.Value().Height).PadForMargin(Margin); SetChildrenOriginToMyOrigin(); }
public void DrawRectangle(FloatRectangle rectangle, Color color, Color?bgColor = null, FloatRectangle?clip = null) { if (bgColor != null) { DrawSolidRectangle(rectangle, bgColor.Value); } var rect = rectangle.Clamp(clip); // rect = rectangle; List <Line> lines = new List <Line> { BuildLine(new Vector2(rect.X, rect.Y), new Vector2(rect.Right, rect.Y), color, clip), BuildLine(new Vector2(rect.Right, rect.Y), new Vector2(rect.Right, rect.Bottom), color, clip), BuildLine(new Vector2(rect.Right, rect.Bottom), new Vector2(rect.X, rect.Bottom), color, clip), BuildLine(new Vector2(rect.X, rect.Bottom), new Vector2(rect.X, rect.Y), color, clip) }; DrawLines(lines, null); }