// Overrides the entire PopupMenu Draw method due to InputTextField public override void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics) { float Padding = 0.1f; float LineHeight = Font.MeasureString(StaticText).Y; Rectangle MenuRect = new Rectangle((int)Position.X, (int)Position.Y, MenuWidth, MenuHeight); spriteBatch.Draw(Menu, MenuRect, Color.White); string WrappedText = DrawingUtils.WrappedString(Font, StaticText, MenuRect, Padding)[0]; Vector2 TextSize = Font.MeasureString(WrappedText); spriteBatch.DrawString(Font, WrappedText, new Vector2(Position.X + (MenuWidth - TextSize.X) / 2, Position.Y + MenuHeight / 10), Color.Black); // Draw Field for input text if (InputTextField == null) { InputTextField = new InputTextField(new Rectangle((int)(Position.X + MenuWidth * Padding), (int)(Position.Y + Font.MeasureString(WrappedText).Y + Font.LineSpacing), (int)((1.0f - 2 * Padding) * MenuWidth), (int)LineHeight)); } InputTextField.Draw(spriteBatch, graphics, Font); for (int i = 0; i < ButtonLabels.Count; i++) { if (i + 1 > Buttons.Count) { Vector2 ButtonTextSize = Font.MeasureString(ButtonLabels[i]); Vector2 CenteredButtonPos = new Vector2(Position.X + (i + 1) * MenuWidth / (ButtonLabels.Count + 1) - ButtonTextSize.X / 2, Position.Y + TextSize.Y + LineHeight + 2 * MenuHeight / 10); Buttons.Add(new Button(ButtonLabels[i], Font, CenteredButtonPos)); } Buttons[i].Draw(spriteBatch, graphics); } }
public override void Draw(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { foreach (MemberPhysicalObject obj in members) { obj.Draw(gameTime, graphics); } }
/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(Graphics g) { var offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : PointF.Empty; var rect = new RectangleF(Bounds.X + offset.X, Bounds.Y + offset.Y, Bounds.Width, Bounds.Height); if (rect.Height > 2 && CssUtils.IsColorVisible(ActualBackgroundColor)) { g.FillRectangle(CssUtils.GetSolidBrush(ActualBackgroundColor), rect); } var b1 = CssUtils.GetSolidBrush(ActualBorderTopColor); DrawingUtils.DrawBorder(Border.Top, g, this, b1, rect, true, true); if (rect.Height > 1) { var b2 = CssUtils.GetSolidBrush(ActualBorderLeftColor); DrawingUtils.DrawBorder(Border.Left, g, this, b2, rect, true, true); var b3 = CssUtils.GetSolidBrush(ActualBorderRightColor); DrawingUtils.DrawBorder(Border.Right, g, this, b3, rect, true, true); var b4 = CssUtils.GetSolidBrush(ActualBorderBottomColor); DrawingUtils.DrawBorder(Border.Bottom, g, this, b4, rect, true, true); } }
private void DrawDot(IntVector2 position) { RectInt rect = DrawingUtils.CalculateFillRect(position, _textureSize, brushSize); bool[] mask = DrawingUtils.CreateDotMask(rect); ModifyTexture(mask, rect); }
/// <summary> /// Draw video image over the iframe if found. /// </summary> private void DrawImage(Graphics g, PointF offset, Rectangle rect) { if (_imageWord.Image != null) { if (_imageWord.ImageRectangle == Rectangle.Empty) { g.DrawImage(_imageWord.Image, rect); } else { g.DrawImage(_imageWord.Image, rect, _imageWord.ImageRectangle, GraphicsUnit.Point); } if (_imageWord.Selected) { g.FillRectangle(CssUtils.SelectionBackcolor, _imageWord.Left - _imageWord.LastMeasureOffset.X + offset.X, _imageWord.Top + offset.Y, _imageWord.Width, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight); } } else if (_isVideo && !_imageLoadingComplete) { DrawingUtils.DrawImageLoadingIcon(g, rect); if (rect.Width > 19 && rect.Height > 19) { g.DrawRectangle(Pens.LightGray, rect); } } }
private static void AssertHsl2RbgColor(double h, double s, double l, int expectedR, int expectedG, int expectedB) { var color = DrawingUtils.HSL2RGB(h, s, l); Assert.AreEqual(expectedR, color.R, "Expected R + " + expectedR + " but was " + color.R); Assert.AreEqual(expectedG, color.G, "Expected G: " + expectedG + " but was " + color.G); Assert.AreEqual(expectedB, color.B, "Expected B: " + expectedB + " but was " + color.B); }
private void MainForm_MouseMove(object sender, MouseEventArgs e) { if (drawing) { DrawingUtils.Redraw(); currFigure.Draw(e.Location); } }
public static ImageDimensions GetNewImageSize(ImageProcessingOptions options, ImageDimensions originalImageSize) { // Determine the output size based on incoming parameters var newSize = DrawingUtils.Resize(originalImageSize, options.Width ?? 0, options.Height ?? 0, options.MaxWidth ?? 0, options.MaxHeight ?? 0); newSize = DrawingUtils.ResizeFill(newSize, options.FillWidth, options.FillHeight); return(newSize); }
public override void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics) { Color Overlay = Color.Lerp(Color.Transparent, Color.Black, 0.7f); GraphicsDevice GD = graphics.GraphicsDevice; DrawingUtils.DrawFilledRectangle(spriteBatch, graphics, GD.Viewport.Bounds, Overlay); base.Draw(spriteBatch, graphics); }
private void ModifyTexture(bool[] mask, RectInt rect) { Color[] colorsToModify = _texture.GetPixels(rect.x, rect.y, rect.width, rect.height); DrawingUtils.ModifyColors(ref colorsToModify, mask, rect, brushColor); _texture.SetPixels(rect.x, rect.y, rect.width, rect.height, colorsToModify); _texture.Apply(); }
private void DrawLine(IntVector2 p1, IntVector2 p2) { RectInt rect = DrawingUtils.CalculateFillRect(p1, p2, _textureSize, brushSize); bool[] mask = DrawingUtils.CreateLineMask(p1, p2, rect, _textureSize, brushSize); ModifyTexture(mask, rect); }
public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics, SpriteFont font) { Color FieldColor = IsActive? Color.White : Color.LightGray; DrawingUtils.DrawFilledRectangle(spriteBatch, graphics, Rect, FieldColor); spriteBatch.DrawString(font, TextString, new Vector2(Rect.X + 5, Rect.Y + 5), Color.Black); DrawingUtils.DrawUnderline(spriteBatch, graphics, Rect, Color.Black); }
/// <summary> /// Rotate point at point(x,y) /// </summary> /// <param name="x">x coordinate value of the rotation point</param> /// <param name="y">y coordinate value of the rotation point</param> /// <param name="rotationAngle">Rotation angle</param> public void RotateAt(float x, float y, int rotationAngle) { float tmpX = this.X - x; float tmpY = this.Y - y; PointF tmpPoint = DrawingUtils.RotatePoint(new PointF(tmpX, tmpY), rotationAngle); this.X = (int)(tmpPoint.X + x); this.Y = (int)(tmpPoint.X + y); }
public override void DrawScreen(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { base.DrawScreen(gameTime, graphics); foreach(Vector2 pos in positions) { Vector2 screenPos = this.Game.Camera.WorldToScreenPosition(pos); graphics.DrawCircle(screenPos, 10, Color.Red, 1f); } }
void DrawRadii(string cmd, string[] splitcmd, int player) { Float3 commanderpos = CommanderController.GetInstance().GetCommanderPos(); for (int i = 100; i <= 1000; i += 100) { DrawingUtils.DrawCircle(commanderpos, i); } }
/// <summary> /// Increases the size of the image. /// </summary> public void IncreaseImageSize() { double newWidth = PrimaryImageWidth / ImageScale; ImageSize size = DrawingUtils.Resize(PrimaryImageWidth, PrimaryImageHeight, newWidth, null, null, null); PrimaryImageWidth = Convert.ToInt32(size.Width); PrimaryImageHeight = Convert.ToInt32(size.Height); }
/// <summary> /// If we're going to put a fixed size on the command line, this will calculate it /// </summary> /// <param name="state">The state.</param> /// <param name="outputVideoCodec">The output video codec.</param> /// <returns>System.String.</returns> protected string GetOutputSizeParam(StreamState state, string outputVideoCodec) { // http://sonnati.wordpress.com/2012/10/19/ffmpeg-the-swiss-army-knife-of-internet-streaming-part-vi/ var assSubtitleParam = string.Empty; var request = state.VideoRequest; if (state.SubtitleStream != null) { if (state.SubtitleStream.Codec.IndexOf("srt", StringComparison.OrdinalIgnoreCase) != -1 || state.SubtitleStream.Codec.IndexOf("subrip", StringComparison.OrdinalIgnoreCase) != -1) { assSubtitleParam = GetTextSubtitleParam((Video)state.Item, state.SubtitleStream, request.StartTimeTicks); } } // If fixed dimensions were supplied if (request.Width.HasValue && request.Height.HasValue) { return(string.Format(" -vf \"scale={0}:{1}{2}\"", request.Width.Value, request.Height.Value, assSubtitleParam)); } var isH264Output = outputVideoCodec.Equals("libx264", StringComparison.OrdinalIgnoreCase); // If a fixed width was requested if (request.Width.HasValue) { return(isH264Output ? string.Format(" -vf \"scale={0}:trunc(ow/a/2)*2{1}\"", request.Width.Value, assSubtitleParam) : string.Format(" -vf \"scale={0}:-1{1}\"", request.Width.Value, assSubtitleParam)); } // If a max width was requested if (request.MaxWidth.HasValue && !request.MaxHeight.HasValue) { return(isH264Output ? string.Format(" -vf \"scale=min(iw\\,{0}):trunc(ow/a/2)*2{1}\"", request.MaxWidth.Value, assSubtitleParam) : string.Format(" -vf \"scale=min(iw\\,{0}):-1{1}\"", request.MaxWidth.Value, assSubtitleParam)); } // Need to perform calculations manually // Try to account for bad media info var currentHeight = state.VideoStream.Height ?? request.MaxHeight ?? request.Height ?? 0; var currentWidth = state.VideoStream.Width ?? request.MaxWidth ?? request.Width ?? 0; var outputSize = DrawingUtils.Resize(currentWidth, currentHeight, request.Width, request.Height, request.MaxWidth, request.MaxHeight); // If we're encoding with libx264, it can't handle odd numbered widths or heights, so we'll have to fix that if (isH264Output) { return(string.Format(" -vf \"scale=trunc({0}/2)*2:trunc({1}/2)*2{2}\"", outputSize.Width, outputSize.Height, assSubtitleParam)); } // Otherwise use -vf scale since ffmpeg will ensure internally that the aspect ratio is preserved return(string.Format(" -vf \"scale={0}:-1{1}\"", Convert.ToInt32(outputSize.Width), assSubtitleParam)); }
/// <summary> /// The drawing_ on draw. /// </summary> /// <param name="args"> /// The args. /// </param> public void Drawing_OnDraw(EventArgs args) { if (!Game.IsInGame || Game.IsPaused || Variables.Techies == null || !Variables.Techies.IsValid) { return; } foreach (var module in Variables.Modules.Where(module => module.CanDraw())) { module.Draw(); } foreach (var hero in Heroes.GetByTeam(Variables.EnemyTeam).Where(x => x.IsValid && !x.IsIllusion)) { var classId = hero.ClassID; bool enabled; if (!this.EnabledHeroes.TryGetValue(classId, out enabled)) { this.EnabledHeroes[classId] = true; } var health = hero.Health; if (!hero.IsAlive) { health = hero.MaximumHealth; } double[] topPanel; if (!this.heroTopPanel.TryGetValue(classId, out topPanel)) { topPanel = new double[3]; topPanel[0] = HUDInfo.GetTopPanelSizeX(hero); topPanel[1] = HUDInfo.GetTopPanelPosition(hero).X; topPanel[2] = HUDInfo.GetTopPanelSizeY(hero) * 1.4; this.heroTopPanel.Add(classId, topPanel); } var sizeX = topPanel[0]; var x = topPanel[1]; var sizey = topPanel[2]; var meepo = hero as Meepo; if ((meepo == null || meepo.WhichMeepo == 0) && Variables.Menu.DrawingsMenu.Item("drawTopPanel").GetValue <bool>()) { DrawingUtils.DrawRemoteMineNumber(hero.Handle, health, x, sizeX, sizey, enabled, hero); DrawingUtils.DrawLandMineNumber(hero.Handle, health, x, sizey, enabled, hero); } if (!Variables.Damage.GetSuicideDamage().ContainsKey(hero.Handle)) { continue; } DrawingUtils.DrawSuicide(hero.Handle, health, x, sizey, sizeX, enabled, hero); } }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); DrawingUtils.SpriteBatchBegin(gameRef.SpriteBatch); gameRef.SpriteBatch.Draw( backgroundImage, rectangle, Color.White); DrawingUtils.SpriteBatchEnd(gameRef.SpriteBatch); }
public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics) { if (CurrentColor.Equals(Color.Transparent)) { return; } GraphicsDevice GD = graphics.GraphicsDevice; DrawingUtils.DrawFilledRectangle(spriteBatch, graphics, GD.Viewport.Bounds, CurrentColor); }
public override void Draw(GameTime gameTime) { DrawingUtils.SpriteBatchBegin(gameRef.SpriteBatch); base.Draw(gameTime); controlManager.Draw(gameRef.SpriteBatch); DrawingUtils.SpriteBatchEnd(gameRef.SpriteBatch); }
public override void Draw(SpriteBatch spriteBatch) { DrawingUtils.DrawMessage( WoodCount.ToString(), new Vector2(Position.X * Engine.TileWidth, Position.Y * Engine.TileWidth + YDrawOffset), Color.GreenYellow, false); base.Draw(spriteBatch); }
private void vScrollBar_Scroll(object sender, ScrollEventArgs e) { if (e.Type != ScrollEventType.EndScroll && e.Type != ScrollEventType.ThumbPosition) { var view = (sender as VScrollBar); _OffsetY = DrawingUtils.TransformValue(e.NewValue, GridHeight * CellHeight, GridHeight); Invalidate(); } }
private static void AssertHsl2RbgColor(double h, double s, double l, int expectedR, int expectedG, int expectedB) { var color = DrawingUtils.HSL2RGB(h, s, l); Assert.Multiple(() => { Assert.That(color.R, Is.EqualTo(expectedR), "Expected R + " + expectedR + " but was " + color.R); Assert.That(color.G, Is.EqualTo(expectedG), "Expected G: " + expectedG + " but was " + color.G); Assert.That(color.B, Is.EqualTo(expectedB), "Expected B: " + expectedB + " but was " + color.B); }); }
void DrawLine(EBWorldPainterData.Point worldPoint1, EBWorldPainterData.Point worldPoint2, Color color) { Vector3 p1 = new Vector3(worldPoint1.location.x, 0.0f, worldPoint1.location.y); Vector3 p2 = new Vector3(worldPoint2.location.x, 0.0f, worldPoint2.location.y); Vector2 screenPoint0 = cam.WorldToViewportPoint(p1); Vector2 screenPoint1 = cam.WorldToViewportPoint(p2); screenPoint0.y = 1.0f - screenPoint0.y; screenPoint1.y = 1.0f - screenPoint1.y; DrawingUtils.Line(screenPoint0 * textureSize, screenPoint1 * textureSize, color); }
public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics) { foreach (Option Opt in Options) { if (Opt.Value == SelectedOption) { DrawingUtils.DrawUnderline(spriteBatch, graphics, Opt.Rect, Color.Purple); } spriteBatch.DrawString(Font, Opt.Label, new Vector2(Opt.Rect.X, Opt.Rect.Y), Color.Black); } }
public static ImageDimensions GetNewImageSize(ImageProcessingOptions options, ImageDimensions?originalImageSize) { if (originalImageSize.HasValue) { // Determine the output size based on incoming parameters var newSize = DrawingUtils.Resize(originalImageSize.Value, options.Width ?? 0, options.Height ?? 0, options.MaxWidth ?? 0, options.MaxHeight ?? 0); return(newSize); } return(GetSizeEstimate(options)); }
private ImageSize GetNewImageSize(ImageProcessingOptions options, ImageSize?originalImageSize) { if (originalImageSize.HasValue) { // Determine the output size based on incoming parameters var newSize = DrawingUtils.Resize(originalImageSize.Value, options.Width, options.Height, options.MaxWidth, options.MaxHeight); return(newSize); } return(GetSizeEstimate(options)); }
/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(Graphics g) { var rects = CommonUtils.GetFirstValueOrDefault(Rectangles); PointF offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : PointF.Empty; rects.Offset(offset); var prevClip = RenderUtils.ClipGraphicsByOverflow(g, this); PaintBackground(g, rects, true, true); PaintBorder(g, rects, true, true); RectangleF r = _imageWord.Rectangle; r.Offset(offset); r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom; r.Y += ActualBorderTopWidth + ActualPaddingTop; if (_imageWord.Image != null) { if (_imageWord.ImageRectangle == Rectangle.Empty) { g.DrawImage(_imageWord.Image, Rectangle.Round(r)); } else { g.DrawImage(_imageWord.Image, Rectangle.Round(r), _imageWord.ImageRectangle, GraphicsUnit.Point); } if (_imageWord.Selected) { g.FillRectangle(CssUtils.SelectionBackcolor, _imageWord.Left - _imageWord.LastMeasureOffset.X + offset.X, _imageWord.Top + offset.Y, _imageWord.Width, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight); } } else if (_imageLoadingComplete) { if (_imageLoadingComplete && r.Width > 19 && r.Height > 19) { DrawingUtils.DrawImageErrorIcon(g, r); } } else { DrawingUtils.DrawImageLoadingIcon(g, r); if (r.Width > 19 && r.Height > 19) { g.DrawRectangle(Pens.LightGray, Rectangle.Round(r)); } } RenderUtils.ReturnClip(g, prevClip); }
public void DumpMovementAreas(string cmd, string[] cmdsplit, int player) { int figuregroup = DrawingUtils.DrawMap(MovementMaps.GetInstance().infantryareas); aicallback.SetFigureColor(figuregroup, 1, 0, 0, 1); figuregroup = DrawingUtils.DrawMap(MovementMaps.GetInstance().vehicleareas); aicallback.SetFigureColor(figuregroup, 0, 0, 1, 1); figuregroup = DrawingUtils.DrawMap(MovementMaps.GetInstance().boatareas); aicallback.SetFigureColor(figuregroup, 0, 1, 0, 1); }
public override void Draw(SpriteBatch spriteBatch) { Rectangle = new Rectangle((int)RelativePosition.X, (int)RelativePosition.Y, (int)Size.X, (int)Size.Y); Rectangle barRectangle = new Rectangle((int)(RelativePosition.X + BarMargin.X), (int)(RelativePosition.Y + BarMargin.Y), (int)(Size.X - BarMargin.X * 2), (int)(Size.Y - BarMargin.Y * 2)); barRectangle.Width = (int)((Size.X * Percent) - BarMargin.X * 2); DrawingUtils.DrawRectangleBox(spriteBatch, BorderColor, BackColor, Rectangle, BorderWidth); DrawingUtils.DrawRectangleBox(spriteBatch, Color.Transparent, BarColor, barRectangle, 0); base.Draw(spriteBatch); }
/// <summary> /// Draws itself on the graph object /// </summary> /// <param name="graphObj">Graphic object to be drawn on</param> /// <param name="dx">X region on the graphic object</param> /// <param name="dy">Y region on the graphic object</param> /// <param name="zoom">Zoom value</param> public override void Draw(Graphics graphObj, int dx, int dy, float zoom) { SolidBrush myBrush = new SolidBrush(this.FillColor); myBrush.Color = DrawingUtils.SetTransparency(Color.Black, 80); Pen whitePen = new Pen(Color.White); graphObj.FillRectangle(myBrush, region.GetRectangleF(dx, dy, zoom)); graphObj.DrawRectangle(whitePen, (region.X0 + dx) * zoom, (region.Y0 + dy) * zoom, (region.X1 - region.X0) * zoom, (region.Y1 - region.Y0) * zoom); myBrush.Dispose(); whitePen.Dispose(); }
public override void DrawScreen(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { this.PlayerObject.DrawCompanyList(gameTime, graphics, this.Game.Camera); }
public override void Draw(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { }
public abstract void Draw(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics);
public void DrawScreen(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics, Camera camera, Color color, float depth) { foreach (Vehicle vic in this.combatVehicles.Value) { vic.DrawScreen(gameTime, graphics, camera, color, depth); } foreach (Vehicle vic in this.transportVehicles.Value) { vic.DrawScreen(gameTime, graphics, camera, color, depth); } if (supplyPoint.Value != null) { Vector2 point = camera.WorldToScreenPosition(supplyPoint.Value.Position); graphics.DrawCircle(point, 15, color, depth); } }
public override void DrawWorld(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { base.DrawWorld(gameTime, graphics); graphics.DrawCircle(vehicle.Position, 50, Color.Red, 1); }
public override void DrawScreen(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { base.DrawScreen(gameTime, graphics); this.PlayerObject.DrawCompanySelection(gameTime, graphics, selectedCompany); this.selectedCompany.DrawScreen(gameTime, graphics, this.Game.Camera, Color.Red, 1); }
public virtual void Draw(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { }
public virtual void DrawScreen(GameTime gameTime, DrawingUtils.MyGraphicsClass graphics, Camera camera, Color color, float depth) { Vector2 point = camera.WorldToScreenPosition(this.Position); graphics.DrawCircle(point, 15, color, depth); }
public override void Draw(Microsoft.Xna.Framework.GameTime gameTime, DrawingUtils.MyGraphicsClass graphics) { base.Draw(gameTime, graphics); this.Collidable.Draw(graphics, this.Position, this.Direction); }