/// <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); }
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; }
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; }
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; }
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; }
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; }
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); }
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; }
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; }