shapes

Combine multiple Ellipses

末鹿安然 提交于 2019-11-30 21:06:42
问题 I need a way to combine multiple EllipseGeometry to make a union between them, but CombineGeometry class only can combine 2 Geometries. The ideal way is to have a class similar CombineGeometry that accepts more than Geometry1 and Geometry2 shapes. Anyone knows an object that makes such a behaviour? 回答1: EllipseGeometry is a Geometry too so you can combine like this: <CombinedGeometry GeometryCombineMode="Union"> <CombinedGeometry.Geometry1> <EllipseGeometry RadiusX="70" RadiusY="30" Center=

Bind collection of lines to canvas in WPF

房东的猫 提交于 2019-11-30 16:04:50
问题 I have an observable collection of line segments specified by its boundary points. How can I bind it to draw the lines on a canvas? I have seen the solution for shapes using only one point to define the position. But for applying this approach to lines it need awkward precomputations on coordinates to get the position of outer rectangle and make line coordinates relative to it. Is there a way to avoid it? 回答1: Here is an example how you could do it: The line is defined as follows: public

Bind collection of lines to canvas in WPF

人走茶凉 提交于 2019-11-30 15:56:15
I have an observable collection of line segments specified by its boundary points. How can I bind it to draw the lines on a canvas? I have seen the solution for shapes using only one point to define the position. But for applying this approach to lines it need awkward precomputations on coordinates to get the position of outer rectangle and make line coordinates relative to it. Is there a way to avoid it? Here is an example how you could do it: The line is defined as follows: public class Line { public Point From { get; set; } public Point To { get; set; } } MainWindow.xaml: <Window x:Class=

Libgdx - How to draw filled rectangle in the right place in scene2d?

ε祈祈猫儿з 提交于 2019-11-30 14:49:00
问题 I am using scene2d. Here is my code: group.addActor(new Actor() { @Override public Actor hit(float arg0, float arg1) {return null;} @Override public void draw(SpriteBatch batch, float arg1) { batch.end(); shapeRenderer.begin(ShapeType.FilledRectangle); shapeRenderer.setColor(Color.RED); shapeRenderer.filledRect(0, 0, 300, 20); shapeRenderer.end(); batch.begin(); } }); The problem is that it draws this rectangular relative to screen (x = 0, y = 0), but I need it to be drawn relative to my

How to create a sphere in css?

心不动则不痛 提交于 2019-11-30 13:23:01
问题 I have trying to create a 3D sphere using just pure css, but I've been unable to generate the shape required. I've seen a cylinder but I can't find any reference to creating an actual sphere . My current code looks like: .red { background-color: red; } .green { background-color: green; } .blue { background-color: blue; } .yellow { background-color: yellow; } .sphere { height: 200px; width: 200px; border-radius: 50%; text-align: center; vertical-align: middle; font-size: 500%; position:

Check if Polygon is Self-Intersecting

心已入冬 提交于 2019-11-30 12:42:03
问题 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? 回答1: 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

How to draw a smaller ShapeDrawable inside another shapeDrawable programmatically

好久不见. 提交于 2019-11-30 09:59:01
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( 10 ); smallerCircle.setIntrinsicWidth( 10); smallerCircle.setBounds(new Rect(0, 0, 10, 10));

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

谁都会走 提交于 2019-11-30 09:25:03
问题 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. 回答1: 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

How to draw and move shapes using mouse in C#

这一生的挚爱 提交于 2019-11-30 07:34:31
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() { InitializeComponent(); this.DoubleBuffered = true; } Rectangle rec = new Rectangle(0, 0, 0, 0); protected override

How to create a sphere in css?

左心房为你撑大大i 提交于 2019-11-30 07:14:05
I have trying to create a 3D sphere using just pure css, but I've been unable to generate the shape required. I've seen a cylinder but I can't find any reference to creating an actual sphere . My current code looks like: .red { background-color: red; } .green { background-color: green; } .blue { background-color: blue; } .yellow { background-color: yellow; } .sphere { height: 200px; width: 200px; border-radius: 50%; text-align: center; vertical-align: middle; font-size: 500%; position: relative; box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black; display: