rectangles

Draw rectangle based on data in matlab

我与影子孤独终老i 提交于 2019-12-13 06:58:51
问题 I have one row data as follows : 0 -> 2 DATA 1.000000 - 1.000100 SUCCESS 1.000100 - 1.000200 FAIL I want to plot data as below : I think I can use rectangle but it does not show time at x-axis? How to solve this? if SUCCESS it will fill blue color, otherwise red color 回答1: Well you should use the fill command instead of the rectangle command. See my code below to get you started. To tweak things to your liking just consult the help file in MatLab on the functions I am using. Good luck and

Can I decide the number of rectangles in a grid at runtime?

☆樱花仙子☆ 提交于 2019-12-13 04:59:43
问题 I'm basically having the same problem as this guy. The thing is, I want there to be a certain number of rectangles on the screen, depending on the screen size/resolution. Now the first comment on that question says "creating UI elements in procedural code in XAML-based technologies is discouraged, cumbersome, probably a bad idea, and just plain wrong". So is there another way in which I can achieve my goal? One way I can think of would be to have a minimum of 3x3 rectangles, but add UI code

Collision detection while using rectangles

五迷三道 提交于 2019-12-13 04:37:57
问题 So I understand that I'm not coding this the best way possible at the moment; this is a sort of test run. What I'm trying to do is wall collisions using rectangles and the intersects property (sorry if I'm not using the correct terminology). So far I have 2 rectangles on screen. 1 the player controls and the other which the play is colliding with. When they collide the player stops moving. The problem is that if the player is trying to move into the rectangle while they are already colliding

Matplotlib rectangleSelector - Set initial position

此生再无相见时 提交于 2019-12-12 20:46:06
问题 I am working on a project on which I want to select an area on an image in order to do some treatments on this area. So I found this wonderful tool RectangleSelector of matplotlib. But what I want is setting the rectangle at an initial position on the image, instead of waiting for the user clicking a first area (for example a rectangle of 10x10 pixels on top/left of the image). At first I thought I have to use state_modifier_keys but it doesn't seem to be this. So, is it possible ? An example

Drawing bunch of rotated rectangles on android canvas

我只是一个虾纸丫 提交于 2019-12-12 20:38:43
问题 I have a task to draw many rectangles on canvas, but all of them have a rotation angle by which they have to be rotated on canvas. Many of suggestions I ran into while searching for solution of this problem indicated the way to draw a rectangle and rotate the canvas (Canvas.rotate(angle)), but it rotates all canvas and is only possible with one rectangle. What could be the best way to draw many of rotated rectangles on canvas? I want to draw rectangles (single color, with Paint), but not

Rotating a rectangle (not image) in pygame

好久不见. 提交于 2019-12-12 11:07:16
问题 In pygame I use pygame.draw.rect(screen, color, rectangle) for all the rectangles in my program. I want to be able to rotate these rectangles to any angle. I have seen the following code to rotate IMAGES but my question is with RECTANGLES . pygame.transform.rotate(image, angle) But I am working with rectangles, I don't have an image or "surface" that I can rotate. When I try to rotate a rectangle with rect = pygame.draw.rect(screen, self.color, self.get_rectang()) rotatedRect = pygame

How to find the nearest point in the perimeter of a rectangle to a given point?

橙三吉。 提交于 2019-12-12 08:06:13
问题 This is a language-agnostic question. Given a rectangle's dimensions with l,t,w,h (left, top, width, height) and a point x,y , how do I find the nearest point on the perimeter of the rectangle to that point? I have tried to resolve it in Lua, but any other language would do. So far this is my best effort: local function nearest(x, a, b) if a <= x and x <= b then return x elseif math.abs(a - x) < math.abs(b - x) then return a else return b end end local function getNearestPointInPerimeter(l,t

Confused about rectangles in ruby

萝らか妹 提交于 2019-12-12 06:47:34
问题 This code takes the coordinates of two rectangles and finds their intersection. def rec_intersection(rect1, rect2) x_min = [rect1[0][0], rect2[0][1]].max x_max = [rect1[1][0], rect2[1][1]].min y_min = [rect1[0][0], rect2[0][1]].max y_max = [rect1[1][0], rect2[1][1]].min return nil if ((x_max < x_min) || (y_max < y_min)) return [[x_min, y_min], [x_max, y_max]] end rec_intersection([[1, 1], [2, 2]],[[0, 0], [5, 5]]) I don't really understand it. Specifically I would like to know more about

Unable to detect if a rectangle is touched in libgdx

岁酱吖の 提交于 2019-12-12 04:08:09
问题 I have a rectangle with a sprite on it and I have to detect if the touch position lies within the rectangle. This is my code, if (Gdx.input.isTouched()) { int x1 = Gdx.input.getX(); int y1 = Gdx.input.getY(); Vector3 inputs = new Vector3(x1, y1, 0); gamecam.unproject(inputs); Gdx.app.log("x" + inputs.x, "y" + inputs.y); Gdx.app.log("rect" + rectangle.x, "rect" + rectangle.y); if(rectangle.contains(inputs.x,inputs.y)) { Gdx.app.log("x" + inputs.x, "y" + inputs.y); Gdx.app.log("rect" +

Libgdx, how can I create a rectangle from coordinates?

◇◆丶佛笑我妖孽 提交于 2019-12-12 02:06:38
问题 I am currently trying to make a selector box for an RTS game. For this I need to be able to drag the mouse in order to create the selection box, however this can lead to a negative length/width. In Libgdx is there a way to make rectangle from just using 2 sets of coordinates? Thanks. 回答1: this is a simple idea, if I understand what you want to do: to create a rectangle you can use this, Rectangle(float x, float y, float width, float height) for more inforamacion you can read it here http:/