public Size GetMaxCharacterSize(BGICanvas.Direction dir, int size) { if (dir == BGICanvas.Direction.Horizontal) { return(new Size(Width * size, Height * size)); } else { return(new Size(Height * size, Width * size)); } }
public Size GetTextSize(string str, BGICanvas.Direction dir, int size) { if (dir == BGICanvas.Direction.Horizontal) { return(new Size(str.Length * Width * size, Height * size)); } else { return(new Size(Height * size, str.Length * Width * size)); } }
public float DrawCharacter(BGICanvas bgi, float x, float y, BGICanvas.Direction dir, int size, byte character, IList <Rectangle> updates) { BGICharacter ch = this[character]; if (ch != null) { var drawUpdates = updates ?? new List <Rectangle>(); ch.Draw(bgi, x, y, dir, size, updates); if (updates == null) { bgi.UpdateRegion(drawUpdates); } return(ch.GetWidth(size)); } return(0); }
public void Draw(BGICanvas bgi, float x, float y, BGICanvas.Direction dir, int size, IList <Rectangle> updates) { var drawUpdates = updates ?? new List <Rectangle> (); var height = font.Height * scaleup [size] / scaledown [size]; if (dir == BGICanvas.Direction.Horizontal) { foreach (var stroke in strokes) { int curx = (int)x + (stroke.x * scaleup [size] / scaledown [size]); int cury = (int)y + height - (stroke.y * scaleup [size] / scaledown [size]); if (stroke.type == StrokeType.MoveTo) { bgi.MoveTo(curx, cury); } else if (stroke.type == StrokeType.LineTo) { bgi.LineTo(curx, cury, drawUpdates); } } } else { foreach (var stroke in strokes) { int curx = (int)x + height - (stroke.y * scaleup [size] / scaledown [size]); int cury = (int)y - (stroke.x * scaleup [size] / scaledown [size]); if (stroke.type == StrokeType.MoveTo) { bgi.MoveTo(curx, cury); } else if (stroke.type == StrokeType.LineTo) { bgi.LineTo(curx, cury, drawUpdates); } } } if (updates == null) { bgi.UpdateRegion(drawUpdates); } }
public Size GetMaxCharacterSize(BGICanvas.Direction dir, int size) { float width = 0; foreach (var ch in characters) { if (ch != null) { width = Math.Max(width, ch.GetWidth(size)); } } if (dir == BGICanvas.Direction.Horizontal) { return(new Size(BGICanvas.Round(width), (int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]))); } else { return(new Size((int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), BGICanvas.Round(width))); } }
public Size GetTextSize(string str, BGICanvas.Direction dir, int size) { float width = 0; foreach (byte c in BGICanvas.Encoding.GetBytes(str)) { BGICharacter ch = this[c]; if (ch != null) { width += ch.Width; } } if (dir == BGICanvas.Direction.Horizontal) { return(new Size(BGICanvas.Trunc(width * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), (int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]))); } else { return(new Size((int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), BGICanvas.Trunc(width * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]))); } }
public Size GetRealTextSize(string str, BGICanvas.Direction dir, int size) { return(GetTextSize(str, dir, size)); }
public float DrawCharacter(BGICanvas bgi, float x, float y, BGICanvas.Direction dir, int size, byte character, IList <Rectangle> updates) { byte foreCol = bgi.GetColor(); FontCharacter fc = this[character]; if (dir == BGICanvas.Direction.Horizontal) { int starty = (int)y; for (int cy = 0; cy < Height; cy++) { int startx = (int)x; for (int cx = 0; cx < Width; cx++) { if (fc[cx, cy]) { if (size == 1) { bgi.PutPixelInternal(startx, starty, foreCol); } else { for (int ccy = 0; ccy < size; ccy++) { for (int ccx = 0; ccx < size; ccx++) { bgi.PutPixelInternal(startx + ccx, starty + ccy, foreCol); } } } } startx += size; } starty += size; } var updateRect = new Rectangle((int)x, (int)y, Width * size, Height * size); if (updates != null) { updates.Add(updateRect); } else { bgi.UpdateRegion(updateRect); } } else { int startx = (int)x; for (int cy = 0; cy < Height; cy++) { int starty = (int)y; for (int cx = 0; cx < Width; cx++) { if (fc[cx, cy]) { if (size == 1) { bgi.PutPixelInternal(startx, starty, foreCol); } else { for (int ccy = 0; ccy < size; ccy++) { for (int ccx = 0; ccx < size; ccx++) { bgi.PutPixelInternal(startx + ccx, starty - ccy, foreCol); } } } } starty -= size; } startx += size; } var updateRect = new Rectangle((int)x, (int)y, Height * size, Width * size); if (updates != null) { updates.Add(updateRect); } else { bgi.UpdateRegion(updateRect); } } return(Width * size); }