123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonUI.Display;
- using CommonUI.Gemo;
- namespace CommonUI.Display
- {
- public enum Blend : byte
- {
- BLEND_MODE_NORMAL = Data.Blend.BLEND_MODE_NORMAL,
- BLEND_MODE_SCREEN = Data.Blend.BLEND_MODE_SCREEN,
- BLEND_MODE_GRAY = Data.Blend.BLEND_MODE_GRAY,
- }
- public enum Anchor : byte
- {
- NONE = Data.Anchor.NONE,
- ANCHOR_LEFT = Data.Anchor.ANCHOR_LEFT,
- ANCHOR_HCENTER = Data.Anchor.ANCHOR_HCENTER,
- ANCHOR_RIGHT = Data.Anchor.ANCHOR_RIGHT,
- ANCHOR_TOP = Data.Anchor.ANCHOR_TOP,
- ANCHOR_VCENTER = Data.Anchor.ANCHOR_VCENTER,
- ANCHOR_BOTTOM = Data.Anchor.ANCHOR_BOTTOM,
- }
- public enum Trans : byte
- {
- TRANS_NONE = Data.Trans.TRANS_NONE,
- TRANS_ROT90 = Data.Trans.TRANS_ROT90,
- TRANS_ROT180 = Data.Trans.TRANS_ROT180,
- TRANS_ROT270 = Data.Trans.TRANS_ROT270,
- TRANS_MIRROR = Data.Trans.TRANS_MIRROR,
- TRANS_MIRROR_ROT90 = Data.Trans.TRANS_MIRROR_ROT90,
- TRANS_MIRROR_ROT180 = Data.Trans.TRANS_MIRROR_ROT180,
- TRANS_MIRROR_ROT270 = Data.Trans.TRANS_MIRROR_ROT270,
- }
- public enum ImageAnchor : byte
- {
- L_T = Data.ImageAnchor.L_T,
- C_T = Data.ImageAnchor.C_T,
- R_T = Data.ImageAnchor.R_T,
- L_C = Data.ImageAnchor.L_C,
- C_C = Data.ImageAnchor.C_C,
- R_C = Data.ImageAnchor.R_C,
- L_B = Data.ImageAnchor.L_B,
- C_B = Data.ImageAnchor.C_B,
- R_B = Data.ImageAnchor.R_B,
- }
- public enum ImageTrans : byte
- {
- NONE = (Trans.TRANS_NONE),
- R_90 = (Trans.TRANS_ROT90),
- R_180 = (Trans.TRANS_ROT180),
- R_270 = (Trans.TRANS_ROT270),
- MIRROR = (Trans.TRANS_MIRROR),
- MR_90 = (Trans.TRANS_MIRROR_ROT90),
- MR_180 = (Trans.TRANS_MIRROR_ROT180),
- MR_270 = (Trans.TRANS_MIRROR_ROT270),
- }
-
- // ------------------------------------------------------------------------------------------
- // -by zhangyifei
- // ------------------------------------------------------------------------------------------
- public abstract class Graphics : IDisposable
- {
- public const float ANGLE_90 = (float)(90);
- public const float ANGLE_180 = (float)(180);
- public const float ANGLE_270 = (float)(270);
- public abstract void setBlend(Blend blend);
- public abstract Blend getBlend();
- public abstract uint getColor();
- public abstract void setColor(uint color);
- public abstract void setColor(int red, int green, int blue);
- public abstract void setColor(int red, int green, int blue, int alpha);
- public abstract void setColor(float red, float green, float blue, float alpha);
- public abstract void setAlpha(float alpha);
- public abstract float getAlpha();
- public virtual void addAlpha(float add)
- {
- setAlpha(getAlpha() * add);
- }
- public abstract void SetClip(Rectangle2D rect);
- public abstract void SetClip(float x, float y, float w, float h);
- public abstract void PushClip();
- public abstract void PopClip();
- #region TRANSFORM
- public abstract void translate(float x, float y);
- public abstract void rotate(float angle);
- public abstract void scale(float sx, float sy);
- public abstract void pushTransform();
- public abstract void popTransform();
- #endregion
- #region IMAGE
- public abstract void beginImage(Image image);
- public abstract void drawVertex(VertexBuffer vertex);
- public abstract void drawVertex(VertexBuffer vertex, int[] indices, VertexTopology mode);
- public abstract void drawVertexSequence(VertexBuffer vertex, VertexTopology mode);
- public abstract void drawImageZoom(
- float x, float y, float w, float h);
- public abstract void drawImage(
- float x, float y);
- public abstract void drawImage(
- float x, float y, Anchor anchor);
- public abstract void drawImageTrans(
- float x, float y, Trans trans);
- public abstract void drawRegion(
- float sx, float sy,
- float w, float h,
- Trans tx,
- float dx, float dy);
- public abstract void drawRegion(
- float sx, float sy,
- float sw, float sh,
- float dx, float dy,
- float dw, float dh);
- public abstract void drawImageEllipse(
- float sx, float sy,
- float sw, float sh,
- float startAngle,
- float endAngle);
-
- public abstract void drawImageZoom(Image image,
- float x, float y, float w, float h);
- public abstract void drawImage(Image image,
- float x, float y);
- public abstract void drawImage(Image image,
- float x, float y, Anchor anchor);
- public abstract void drawImageTrans(Image image,
- float x, float y, Trans trans);
- public abstract void drawRegion(Image src,
- float sx, float sy,
- float w, float h,
- Trans tx,
- float dx, float dy);
- public abstract void drawRegion(Image src,
- float sx, float sy,
- float sw, float sh,
- float dx, float dy,
- float dw, float dh);
-
- #endregion
- #region SHAPE
- public abstract void drawLine(float x1, float y1, float x2, float y2);
- public abstract void drawRect(float x, float y, float w, float h);
- public abstract void fillRect(float x, float y, float w, float h);
- public abstract void drawRoundRect(float x, float y, float w, float h, float rx, float ry);
- public abstract void fillRoundRect(float x, float y, float w, float h, float rx, float ry);
- public abstract void drawArc(float x, float y, float w, float h, float startAngle, float arcAngle);
- public abstract void fillArc(float x, float y, float w, float h, float startAngle, float arcAngle);
- public abstract void fillRect4Color(float x, float y, float w, float h, uint[] rgba);
- #endregion
- public abstract void drawTextLayer(
- TextLayer text,
- float x, float y,
- Anchor anchor);
- public abstract void drawTextLayer(
- TextLayer text,
- float x, float y, float w, float h,
- ImageAnchor anchor);
- public abstract void Dispose();
- }
- public class NullGraphics : CommonUI.Display.Graphics
- {
- public static NullGraphics SimpleGraphics = new NullGraphics();
- private float m_alpha = 1f;
- private Blend m_blend = Blend.BLEND_MODE_NORMAL;
- private uint m_color = 0xffffffff;
- public override void Dispose() { }
- public override void beginImage(Image image) { }
- public override void drawImage(float x, float y) { }
- public override void drawImage(Image image, float x, float y) { }
- public override void drawImage(float x, float y, Anchor anchor) { }
- public override void drawImage(Image image, float x, float y, Anchor anchor) { }
- public override void drawImageEllipse(float sx, float sy, float sw, float sh, float startAngle, float endAngle) { }
- public override void drawImageTrans(float x, float y, Trans trans) { }
- public override void drawImageTrans(Image image, float x, float y, Trans trans) { }
- public override void drawImageZoom(float x, float y, float w, float h) { }
- public override void drawImageZoom(Image image, float x, float y, float w, float h) { }
- public override void drawArc(float x, float y, float w, float h, float startAngle, float arcAngle) { }
- public override void drawLine(float x1, float y1, float x2, float y2) { }
- public override void drawRect(float x, float y, float w, float h) { }
- public override void drawRegion(float sx, float sy, float w, float h, Trans tx, float dx, float dy) { }
- public override void drawRegion(Image src, float sx, float sy, float w, float h, Trans tx, float dx, float dy) { }
- public override void drawRegion(float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { }
- public override void drawRegion(Image src, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh) { }
- public override void drawRoundRect(float x, float y, float w, float h, float rx, float ry) { }
- public override void fillRect4Color(float x, float y, float w, float h, uint[] rgba) { }
- public override void fillRoundRect(float x, float y, float w, float h, float rx, float ry) { }
- public override void fillArc(float x, float y, float w, float h, float startAngle, float arcAngle) { }
- public override void fillRect(float x, float y, float w, float h) { }
- public override void drawTextLayer(TextLayer text, float x, float y, Anchor anchor) { }
- public override void drawTextLayer(TextLayer text, float x, float y, float w, float h, ImageAnchor anchor) { }
- public override void drawVertex(VertexBuffer vertex) { }
- public override void drawVertex(VertexBuffer vertex, int[] indices, VertexTopology mode) { }
- public override void drawVertexSequence(VertexBuffer vertex, VertexTopology mode) { }
- public override float getAlpha() { return m_alpha; }
- public override Blend getBlend() { return m_blend; }
- public override uint getColor() { return m_color; }
- public override void setAlpha(float alpha) { }
- public override void setBlend(Blend blend) { }
- public override void setColor(uint color) { }
- public override void setColor(int red, int green, int blue) { }
- public override void setColor(float red, float green, float blue, float alpha) { }
- public override void setColor(int red, int green, int blue, int alpha) { }
- public override void PopClip() { }
- public override void PushClip() { }
- public override void SetClip(Rectangle2D rect) { }
- public override void SetClip(float x, float y, float w, float h) { }
- public override void pushTransform() { }
- public override void translate(float x, float y) { }
- public override void rotate(float angle) { }
- public override void scale(float sx, float sy) { }
- public override void popTransform() { }
- }
- }
|