예제 #1
0
        /// <summary>
        /// Sizes the control to its contents.
        /// </summary>
        public virtual void SizeToContents()
        {
            if (imageHandle.Id == ResourceHandle <Image> .Invalid)
            {
                return;
            }

            float texw = imageHandle.Resolve().Width;
            float texh = imageHandle.Resolve().Height;

            SetSize((int)texw, (int)texh);
        }
예제 #2
0
        public Single(ResourceHandle<Image> imageHandle, float x, float y, float w, float h )
        {
            this._imageHandle = imageHandle;

            float texw = imageHandle.Resolve().Width;
            float texh = imageHandle.Resolve().Height;

            m_uv = new float[4];
            m_uv[0] = x / texw;
            m_uv[1] = y / texh;
            m_uv[2] = (x + w) / texw;
            m_uv[3] = (y + h) / texh;

            m_Width = (int) w;
            m_Height = (int) h;
        }
예제 #3
0
        public Single(ResourceHandle <Image> imageHandle, float x, float y, float w, float h)
        {
            this._imageHandle = imageHandle;

            float texw = imageHandle.Resolve().Width;
            float texh = imageHandle.Resolve().Height;

            m_uv    = new float[4];
            m_uv[0] = x / texw;
            m_uv[1] = y / texh;
            m_uv[2] = (x + w) / texw;
            m_uv[3] = (y + h) / texh;

            m_Width  = (int)w;
            m_Height = (int)h;
        }
예제 #4
0
        void SetRect(int num, float x, float y, float w, float h)
        {
            float texw = imageHandle.Resolve().Width;
            float texh = imageHandle.Resolve().Height;

            //x -= 1.0f;
            //y -= 1.0f;

            m_Rects[num].uv[0] = x / texw;
            m_Rects[num].uv[1] = y / texh;

            m_Rects[num].uv[2] = (x + w) / texw;
            m_Rects[num].uv[3] = (y + h) / texh;

            //	rects[num].uv[0] += 1.0f / material->width;
            //	rects[num].uv[1] += 1.0f / material->width;
        }
예제 #5
0
        static TextRenderer()
        {
            textureAtlas = new TextureAtlas(512, PixelFormat.R8G8B8);
            glyphCache   = new GlyphCache();

            textMaterial = Material.Create(Allocator.GetHeap(), "TextMaterial");
            var mat = textMaterial.Resolve();

            mat.BackfaceCulling = false;
            mat.SetBlending(BlendSource.SourceAlpha, BlendDestination.InverseSourceAlpha);
            mat.SetShader("Text");
            mat.SetTexture(0, textureAtlas.AtlasImageHandle);
            mat.GetTextureUnit(0).WrapMode = TextureWrapMode.ClampToEdge;
        }
예제 #6
0
        public GlyphManager()
        {
            glyphSubTextures = new Dictionary<GlyphId, SubTexture>();
            glyphInfos = new Dictionary<GlyphId, Glyph>();

            textureAtlas = new TextureAtlas(512,PixelFormat.R8G8B8);

            textMaterial = Material.Create(Allocator.GetHeap(), "TextMaterial");
            var mat = textMaterial.Resolve();
            mat.BackfaceCulling = false;
            mat.SetBlending(BlendSource.SourceAlpha, BlendDestination.InverseSourceAlpha);
            mat.SetShader("Text");
            mat.SetTexture(0, textureAtlas.AtlasImageHandle);
            mat.GetTextureUnit(0).WrapMode = TextureWrapMode.ClampToEdge;
        }
예제 #7
0
        public override Color PixelColor(ResourceHandle <Image> imageHandle, uint x, uint y, Color defaultColor)
        {
            var image = imageHandle.Resolve();

            if (image == null || image.Width == 0)
            {
                return(defaultColor);
            }

            var offset = (int)(4 * (x + y * image.Width));
            var data   = image.Buffer;

            var pixel = new Color(data[offset + 0],
                                  data[offset + 1], data[offset + 2], data[offset + 3]);

            return(pixel);
        }
예제 #8
0
        public override Color PixelColor(ResourceHandle<Image> imageHandle, uint x, uint y, Color defaultColor)
        {
            var image = imageHandle.Resolve();
            if(image == null || image.Width == 0)
                return defaultColor;

            var offset = (int)(4 * (x + y * image.Width));
            var data = image.Buffer;

            var pixel = new Color(data[offset + 0],
                data[offset + 1], data[offset + 2], data[offset + 3]);

            return pixel;
        }
예제 #9
0
        static TextRenderer()
        {
            textureAtlas = new TextureAtlas(512,PixelFormat.R8G8B8);
            glyphCache = new GlyphCache();

            textMaterial = Material.Create(Allocator.GetHeap(), "TextMaterial");
            var mat = textMaterial.Resolve();
            mat.BackfaceCulling = false;
            mat.SetBlending(BlendSource.SourceAlpha, BlendDestination.InverseSourceAlpha);
            mat.SetShader("Text");
            mat.SetTexture(0, textureAtlas.AtlasImageHandle);
            mat.GetTextureUnit(0).WrapMode = TextureWrapMode.ClampToEdge;
        }