Можно ли улучшить класс? - C#
Формулировка задачи:
Есть класс, который рисует интерфейс, примерно такой:
Стесняюсь спросить ерунду, но можно ли как-то переделать этот класс, чтобы было использовать его как-то так:
Если я наркоман и подобное невозможно - извините
public class UI
{
public UI(int width, int height)
{
screen_width = width;
screen_height = height;
}
private int screen_width;
private int screen_height;
public void TextureDraw (Texture t, int x, int y) {....}
public void TextureDrawAndCrop (Texture t, int x, int y, int percent) {....}
public void LabelDraw (string s, int x, int y, int width, int height) {....}
public void LineDraw (Line l, int x, int y, int width, int height) {....}
}
используется так:
UI myUI = new UI(1280, 720);
myUI.TextureDraw (texture, 0, 0);
myUI.TextureDraw (texture_2, 3, 3);
myUI.TextureDrawAndCrop (texture_3, 0, 0, 50);
myUI.LineDraw (line_1, 5, 5, 10, 10)UI myUI = new UI(1280, 720); myUI.Texture(texture).Draw (0, 0); myUI.Texture(texture_2).Draw (3, 3); myUI.Texture(texture_3).DrawAndCrop (0, 0, 50); myUI.Line(line_1).Draw (5, 5, 10, 10);
Решение задачи: «Можно ли улучшить класс?»
textual
Листинг программы
public class UI
{
...
public Image image(Texture txt)
{
return new Image(txt);
}
...
}
public class Image
{
Texture texture;
public Image(Texture txt)
{
texture = txt;
}
public void Draw(int x, int y)
{ ... }
}