public override void Draw(CanvasContext2D context) { context.Save(); context.FillStyle = "blue"; context.FillRect(X - 13, Y - 13, 26, 26); context.Restore(); }
public void Draw(CanvasContext2D 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(); }
private static void drawGrad(CanvasContext2D context, object radgrad, double size) { context.FillStyle = radgrad; context.FillRect(0, 0, size, size); }
public override void Draw(CanvasContext2D context) { context.FillStyle = "red"; context.FillRect(100, 100, 200, 200); context.DrawImage(someImage, 250, 250); context.DrawImage(someImage, 350, 350, 100, 100, 200, 200, 100, 100); for (int i = 0; i < DebugText.Length; i++) { if (DebugText[i].Truthy()) { context.Save(); context.StrokeStyle = "white"; context.StrokeText(DebugText[i].ToString(), Screen.Width - 120, i * 20 + 150); context.Restore(); } } }
public override void Draw(CanvasContext2D canv) { if (!Visible) return; canv.Save(); canv.FillStyle = BackColor; var width = VisibleItems * ( ItemWidth + JWidth ) - 2; canv.FillStyle = BackColor; canv.LineWidth = 1; canv.StrokeStyle = "#333"; CHelp.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); }
private bool DrawTriangle(CanvasContext2D ctx, ImageElement im, double x0, double y0, double x1, double y1, double x2, double y2, double sx0, double sy0, double sx1, double sy1, double sx2, double sy2) { if (!Intersects(0, Width, 0, Height, x0, y0, x1, y1, x2, y2)) { return false; } //double edgeOffset = isOutlined ? ContractionInPixels : ExpansionInPixels; //Vector2d expandedS0 = GetMiterPoint(Vector2d.Create(x0, y0), Vector2d.Create(x1, y1), Vector2d.Create(x2, y2), ExpansionInPixels); //Vector2d expandedS1 = GetMiterPoint(Vector2d.Create(x1, y1), Vector2d.Create(x0, y0), Vector2d.Create(x2, y2), ExpansionInPixels); //Vector2d expandedS2 = GetMiterPoint(Vector2d.Create(x2, y2), Vector2d.Create(x1, y1), Vector2d.Create(x0, y0), ExpansionInPixels); //Vector2d expandedS0 = MiterPoint(x0, y0, x1, y1, x2, y2); //Vector2d expandedS1 = MiterPoint(x1, y1, x0, y0, x2, y2); //Vector2d expandedS2 = MiterPoint(x2, y2, x1, y1, x0, y0); MiterPointOut(expandedS0, x0, y0, x1, y1, x2, y2, ExpansionInPixels); MiterPointOut(expandedS1, x1, y1, x0, y0, x2, y2, ExpansionInPixels); MiterPointOut(expandedS2, x2, y2, x1, y1, x0, y0, ExpansionInPixels); x0 = expandedS0.X; y0 = expandedS0.Y; x1 = expandedS1.X; y1 = expandedS1.Y; x2 = expandedS2.X; y2 = expandedS2.Y; ctx.Save(); if (RenderingOn) { ctx.BeginPath(); ctx.MoveTo(x0, y0); ctx.LineTo(x1, y1); ctx.LineTo(x2, y2); ctx.ClosePath(); ctx.Clip(); } double denom = sx0 * (sy2 - sy1) - sx1 * sy2 + sx2 * sy1 + (sx1 - sx2) * sy0; //if (denom == 0) //{ // ctx.Restore(); // return false; //} double m11 = -(sy0 * (x2 - x1) - sy1 * x2 + sy2 * x1 + (sy1 - sy2) * x0) / denom; double m12 = (sy1 * y2 + sy0 * (y1 - y2) - sy2 * y1 + (sy2 - sy1) * y0) / denom; double m21 = (sx0 * (x2 - x1) - sx1 * x2 + sx2 * x1 + (sx1 - sx2) * x0) / denom; double m22 = -(sx1 * y2 + sx0 * (y1 - y2) - sx2 * y1 + (sx2 - sx1) * y0) / denom; double dx = (sx0 * (sy2 * x1 - sy1 * x2) + sy0 * (sx1 * x2 - sx2 * x1) + (sx2 * sy1 - sx1 * sy2) * x0) / denom; double dy = (sx0 * (sy2 * y1 - sy1 * y2) + sy0 * (sx1 * y2 - sx2 * y1) + (sx2 * sy1 - sx1 * sy2) * y0) / denom; ctx.Transform(m11, m12, m21, m22, dx, dy); if (RenderingOn) { ctx.Alpha = Opacity; if (lighting < 1.0) { ctx.Alpha = 1; ctx.FillStyle = "Black"; ctx.FillRect(0, 0, Width, Height); ctx.Alpha = lighting * Opacity; } ctx.DrawImage(im, 0, 0); } ctx.Restore(); return true; }
public override void Draw(CanvasContext2D 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; CHelp.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); }