public override bool Collides(float x, float y, int screenWidth, int screenHeight) { float _x_ = this.x; float _y_ = this.y; control.GetTransform().Transform(ref _x_, ref _y_); float _x = x - _x_; float _y = y - _y_; return(_x * _x + _y * _y <= innerRad * innerRad); }
public override bool Collides(float x, float y, int screenWidth, int screenHeight) { float _x_ = this.x; float _y_ = this.y; control.GetTransform().Transform(ref _x_, ref _y_); float _x = x - _x_; float _y = y - _y_; float len_sq = _x * _x + _y * _y; return(len_sq <= (rad + width) * (rad + width) && len_sq >= (rad - width) * (rad - width)); }
public override void Draw(GPURenderer renderer, int width, int height) { renderer.Transform(Transformation); RectangleF rect = new RectangleF(0, 0, width, size); renderer.FillRectangle(Color.FromArgb(100, 200, 200, 200), rect); renderer.DrawRect(Color.Black, 1, rect); float scale = parent.GetTransform().GetScale(); int linMM = (int)(Util.PointToMm(width) / scale); float len1 = Util.MmToPoint(3); float len2 = Util.MmToPoint(5); float len3 = Util.MmToPoint(10); renderer.BeginLines(Color.Black, 1); for (int i = 0; i <= linMM; i++) { float x = Util.MmToPoint(i) * scale; float y1 = len1; if (i % 5 == 0) { y1 = len2; } if (i % 10 == 0) { y1 = len3; } renderer.BatchedLine(new PointF(x, 0), new PointF(x, y1)); renderer.BatchedLine(new PointF(x, size), new PointF(x, size - y1)); //renderer.DrawLine(Color.Black, 1, new PointF(x, 0), new PointF(x, y1)); //renderer.DrawLine(Color.Black, 1, new PointF(x, size), new PointF(x, size - y1)); } renderer.EndLines(); float tx = width / 2; double deg = Math.Abs( Math.Round( (Transformation.GetRotation() - parent.GetTransform().GetRotation()) * 18000.0 / Math.PI) / 100.0); if (deg > 90) { deg = 180 - deg; } renderer.DrawText("" + deg + "°", PBrush.CreateSolid(Color.Tomato), new RectangleF(Util.PointToMm(tx), 10, 50, 50), 20); }
public override void Draw(GPURenderer renderer, int width, int height) { Matrix3x3 rotate = Matrix3x3.Rotate(angle); renderer.Transform(rotate); renderer.Transform(Transformation); PBrush bgrColor = PBrush.CreateSolid(Color.FromArgb(100, 200, 200, 200)); PBrush fgrColor = PBrush.CreateSolid(Color.Black); PBrush fntColor = PBrush.CreateSolid(Color.Tomato); RectangleF rect1 = new RectangleF(-ballRad, -ballRad, ballRad * 2, ballRad * 2); RectangleF rect2 = rect1; rect2.X += rad; renderer.FillEllipse(bgrColor, rect1); renderer.FillEllipse(bgrColor, rect2); renderer.DrawEllipse(fgrColor, 2, rect1); renderer.DrawEllipse(fgrColor, 2, rect2); renderer.DrawLine(Color.Black, 2, new PointF(ballRad, 0), new PointF(rad - ballRad, 0)); renderer.DrawLine(Color.Tomato, 1, new PointF(-ballRad, 0), new PointF(ballRad, 0)); renderer.DrawLine(Color.Tomato, 1, new PointF(0, -ballRad), new PointF(0, ballRad)); renderer.DrawLine(Color.Tomato, 1, new PointF(-ballRad + rad, 0), new PointF(ballRad + rad, 0)); renderer.DrawLine(Color.Tomato, 1, new PointF(rad, -ballRad), new PointF(rad, ballRad)); float pageScale = parent.GetTransform().GetScale(); float pageRot = parent.GetTransform().GetRotation(); string strRad = "" + Math.Round(Util.PointToMm(rad / pageScale) * 100.0) / 100.0; string strDeg = "" + Math.Round((pageRot - angle) * 18000.0 / Math.PI) / 100.0; renderer.DrawText($"{strRad}mm\n{strDeg}°", fntColor, new RectangleF(Util.PointToMm(ballRad), Util.PointToMm(-ballRad), 500, 50), 10); renderer.ResetTransform(); }