Questions tagged [rectangles]

A rectangle is a geometric shape: any quadrilateral with four right angles

1373 questions
-1
votes
1 answer

Unable to resize a Rectangle2D following the cursor

I'm trying to resize a Rectangle2D using the mouse dragging method. In addition I want to recenter it in the middle of the JPanel. I think the code and formulas are correct but it doesen't work properly because it resizes the rectangle excessively…
Shafa95
  • 201
  • 2
  • 14
-1
votes
1 answer

How does X and Y of the rectangle have to change for the center to stay in the same place?

I have a Rectangle rect = new Rectangle( (int)(someArray[z].rectangleObject.X + ((double)widthOfCell / 2) - ((double)targetWidth / 2)), (int)(someArray[z].rectangleObject.Y + (double)(heightOfCell / 2) - …
Vitalis Hommel
  • 990
  • 2
  • 8
  • 20
-1
votes
1 answer

multiple classes handlin - Pygame

Im creating a game which i use multiple files and the code below is the file which i have the sprites, 2 classes Player() which stands for a puddle, and a ball Ball() so i want to somehow(i dont know maybe inherit from player class but couldnt do…
Aris
  • 75
  • 6
-1
votes
1 answer

Google Map API Rectangle Class

I have a draggable rectangle on my map. If the user drags the rectangle into a square shape, I know both sides are equal. How can I determine the length of one side compared to the other? I can use getBounds and probably work something out with…
-1
votes
1 answer

How would I test collision for 2 images in Java.

I am currently making a Space Shooter in Java. I am able to make bullets shoot and enemies come from the top, but I am not sure how to check if they intersect. I understand that the Rectangle class has a intersects method, but I am not sure how I…
the fool
  • 19
  • 5
-1
votes
2 answers

How to cut picture from pictureBox by rectangle on it

I need to cut part of picture from pictureBox using rectangle which i have in this picturebox. For now i load image to picture box (and zoom it to picturebox) and draw resizable rectangle inside picturebox, but i don't know how to cut for example…
Skylin R
  • 2,111
  • 1
  • 20
  • 23
-1
votes
1 answer

Android: draw rectangle in AsyncTask of Service

How can a rectangle be drawn in AsyncTask of service? Is it possible? From Android canvas draw rectangle, it said drawView = new DrawView(this); drawView.setBackgroundColor(Color.WHITE); setContentView(drawView); However, setContentView…
WeiHung
  • 109
  • 2
  • 10
-1
votes
1 answer

Itext rectangle from milimeters

I try draw a A5 rentangle in a PDF with Itext using Rectangle class and Utilities.milimetersToPoints method but when i print the PDF and measure the rectangle the measurments is not the A5 dimensions. public static boolean createPDF(String pathPDF)…
Javetor
  • 25
  • 1
  • 4
-1
votes
6 answers

Load rectangle data from txt file with Python?

I have rectangle data associated with images in a txt file. Each row is for a diff image. First column is image number. 8 17 30 70 80 9 49 25 72 83 10 13 21 75 82 74 25 16 21 Each line is for rectangles represented by: img_number…
jsky
  • 2,225
  • 5
  • 38
  • 54
-1
votes
1 answer

How can I make the edges of a rectangle diamond shape?

Here is an image for reference. What I was able to do so far is make the edges in the rectangle round and now I want the edges to be diamond shape or somewhat close to the image. Code
Luis Averhoff
  • 385
  • 6
  • 22
-1
votes
1 answer

How to move a rectangle in chess game

I am programming Chess and wanted to know how I can change the spot of my rectangles. If you need any more informations let me know in the answers. I would be really happy if I could get any answers that could help me. Thanks.
-1
votes
1 answer

Confused about rectangles in ruby

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 =…
HolyMoly
  • 2,020
  • 3
  • 22
  • 35
-1
votes
2 answers

How do you make a value inside a for loop that isn't the i value incrementally decrease?

I am writing a program to identify which rectangles intersect eachother based on the rectangles and the corner coordinates that a user inputs. I am trying to create a for loop that checks for each rectangle, which rectangles (input by user)…
user3440080
  • 7
  • 1
  • 7
-1
votes
1 answer

How to inflate a rectangular shape given its vertices

I have 5 vertices of a Rectangle. I want to inflate the rectangle to a certain no. say x. How can I dot that? The rectangle is a custom struct not System.Drawing.Rectangle object. Please suggest.
WAQ
  • 2,556
  • 6
  • 45
  • 86
-1
votes
1 answer

Click and drag implementation on a rectangle VB.NET

So my problem is that I want to have multiple rectangles on a form at a time. However I also want these rectangles to be able to be clicked and dragged across the form. This is my current code for clicking and dragging a rectangle that was drawn…
Navtik
  • 5
  • 1
  • 5