shapes

Check if Polygon is Self-Intersecting

若如初见. 提交于 2019-11-30 03:24:59
I have a System.Windows.Shapes.Polygon object, whose layout is determined completely by a series of Points. I need to determine if this Polygon is self intersecting; i.e., if any of the sides of the polygon intersect any of the other sides at a point which is not a vertex. Is there an easy/fast way to compute this? Easy, slow, low memory footprint : compare each segment against all others and check for intersections. Complexity O(n 2 ) . Slightly faster, medium memory footprint (modified version of above): store edges in spatial "buckets", then perform above algorithm on per-bucket basis.

Multiline text as the button label in Windows Forms

依然范特西╮ 提交于 2019-11-30 01:50:46
问题 Basically, I am creating a button in an oval shape. But my button label is too long to display in one line, so I wanted to split it into multiple lines so that the oval button looks good. How do I enable word wrap on a button? 回答1: Set the label text on form load and add Environment.Newline as the newline string, like this: btnOK.Text = "OK" + Environment.NewLine + "true"; 回答2: If you want to set a button's label to multi-line text inside the VS designer, you can click on the "down arrow" at

Drawing multiple shapes with ShapeDrawable in xml with Android

纵然是瞬间 提交于 2019-11-29 21:15:11
I am currently drawing a number of circles on a canvas in a custom view in code. the circles are static and do not change. I would like to draw them using a ShapeDrawable in xml to help clean up my code. I will have a number of different drawables which the user can select and therefore I don't want to do this in code. having 3 or 4 xml drawables seems a lot neater to me. I have created one circle in xml using a ShapeDrawable but am unable to add more than one shape to the xml. How do I add multiple shapes to an xml document using ShapeDrawable. Here's how I did a filled red circle with a one

D3 force directed graph, different shape according to data and value given?

≡放荡痞女 提交于 2019-11-29 18:18:36
问题 I've made a force directed graph and I wanted to change shape of nodes for data which contains "entity":"company" so they would have rectangle shape, and other one without this part of data would be circles as they are now. You can see my working example with only circle nodes here: http://jsfiddle.net/dzorz/uWtSk/ I've tried to add rectangles with if else statement in part of code where I append shape to node like this: function(d) { if (d.entity == "company") { node.append("rect") .attr(

How to draw a smaller ShapeDrawable inside another shapeDrawable programmatically

扶醉桌前 提交于 2019-11-29 15:20:36
问题 Im trying to draw a smaller circle within another circle. It seems pretty simple but Im having trouble with this and couldnt find an answer. The code im using is: ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape()); biggerCircle.setIntrinsicHeight( 60 ); biggerCircle.setIntrinsicWidth( 60); biggerCircle.setBounds(new Rect(0, 0, 60, 60)); biggerCircle.getPaint().setColor(Color.BLUE); ShapeDrawable smallerCircle= new ShapeDrawable( new OvalShape()); smallerCircle.setIntrinsicHeight(

Any way to have text in div fill a triangle shape?

佐手、 提交于 2019-11-29 15:18:32
I'm trying to have a block of text in a div fill a downward triangle shape. Is there any way to achieve this with either CSS or Javascript? This is for a site in which users can dynamically insert text. I'm trying to avoid the alternative method, which is to have them insert text line by line with a limit on each line. gilly3 Your question is very similar to this one . I know of no CSS way, but you can do it with JavaScript. The idea is to find where each line of text breaks and wrap the remaining text in a new child div. You have to use text ranges to accomplish it. See this demo: http:/

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

Resizing Path2D circle by clicking and dragging its outer edge

允我心安 提交于 2019-11-29 13:05:21
So, when I click and drag a Path2D circle on my JPanel, it is resizing. The problem is that when I initially click-and-drag it, the circle jumps to a smaller size, but then resized correctly as you click and drag. The easiest way to demonstrate is to run the runnable code below. I know I need to fix this code: @Override public void mouseDragged(MouseEvent e) { int mouseX = e.getX(); int mouseY = e.getY(); if (resizing) { System.out.println("resizing"); Rectangle bounds = shapes.get(currentIndex).getBounds(); int shapeX = bounds.x; int shapeY = bounds.y; shapes.get(currentIndex).reset(); shapes

Defining Drawable Shape with in JAVA code

人走茶凉 提交于 2019-11-29 12:05:59
Hi Can I define this shape without using xml code <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#34342C" android:endColor="#848486" android:angle="90" /> <padding android:left="7dp" android:top="5dp" android:right="7dp" android:bottom="5dp" /> <stroke android:width="1dp" android:color="#FFFFFF" /> </shape> Thanks for your help Yes use a ShapeDrawable to draw your rectangle with the padding you require using a Paint with the appropriate color and stroke width using a Linear gradient and adding this to the Paint as a

How to draw and move shapes using mouse in C#

ⅰ亾dé卋堺 提交于 2019-11-29 10:16:35
问题 I'm new to programming in C# and wanted to ask for a little bit of help. I'm currently trying to move a color-filled rectangle that I draw on a Windows Application form with my left mouse button, and I'm trying to drag-and-drop it to another location using my right mouse button. Currently I've managed to draw the rectangle, but the right click is dragging the entire form along. Here's my code: public partial class Form1 : Form { private Point MouseDownLocation; public Form1() {