shape

How to draw a diamond shape in java?

最后都变了- 提交于 2019-12-24 04:22:35
问题 So i have to draw a diamond shape. Not a Static diamond but a diamond that i will myself drag and draw. I've used General Path to do it but it is drawing a diamond that is not straight; the diamond is bend to the left and it's not being drawn to where my mouse is pointed. Here is my code to create the diamond shape. Can someone please help me solve this? private GeneralPath drawDiamond(int x1, int y1, int x2, int y2){ int x = Math.min(x1, x2); int y = Math.min(y1, y2); // Gets the difference

Tracking white ball in white background (Python/OpenCV)

自闭症网瘾萝莉.ら 提交于 2019-12-23 21:26:11
问题 i'm using OpenCV in Python 3 to detect a white/black ball on a white field and give it's exact (x,y,radius) and color. I use the function cv2.Canny() and cv2.findContours() to find it but the problem is cv2.Canny() dont's always detect the complete shape of the circle (most of time only 3/4 of the circle). So when i use cv2.findContours() it don't detect it as a Contour. Please see : and This is the most important code: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur

Programmatically add Gradient with solid color and stroke

前提是你 提交于 2019-12-23 19:15:07
问题 Currently I am using this code to add color: ShapeDrawable drawable = new ShapeDrawable(new OvalShape()); drawable.getPaint().setColor(color); Now I need to apply some gradient colors to it along with stroke(like border with different color). I am setting this as background to button. Here is what I am expecting, I need to do it programmatically. 回答1: Add a RadialGradient to your drawable like this: Shader shader = new RadialGradient(x, y, radius, color0, color1, Shader.TileMode.REPEAT);

MS PowerPoint: how to convert a shape's position and size into screen coordinates?

时间秒杀一切 提交于 2019-12-23 18:13:56
问题 I wrote me a little VBA Macro for PowerPoint (2010) that opens a popup with explanations when hovering over some Shape. This works fine. Alas, there is no event that is triggered when leaving the area again and so I now want to extend the code such that it monitors the area of the popup and when the pointer leaves that area it removes the popup again. But now I ran into some stupid problem: the coordinates of the Shape (.Left, .Top, .Width, and .Height) are given in some "document units" (don

Transforming a shape

我是研究僧i 提交于 2019-12-23 17:13:50
问题 I have two points that I want to connect in a specific way - see the first picture. I know the coordinates of all four points. I then need to move the whole shape to coordinates [0, 0] and rotate it, so the main two points are both on x-axis (see the second picture). Next I need to "squeeze" the shape on the x-axis only so that the last point has coordinates [0, 1] (see the last picture). My question is - how do I compute the coordinates of the middle two points effectively in Java without

Worldwind - Shapes are always displayed on top of images?

醉酒当歌 提交于 2019-12-23 15:47:31
问题 I have two layers added to the layerlist of WorldWindowGLJPanel. One of them is RenderableLayer which contain shapes and the other is BasicTiledImageLayer containing raster images. (One layer contains one object). The problem is when i change the order of layers with layermanager panel, only the order of objects that have the same type of layer changes and shapes are always displayed on top of images no matter which order they have. Is there a way to correct this? Screenshots: And my code is

Graphics2D: Should I use the int or float versions?

我们两清 提交于 2019-12-23 12:41:59
问题 Some of the Graphics2D methods, such as drawString , have versions that take coordinates as int or float . Are there any reasons to choose one over the other? Likewise, should I use the newer Shape classes, such as Rectangle2D (which use floating-point coordinates), or use Rectangle (which defines coordinates as int s)? 回答1: I see int and float - drawString(AttributedCharacterIterator iterator, float x, float y) Renders the text of the specified iterator, using the Graphics2D context's

Android L is not able to draw dotted line as drawable background

痴心易碎 提交于 2019-12-23 10:59:09
问题 Android L is not able to draw dotted line as drawable background as below: <?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="line" > <stroke android:dashGap="1dp" android:dashWidth="1dp" android:color="#999999" /> <size android:height="1dp" /> </shape> </item> </selector> I am also using layerType='software' in xml. Kindly help. 回答1: 1.The view must be at least 2dp in height (or wrap_content ), in order

Nesting ShapeRenderer.begin/end in SpriteBatch.begin/end

人走茶凉 提交于 2019-12-23 09:21:18
问题 Is it possible to draw shapes by using ShapeRenderer between SpriteBatch begin and end calls. I have tried but no result, only SpriteBatch textures are drawn, no shape is on the scene. Sample code is as followed below : shapeRenderer.begin(ShapeType.FilledCircle); shapeRenderer.setColor(0f, 1f, 0f, 1f); shapeRenderer.filledCircle( 100, 100, 100); shapeRenderer.end(); I have a orthographic camera created by these commands : camera = new OrthographicCamera(1, Gdx.graphics.getHeight() / Gdx

Check if an array of points is inside an array of rectangles?

六眼飞鱼酱① 提交于 2019-12-23 04:53:07
问题 I have a list of vertices and a list of regions (which are square/rectangle) shaped. Vertex has x and y coordinates, and a region has (x, y, height and width). How can I efficiently check which vertex lies in which region for every vertex/region? EDIT: This is the code I wrote to do this. if (!g.getVertices().isEmpty()) { for (int i = 0; i < g.getVertices().size(); i++) { Vertex v = g.getVertices().get(i); Point vertexPoint = new Point(v.getX(), v.getY()); for (int j = 0; j < g