A rectangle is a geometric shape: any quadrilateral with four right angles
Questions tagged [rectangles]
1373 questions
-4
votes
1 answer
Algorithm to divide black and white chocolate bar with least number of breaks
I have a rectangular chocolate bar that consists of squares either black, white or mixed. The bar being not bigger than 50x50 squares. I'm supposed to divide the bar between two people(one gets all the white squares and one the black ones, mixed…

Petr Kroupa
- 53
- 3
- 8
-4
votes
1 answer
Why does add(int newx, int newy) method of the Rectangle class modify the height and width arguments?
import java.awt.Rectangle;
public class AddTester {
public static void main(String[] args) {
Rectangle box = new Rectangle(5, 10, 20, 30);
System.out.println(box);
//output: java.awt.Rectangle[x=5,y=10,width=20,height=30]
…

Dorkymon
- 9
- 5
-4
votes
1 answer
Drawing Rectangles in Java
I am trying to draw rectangles in Java like this picture:
I visualize the coordinates as I do at math but I come up with the rectangles turned upside down which is like this:
I know Im missing just a few things.What should I do?
(Colors will be…

SametSahin
- 571
- 3
- 7
- 24
-4
votes
1 answer
Find mid-point between two rectangles, intersection + edge aware
As seen in the image, I would like to find the mid-point between two rectangles. If the rectangles are intersecting then the mid-point would simply be between the centers of the rectangles. But if the rectangles are not intersecting, then the…

StackUnderflow
- 2,403
- 2
- 21
- 28
-4
votes
1 answer
Creating a Rectangle object and finding area
How can I create a Rectangle object and use its methods to determine the area?
I have tried to create a Rectangle object and print it to console like this:
import java.awt.Rectangle;
public class Rectangle
{
public static void main(String…

Java_NewBie
- 93
- 1
- 10
-5
votes
1 answer
Getting the best rectangle
I have a rectangle, and a list of other rectangles.
I want to get the rectangle from the list, that has the best width, height, and aspect ratio according to my rectangle.
Example
After I run my code, the best rectangle should be rectangle 3.
Note…

Boldijar Paul
- 5,405
- 9
- 46
- 94
-6
votes
1 answer
Drawing a rectangle with a certain angle of degree
I'm using Windows visual studio 2015 winforms to draw rectangles on a panel.
I get my information from a list of objects(bricks). I just check the rotation for each brick:
My brick holds the following information:
string ID;
PointF…

Bart
- 717
- 1
- 9
- 28