drawing2d

Android: Drawing on Canvas in Scrollview

馋奶兔 提交于 2019-11-30 05:16:09
问题 I'm pretty much new in programing for Android. My app is sample app from api demos on developer android website. When I change parameters in that sample drawing it gets larger . That drawing needs to be displayed in scroll view (it doesn't need to be shrinked to fit the screen). This is the code I used: DrawPoints.java public class DrawPoints extends myActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.routes); }

How do I draw an annulus (doughnut) using GDI+?

南楼画角 提交于 2019-11-29 15:13:18
I have been trying to draw an annulus (ring with thickness) with a transparent hole and a gradient rim in C# with very little success. Does anyone have any suggestions on how to do this? here's a nice Blend Utility Here's the Final result - thanks to BlueMonkMN Rectangle GetSquareRec(double radius, int x, int y) { double r = radius; double side = Math.Sqrt(Math.Pow(r, 2) / 2); Rectangle rec = new Rectangle(x - ((int)side), y - ((int)side), (int)(side * 2) + x, (int)(side * 2) + y); return rec; } void Form1_Paint(object sender, PaintEventArgs e) { Graphics gTarget = e.Graphics; gTarget

I need a pixel-perfect triangle fill algorithm to avoid aliasing artifacts

梦想与她 提交于 2019-11-27 15:00:15
问题 I'm assisting someone with user interface code to visualise a mathematical image analysis. During this process we'll be segmenting part of a 2D shape into triangles, and filling some of these triangles in on the UI. We're looking for a fill algorithm which guarantees that if two triangles share an edge (specifically, if any two vertices of the triangles are identical), then regardless of drawing order and aliasing there will be not be blank, undrawn pixels on the line between the two. (It's

How to know if a line intersects a rectangle

冷暖自知 提交于 2019-11-27 08:41:17
I have checked out this question, but the answer is very large for me: How to know if a line intersects a plane in C#? - Basic 2D geometry Is there any .NET method to know if a line defined by two points intersects a rectangle? public bool Intersects(Point a, Point b, Rectangle r) { // return true if the line intersects the rectangle // false otherwise } Thanks in advance. public static bool LineIntersectsRect(Point p1, Point p2, Rectangle r) { return LineIntersectsLine(p1, p2, new Point(r.X, r.Y), new Point(r.X + r.Width, r.Y)) || LineIntersectsLine(p1, p2, new Point(r.X + r.Width, r.Y), new

How to know if a line intersects a rectangle

99封情书 提交于 2019-11-26 17:46:26
问题 I have checked out this question, but the answer is very large for me: How to know if a line intersects a plane in C#? - Basic 2D geometry Is there any .NET method to know if a line defined by two points intersects a rectangle? public bool Intersects(Point a, Point b, Rectangle r) { // return true if the line intersects the rectangle // false otherwise } Thanks in advance. 回答1: public static bool LineIntersectsRect(Point p1, Point p2, Rectangle r) { return LineIntersectsLine(p1, p2, new Point