public virtual void Map(int[] data, int cols) { this.data = data; mapWidth = cols; mapHeight = data.Length / cols; size = mapWidth * mapHeight; _Width = _cellW * mapWidth; _Height = _cellH * mapHeight; quads = Quad.CreateSet(size); updated.Set(0, 0, mapWidth, mapHeight); }
public NinePatch(object tx, int x, int y, int w, int h, int Left, int Top, int Right, int Bottom) : base(0, 0, 0, 0) { texture = TextureCache.Get(tx); w = w == 0 ? texture.Width : w; h = h == 0 ? texture.Height : h; nWidth = _Width = w; nHeight = _Height = h; vertices = new float[16]; verticesBuffer = Quad.CreateSet(9); marginLeft = Left; marginRight = Right; marginTop = Top; marginBottom = Bottom; outterF = texture.UvRect(x, y, x + w, y + h); innerF = texture.UvRect(x + Left, y + Top, x + w - Right, y + h - Bottom); UpdateVertices(); }
protected internal virtual void UpdateVertices() { _Width = 0; _Height = 0; if (text == null) { text = ""; } Quads = Quad.CreateSet(text.Length); RealLength = 0; var length = text.Length; for (var i = 0; i < length; i++) { var rect = ((TextureFilm)font).Get(text[i]); var w = font.Width(rect); var h = font.Height(rect); Vertices[0] = Width; Vertices[1] = 0; Vertices[2] = rect.Left; Vertices[3] = rect.Top; Vertices[4] = Width + w; Vertices[5] = 0; Vertices[6] = rect.Right; Vertices[7] = rect.Top; Vertices[8] = Width + w; Vertices[9] = h; Vertices[10] = rect.Right; Vertices[11] = rect.Bottom; Vertices[12] = Width; Vertices[13] = h; Vertices[14] = rect.Left; Vertices[15] = rect.Bottom; Quads.Put(Vertices); RealLength++; _Width += w + font.tracking; if (h > Height) { _Height = h; } } if (length > 0) { _Width -= font.tracking; } Dirty = false; }
protected internal override void UpdateVertices() { if (text == null) { text = ""; } Quads = Quad.CreateSet(text.Length); RealLength = 0; // This object controls lines breaking var writer = new SymbolWriter(font, MaxWidth, Scale); // Word Size var metrics = new PointF(); var paragraphs = Paragraph.Split(text); // Current character (used in masking) var pos = 0; foreach (var words in paragraphs.Select(paragraph => Word.Split(paragraph))) { foreach (var word in words.Where(word => word.Length != 0)) { GetWordMetrics(word, metrics); writer.AddSymbol(metrics.X, metrics.Y); var length = word.Length; var shift = 0f; // Position in pixels relative to the beginning of the word for (var k = 0; k < length; k++) { var rect = ((TextureFilm)font).Get(word[k]); var w = font.Width(rect); var h = font.Height(rect); if (Mask == null || Mask[pos]) { Vertices[0] = writer.x + shift; Vertices[1] = writer.y; Vertices[2] = rect.Left; Vertices[3] = rect.Top; Vertices[4] = writer.x + shift + w; Vertices[5] = writer.y; Vertices[6] = rect.Right; Vertices[7] = rect.Top; Vertices[8] = writer.x + shift + w; Vertices[9] = writer.y + h; Vertices[10] = rect.Right; Vertices[11] = rect.Bottom; Vertices[12] = writer.x + shift; Vertices[13] = writer.y + h; Vertices[14] = rect.Left; Vertices[15] = rect.Bottom; Quads.Put(Vertices); RealLength++; } shift += w + font.tracking; pos++; } writer.AddSpace(SpaceSize); } writer.NewLine(0, font.LineHeight); } Dirty = false; }