/// <summary> /// Draw Sprite /// </summary> /// <param name="spriteTexture">The texture that will be used</param> /// <param name="destRect">The destination rectangle = drawing translation offset + scaling</param> /// <param name="color">Color Modifiers</param> /// <param name="textureArrayIndex"> </param> public void Draw(SpriteTexture spriteTexture, ref Rectangle destRect, ref ByteColor color, int textureArrayIndex = 0, int drawGroupId = 0) { Vector2 position = new Vector2(destRect.X, destRect.Y); Vector2 size = new Vector2(destRect.Width, destRect.Height); Draw(spriteTexture, ref position, ref size, ref color, textureArrayIndex, drawGroupId); }
public VertexSprite2(Vector3 position, Vector3 textureCoordinate, ByteColor color, Vector4 wrap) { Position = position; TextureCoordinate = textureCoordinate; Color = color; Wrap = wrap; }
public VertexPointSprite3DExt1(Vector4 Position, ByteColor Color, ByteColor Color2, Vector2 Size) { this.Color = Color; this.Color2 = Color2; this.Position = Position; this.Size = Size; }
public void Draw(SharpDX.Direct3D11.DeviceContext context, int index) { if (_particules.Count == 0) { return; } //Accumulate particules here for this emitters, and render them ColoredParticule p; _particuleRenderer.Begin(context, true); for (int i = 0; i < _particules.Count; i++) { p = _particules[i]; Vector3 position = p.Position.ValueInterp.AsVector3(); ByteColor color = p.ParticuleColor; //Add a new Particule Matrix result; Matrix scaling = Matrix.Scaling(p.Size.X, p.Size.Y, p.Size.Y); Matrix rotation = Matrix.RotationQuaternion(p.RotationAngles.ValueInterp); //Identity rotation Matrix translation = Matrix.Translation(position); result = scaling * rotation * translation; _particuleRenderer.Processor.Draw(ref color, ref p.ColorReceived, ref result); } _particuleRenderer.End(context); }
public VertexSpriteInstanced(Matrix tranform, ByteColor color, int textureArrayIndex) { this.Tranform = tranform; this.Color = color; this.SourceRect = default(RectangleF); TextureArrayIndex = textureArrayIndex; Depth = 0; }
public VertexCubeFaceLQ(ref Vector4B position, ref HalfVector2 UV, Byte textureArrayId, ref ByteColor lighting, ref HalfVector2 vertexInfo) { this.VertexInfo = vertexInfo; this.Color = lighting; this.Position = position; this.Position.W = textureArrayId; this.UV = UV; }
public VertexSprite3D(Vector4 position, ByteColor color, Vector3 textureCoordinate, Vector4B biomeInfo) { this.Position = position; this.Color = color; this.TextureCoordinate = textureCoordinate; this.MetaData = Vector3.Zero; this.BiomeInfo = biomeInfo; }
public VertexSpriteInstanced(Matrix tranform, ByteColor color, RectangleF sourceRect) { this.Tranform = tranform; this.Color = color; this.SourceRect = sourceRect; TextureArrayIndex = 0; Depth = 0; }
/// <summary> /// Convert a pixel to a DataByte /// </summary> /// <param name="rgb">color bytes</param> /// <returns>Pixel converted to specific byte value for the hardware</returns> protected override byte ColorToByte(ByteColor rgb) { if (!rgb.IsMonochrome && !IsRed(rgb)) { rgb.Desaturate(); } return(rgb.R >= 128 ? Epd7In5b_V2Colors.Red : Epd7In5b_V2Colors.NotRed); }
public VertexCubeLiquid(ref Vector4B position, int textureArrayId, ref ByteColor lighting, ref Vector4B vertexInfo2, ref Vector4B VertexInfo1) { this.VertexInfo1 = VertexInfo1; this.VertexInfo2 = vertexInfo2; this.Color = lighting; this.Position = position; Dummy = 0; this.ArrayId = (ushort)textureArrayId; }
public VertexPointSprite3DTexCoord(ref Matrix worldTranform, ref Vector4 Position, ref ByteColor Color, ref Vector2 Size, ref Vector4 TextCoordU, ref Vector4 TextCoordV) { this.WorldTransform = worldTranform; this.Color = Color; this.Position = Position; this.Size = Size; this.TextCoordU = TextCoordU; this.TextCoordV = TextCoordV; }
/*Set LED Pixel*/ public static byte[] SetLEDPixel(byte pixelIndex, ByteColor newColor) { byte[] data = new byte[4]; data[0] = pixelIndex; data[1] = newColor.red; data[2] = newColor.green; data[3] = newColor.blue; return(data); }
private ByteColor SetPaleMemoryColor(PictureBox source) { ByteColor c = new ByteColor(); c.R = source.BackColor.R; c.G = source.BackColor.G; c.B = source.BackColor.B; return(c); }
/// <summary> /// Renders the specified control using the provided graphics interface /// </summary> /// <param name="control">Control that will be rendered</param> /// <param name="graphics"> /// Graphics interface that will be used to draw the control /// </param> public void Render(Controls.LabelControl control, IFlatGuiGraphics graphics) { var absoluteBounds = control.GetAbsoluteBounds(); if (control.CustomFont != null) { ByteColor color = control.Color; graphics.DrawString(control.CustomFont, ref absoluteBounds, control.Suffix == null ? control.Text : control.Text + control.Suffix, ref color, control.Autosizing, -1, control.CustomHorizontalPlacement, control.CustomVerticalPlacement); } else { string styleFrame; if (control.IsHeaderFont) { styleFrame = "labelHeader"; } else { switch (control.FontStyle) { case System.Drawing.FontStyle.Bold: styleFrame = "labelBold"; break; case System.Drawing.FontStyle.Italic: styleFrame = "labelItalic"; break; case System.Drawing.FontStyle.Regular: styleFrame = "label"; break; case System.Drawing.FontStyle.Underline: styleFrame = "labelUnderline"; break; default: styleFrame = "label"; break; } } if (control.ColorSet) { ByteColor color = control.Color; graphics.DrawString(styleFrame, 0, ref absoluteBounds, control.Suffix == null ? control.Text : control.Text + control.Suffix, ref color, control.Autosizing); } else { graphics.DrawString(styleFrame, 0, ref absoluteBounds, control.Suffix == null ? control.Text : control.Text + control.Suffix, control.Autosizing); } } }
public VertexCubeColor(ref Vector3 position, ref ByteColor color, ref ByteColor ambiantColor, ref Matrix tranform) { //The position will be added inside the unused 4 column matrix (Because the matrix doesn't contains projection information). tranform.M14 = position.X; tranform.M24 = position.Y; tranform.M34 = position.Z; this.Color = color; this.AmbiantColor = ambiantColor; this.Tranform = Matrix.Transpose(tranform); }
/// <summary> /// Fill the screen with a color /// </summary> /// <param name="command">Start Data Transmission Command</param> /// <param name="rgb">Color to fill the screen</param> private void FillColor(Epd7In5b_V2Commands command, ByteColor rgb) { var outputLine = GetColoredLineOnDevice(rgb); SendCommand(command); for (var y = 0; y < Height; y++) { SendData(outputLine); } }
/// <summary> /// Renders the specified control using the provided graphics interface /// </summary> /// <param name="control">Control that will be rendered</param> /// <param name="graphics"> /// Graphics interface that will be used to draw the control /// </param> public void Render(Controls.Arcade.PanelControl control, IFlatGuiGraphics graphics) { if (control.HidedPanel) { return; } RectangleF absoluteBound = control.GetAbsoluteBounds(); ByteColor color = control.Color; // This is simple! A panel consists of a single element we need to draw. graphics.DrawElement(control.FrameName, ref absoluteBound, ref color); }
private void BuildWindow(ref ByteColor LeftPanelColor) { //Create the Close Button _debugWindow = new WindowControl(); _debugWindow.Name = "DebugComponent"; _debugWindow.Title = "Debug Component"; _debugWindow.Bounds = new UniRectangle(0, 0, 600, 400); _closeBt = ToDispose(new CloseWindowButtonControl() { Bounds = new UniRectangle(_debugWindow.Bounds.Right - 20, 5, 15, 15) }); _closeBt.Pressed += closeBt_Pressed; _debugWindow.Children.Add(_closeBt); //Create the Left Menu panel PanelControl menu = ToDispose(new PanelControl() { Bounds = new UniRectangle(4, 24, 100, _debugWindow.Bounds.Size.Y - 28), Color = LeftPanelColor }); LabelControl menu_title = ToDispose(new LabelControl() { Bounds = new UniRectangle(5, 0, menu.Bounds.Size.X, 30), Color = Color.Yellow, Text = "Visualisation" }); menu.Children.Add(menu_title); ButtonControl btOptions = ToDispose(new ButtonControl() { Tag = "btOptions", Bounds = new UniRectangle(4, menu_title.Bounds.Bottom - 6, 92, 40), Text = "Debug Options" }); btOptions.Pressed += new EventHandler(btMenu_Pressed); menu.Children.Add(btOptions); ButtonControl btComponent = ToDispose(new ButtonControl() { Tag = "btComponent", Bounds = new UniRectangle(4, menu_title.Bounds.Bottom - 6 + 40, 92, 40), Text = "Game Comp." }); btComponent.Pressed += new EventHandler(btMenu_Pressed); menu.Children.Add(btComponent); ButtonControl btPerf = ToDispose(new ButtonControl() { Tag = "btPerf", Bounds = new UniRectangle(4, menu_title.Bounds.Bottom - 6 + 80, 92, 40), Text = "Perf. Comp." }); btPerf.Pressed += new EventHandler(btMenu_Pressed); menu.Children.Add(btPerf); _debugWindow.Children.Add(menu); }
public VertexCubeSolid(ref Vector4B position, int textureArrayId, ref ByteColor lighting, ref Vector4B vertexInfo, ref Vector4B biomeInfo, byte animationSpeed, byte maxAnimationFrame) { this.VertexInfo = vertexInfo; this.Color = lighting; this.Position = position; this.ArrayId = (ushort)textureArrayId; this.BiomeInfo = biomeInfo; Dummy = 0; Animation = new Vector4B() { X = animationSpeed, Y = maxAnimationFrame }; }
/// <summary> /// Fill the screen with a color /// </summary> /// <param name="rgb">Color to fill the screen</param> private void FillColor(ByteColor rgb) { var outputLine = GetColoredLineOnDevice(rgb); SendCommand(StartDataTransmissionCommand); for (var y = 0; y < Height; y++) { SendData(outputLine); } SendCommand(StopDataTransmissionCommand); }
public static SpriteBitmapRecord DecomposeIntoRedBlueImageMap(Bitmap bitmap, Color?maskColor = null) { var sprite = new List <ColoredSpriteData>(); // Build the palette of this sprite image var palette = ExtractColorPalette(bitmap, maskColor); // Get the 4-bit data and mask arrays var data = Decimate(Extract4BitPixelData(bitmap, palette)); var mask = Decimate(Extract4BitPixelMask(bitmap, palette)); // Start scanning the data, row by row. Each line is so far away from the // previous line that we always reset var width = data.GetLength(0); var height = data.GetLength(1); var classes = new ByteColor[width, height]; for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { classes[col, row] = RedBlueClassifier(mask[col, row]); } // Once a full row is classified, create the sprite data for (int col = 0; col < width; col++) { if (mask[col, row] == 0xFF) { continue; } sprite.Add(new ColoredSpriteData { Color = classes[col, row], Offset = row * 160 + col, Mask = mask[col, row], Data = data[col, row] }); } } return(new SpriteBitmapRecord { Data = data, Mask = mask, Classes = classes, SpriteData = sprite }); }
/// <summary> /// Will draw : Name & Health Bar /// </summary> /// <param name="context"></param> private void DrawEntitiesOverHeadData(DeviceContext context) { _dynamicEntityNameRenderer.Begin(context, true); _dynamicEntityEnergyBarRenderer.Begin(context, true); foreach (VisualDynamicEntity dynamicEntity in _dynamicEntitiesDico.Values.Where(x => x.ModelInstance != null && x.ModelInstance.World != Matrix.Zero)) { bool isMultiline = false; string Name; Vector3 textPosition = dynamicEntity.WorldPosition.ValueInterp.AsVector3(); textPosition.Y += (dynamicEntity.ModelInstance.State.BoundingBox.Maximum.Y / 16); //Place the text above the BoundingBox ByteColor color = Color.White; if (dynamicEntity.DynamicEntity is CharacterEntity) { Name = ((CharacterEntity)dynamicEntity.DynamicEntity).CharacterName; //Is it the local player ? if (IsLocalPlayer(dynamicEntity.DynamicEntity.DynamicId)) { color = Color.Yellow; } else { Name += Environment.NewLine + "<" + dynamicEntity.DynamicEntity.Name + ">"; isMultiline = true; } } else { Name = dynamicEntity.DynamicEntity.Name; color = Color.WhiteSmoke; } var distance = MVector3.Distance(dynamicEntity.WorldPosition.ValueInterp, _camManager.ActiveCamera.WorldPosition.ValueInterp); float scaling = Math.Min(0.040f, Math.Max(0.01f, 0.01f / 12 * (float)distance)); _dynamicEntityNameRenderer.Processor.DrawText(Name, ref textPosition, scaling, ref color, _camManager.ActiveCamera, MultiLineHandling: isMultiline); //HBar rendering if (!IsLocalPlayer(dynamicEntity.DynamicEntity.DynamicId) && dynamicEntity.DynamicEntity.Health.CurrentAsPercent < 1 && dynamicEntity.DynamicEntity.Health.CurrentAsPercent > 0) { var size = new Vector2((dynamicEntity.ModelInstance.State.BoundingBox.Maximum.X / 8) * dynamicEntity.DynamicEntity.Health.CurrentAsPercent, 0.1f); Vector3 hbPosition = textPosition; hbPosition.Y += 0.05f; _dynamicEntityEnergyBarRenderer.Processor.Draw(ref hbPosition, ref size, ref hbColor, ref colorReceived); } } _dynamicEntityNameRenderer.End(context); _dynamicEntityEnergyBarRenderer.End(context); }
//Add a new Cube public void Draw(ref ByteColor color, ref ByteColor ambiantColor, ref Matrix tranform) { int vertexOffset = _spritesvertexCollection.Count; //Create the 24 vertex + 36 Index data par cube ! for (int i = 0; i < vbCube.Length; i++) { _spritesvertexCollection.Add(new VertexCubeColor(ref vbCube[i], ref color, ref ambiantColor, ref tranform)); } foreach (var index in ibCube) { _spritesIndexCollection.Add((ushort)(index + vertexOffset)); } _isCollectionDirty = true; }
//the 2 DrawCustomTexture! public void DrawCustomTexture(SpriteTexture customTex, ref RectangleF bounds, int textureArrayIndex = 0, int groupId = 0, ByteColor?color = null) { var offset = new UniRectangle(0, 0, bounds.Width, bounds.Height); var destinationRegion = calculateDestinationRectangle( ref bounds, ref offset ); if (!color.HasValue) { color = _defaultColor; } ByteColor drawColor = color.Value; Rectangle srcRegion = new Rectangle(0, 0, customTex.Width, customTex.Height); spriteRenderer.Draw(customTex, ref destinationRegion, ref srcRegion, ref drawColor, textureArrayIndex, true, groupId); }
public override void Draw(SharpDX.Direct3D11.DeviceContext context, int index) { RenderStatesRepo.ApplyStates(context, DXStates.Rasters.Default, DXStates.Blenders.Disabled, DXStates.DepthStencils.DepthReadWriteEnabled); if (_bufferDirty) { _vb.SetData(context, _letreeVertexCollection.ToArray()); _ib.SetData(context, _letreeIndexCollection.ToArray()); _bufferDirty = false; } _shader.Begin(context); _shader.CBPerFrame.Values.ViewProjection = Matrix.Transpose(_cameraManager.ActiveCamera.ViewProjection3D); _shader.CBPerFrame.IsDirty = true; _shader.CBPerDraw.Values.World = Matrix.Transpose(Matrix.RotationQuaternion(rotationQ.ValueInterp)); _shader.CBPerDraw.IsDirty = true; _shader.Apply(context); _vb.SetToDevice(context, 0); _ib.SetToDevice(context, 0); context.DrawIndexed(_ib.IndicesCount, 0, 0); //Draw text _spriteRenderer.Begin(false, context); Vector2 positionText = new Vector2(0, 0); ByteColor color = Color.White; string info = "[R] Toggle rotation; [T] New generation"; info += Environment.NewLine + "Blocks quantity : " + _letreeIndexCollection.Count / 36; info += Environment.NewLine + "Tree size : " + (MaxtreeSize.X - MintreeSize.X + 1).ToString("X : 00 ") + (MaxtreeSize.Y - MintreeSize.Y + 1).ToString("Y : 00 ") + (MaxtreeSize.Z - MintreeSize.Z + 1).ToString("Z : 00 "); if (_newTemplate != null) { info += Environment.NewLine + "Axiome : " + _newTemplate.Axiom; } _spriteRenderer.DrawText(_font, info, ref positionText, ref color, -1, -1, SpriteRenderer.TextFontPosition.RelativeToFontUp); _spriteRenderer.End(context); }
/// <summary> /// Convert a pixel to a DataByte /// </summary> /// <param name="rgb">color bytes</param> /// <returns>Pixel converted to specific byte value for the hardware</returns> protected override byte ColorToByte(ByteColor rgb) { if (rgb.IsMonochrome) { return(rgb.R <= 85 ? Epd5in65fColors.Black : Epd5in65fColors.White); } if (rgb == ByteColors.Black) { return(Epd5in65fColors.Black); } if (rgb == ByteColors.White) { return(Epd5in65fColors.White); } if (rgb == ByteColors.Green) { return(Epd5in65fColors.Green); } if (rgb == ByteColors.Blue) { return(Epd5in65fColors.Blue); } if (rgb == ByteColors.Red) { return(Epd5in65fColors.Red); } if (rgb == ByteColors.Yellow) { return(Epd5in65fColors.Yellow); } if (rgb == ByteColors.Orange) { return(Epd5in65fColors.Orange); } return(Epd5in65fColors.Clean); }
public override void Draw(DeviceContext context, int index) { if (!_update) { _spriteRender.ReplayLast(context); return; } _update = false; _spriteRender.Begin(false, context); var pos = new Vector2(5, 5); var color = new ByteColor(Color.White); color.A = 50; _spriteRender.DrawText(_font, WatermarkText, ref pos, ref color); _spriteRender.End(context); }
public void Draw(DeviceContext context, int index) { if (_particules.Count == 0) { return; } //Accumulate particules here for this emitters, and render them BaseParticule p; _particuleRenderer.Begin(context, true); for (int i = 0; i < _particules.Count; i++) { p = _particules[i]; Vector3 position = p.Position.Value.AsVector3(); ByteColor white = Color.White; _particuleRenderer.Processor.Draw(ref position, ref p.Size, ref white, 0); } _particuleRenderer.End(context); }
/// <summary> /// Convert a pixel to a DataByte /// </summary> /// <param name="rgb">color bytes</param> /// <returns>Pixel converted to specific byte value for the hardware</returns> protected override byte ColorToByte(ByteColor rgb) { if (rgb.IsMonochrome) { if (rgb.R <= 85) { return(Epd7in5bcColors.Black); } if (rgb.R <= 170) { return(Epd7in5bcColors.Gray); } return(Epd7in5bcColors.White); } return(rgb.R >= 64 ? Epd7in5bcColors.Red : Epd7in5bcColors.Black); }
public static Color ToRGB(ByteColor color) { switch (color) { case ByteColor.GREEN: return(Color.PaleGreen); case ByteColor.YELLOW: return(Color.Yellow); case ByteColor.BLUE: return(Color.Blue); case ByteColor.ORANGE: return(Color.Orange); case ByteColor.PURPLE: return(Color.Purple); case ByteColor.RED: return(Color.Red); } return(Color.Transparent); }
private Color SetPaleColorBoxColor(ByteColor color) { Color newColor = Color.FromArgb(color.R, color.G, color.B); return newColor; }
private ByteColor SetPaleMemoryColor(PictureBox source) { ByteColor c = new ByteColor(); c.R = source.BackColor.R; c.G = source.BackColor.G; c.B = source.BackColor.B; return c; }