2using System.Collections.Generic;
6using Microsoft.Xna.Framework;
7using Microsoft.Xna.Framework.Input;
8using Microsoft.Xna.Framework.Graphics;
20 public RenderTarget2D Texture;
29 get =>
new Point(Texture.Width, Texture.Height);
32 if (value.X == Texture?.Width && value.Y == Texture?.Height)
return;
34 RenderTarget2D oldTexture = Texture;
35 Texture =
new RenderTarget2D(GameMain.Instance.GraphicsDevice, value.X, value.Y);
36 Data =
new Color[Texture.Width * Texture.Height];
38 oldTexture?.Dispose();
42 public void Clear(Color? color =
null)
44 Color cl = color ?? Color.Transparent;
45 for (
int i = 0; i < Data.Length; i++)
53 public Color GetPixel(
int x,
int y)
55 return Data[y * Texture.Width + x];
58 public void SetPixel(
int x,
int y, Color cl)
60 Data[y * Texture.Width + x] = cl;
68 Texture.SetData<Color>(Data);
76 public void Render(Action<SpriteBatch> renderFunc)
78 GameMain.Instance.GraphicsDevice.SetRenderTarget(Texture);
81 spriteBatch.Begin(SpriteSortMode.Deferred,
null, GUI.SamplerState,
null, GameMain.ScissorTestEnable);
83 renderFunc(spriteBatch);
87 GameMain.Instance.GraphicsDevice.SetRenderTarget(
null);
90 public SpriteBatch spriteBatch;
94 Size =
new Point(x, y);
95 spriteBatch =
new SpriteBatch(GameMain.Instance.GraphicsDevice);
98 public CUICanvas() : this(100, 100) { }
100 public override void CleanUp()
Allows you to manipulate pixel data of its texture.
void Render(Action< SpriteBatch > renderFunc)
Uses renderFunc to render stuff directy onto Canvas.Texture You can for example use GUI "Draw" method...
void SetData()
Call this method to transfer values from Data array into texture.
virtual Point Size
Size of the internal texture Will automatically resize the texture and data array of set.
Base class for all components.
CUISprite BackgroundSprite
Will be drawn in background with BackgroundColor Default is solid white 1x1 texture.
Wrapper Containing link to texture and drawing settings, like SourceRedt, DrawMode,...