public override void Draw(CanvasRenderingContext2D canv) { base.Draw(canv); if (!Visible) return; if (Palette == null) return; canv.Save(); canv.StrokeStyle = "#000"; canv.LineWidth = 2; var pos = new Point(TotalX, TotalY); var f = (int)Math.Round(Palette.Length / 2.0); if (Wide) { for (var h = 0; h < 2; h++) { for (var w = 0; w < f; w++) { canv.FillStyle = Palette[w + h * f]; canv.FillRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); canv.StrokeRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); } } if (ShowCurrent) { canv.FillStyle = Palette[SelectedIndex]; canv.FillRect(pos.X + f * Scale.X , pos.Y, Scale.X * 2, Scale.Y * 2); canv.StrokeRect(pos.X + f * Scale.X , pos.Y, Scale.X * 2, Scale.Y * 2); } } else { for (var h = 0; h < f; h++) { for (var w = 0; w < 2; w++) { canv.FillStyle = Palette[w + h * 2]; canv.FillRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); canv.StrokeRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); } } if (ShowCurrent) { canv.FillStyle = Palette[SelectedIndex]; canv.FillRect(pos.X, pos.Y + f * Scale.Y , Scale.X * 2, Scale.Y * 2); canv.StrokeRect(pos.X, pos.Y + f * Scale.Y , Scale.X * 2, Scale.Y * 2); } } canv.Restore(); }
public void Draw(CanvasRenderingContext2D canvas, int x, int y, bool showHeightMap) { if (Dead || ObjectData.Falsey()) return; if (ObjectData.PieceLayouts.Count == 0) { canvas.DrawImage(ObjectManager.broken, ( x - ObjectManager.broken.Width / 2 ), ( y - ObjectManager.broken.Height / 2 ), ObjectManager.broken.Width, ObjectManager.broken.Height); return; } MainPieceLayout().Draw(canvas, x, y, ObjectData, this, showHeightMap); if (ConsoleLog != null) { var gr = GetRect(); canvas.Save(); canvas.FillStyle = "rgba(228,228,12,0.4)"; var wd = 1; canvas.FillRect(gr.X - X + x - ( gr.Width / 2 ) - wd, gr.Y - Y + y - ( gr.Height / 2 ) - wd, gr.Width - ( gr.X - X ) + wd * 2, gr.Height - ( gr.Y - Y ) + wd * 2); canvas.Restore(); } }
public override void Draw(CanvasRenderingContext2D canv) { if (!Visible) return; canv.Save(); canv.FillStyle = BackColor; var width = VisibleItems * ( ItemWidth + JWidth ) - 2; canv.FillStyle = BackColor; canv.LineWidth = 1; canv.StrokeStyle = "#333"; Help.RoundRect(canv, TotalX, TotalY, VisibleItems * ( ItemWidth + JWidth ) + 2, ItemHeight + ScrollWidth + 6, 3, true, true); canv.FillStyle = "grey"; canv.LineWidth = 1; canv.StrokeStyle = "#444"; canv.FillRect(TotalX + 2, TotalY + ItemHeight + 6, VisibleItems * ( ItemWidth + JWidth ), ScrollWidth); canv.FillStyle = "FFDDFF"; canv.LineWidth = 1; canv.StrokeStyle = "#FFDDFF"; ScrollPosition = width * ScrollOffset / ( Controls.Count - VisibleItems ); canv.FillRect(TotalX + ( ScrollPosition ) + 2, TotalY + ItemHeight + 6, 5, ScrollWidth - 2); var curX = 3; for (var i = ScrollOffset; i < Math.Min(Controls.Count, ScrollOffset + VisibleItems); i++) { Controls[i].Parent = this; Controls[i].X = curX; Controls[i].Y = 2; Controls[i].Height = ItemHeight; Controls[i].Width = ItemWidth; curX += ItemWidth + JWidth; Controls[i].Draw(canv); } canv.Restore(); base.Draw(canv); }
public void Draw(CanvasRenderingContext2D canv) { canv.Save(); var size = 0; canv.StrokeStyle = canv.FillStyle = "white"; canv.LineWidth = 3; canv.Me().dashedRect(Element.TotalX - size, Element.TotalY - size, Element.Width + size * 2, Element.Height + size * 2, new int[] {2, 2}); //canv.strokeRect(this.element.totalX() - size, this.element.totalY() - size, this.element.width + size * 2, this.element.height + size * 2); var x = Element.TotalX; var y = Element.TotalY; var w = Element.Width; var h = Element.Height; foreach (var j in points) { canv.FillRect(x + ( w * j.X / 100 ) - j.Size / 2, y + ( h * j.Y / 100 ) - j.Size / 2, j.Size, j.Size); } canv.Restore(); }
public override void Draw(CanvasRenderingContext2D canv) { if (!Visible) return; canv.Save(); if (!Focused) { CursorPosition = -1; DragPosition = -1; } DrawTicks++; can = canv; canv.StrokeStyle = ButtonBorderGrad; canv.FillStyle = Clicking ? Button1Grad : Button2Grad; canv.LineWidth = 2; Help.RoundRect(canv, TotalX, TotalY, Width, Height, 2, true, true); if (canv.Font != Font) canv.Font = Font; if (DragPosition != -1) { canv.FillStyle = "#598AFF"; var w1 = canv.MeasureText(Text.Substring(0, Math.Min(DragPosition, CursorPosition))).Width; var w2 = canv.MeasureText(Text.Substring(0, Math.Max(DragPosition, CursorPosition))).Width; canv.FillRect(TotalX + 8 + w1, TotalY + 3, w2 - w1, ( Height - 7 )); } canv.FillStyle = "#000000"; int hc; if (canv.Font.IndexOf("pt") != -1) hc = int.Parse(canv.Font.Substr(0, canv.Font.IndexOf("pt"))); else hc = int.Parse(canv.Font.Substr(0, canv.Font.IndexOf("px"))); canv.FillText(Text, TotalX + 8, TotalY + ( ( Height - hc ) / 2 ) + Height / 2); if (Focused && ( ( blinkTick++ % 35 ) == 0 )) blinked = !blinked; if (Focused && blinked) { canv.StrokeStyle = "#000000"; var w = canv.MeasureText(Text.Substring(0, CursorPosition)).Width; canv.BeginPath(); canv.MoveTo(TotalX + 8 + w, TotalY + 3); canv.LineTo(TotalX + 8 + w, TotalY + ( Height - 7 )); canv.LineWidth = 2; canv.Stroke(); } canv.Restore(); base.Draw(canv); }