Questions tagged [rectangles]

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

1277 questions
-3
votes
1 answer

JavaFX does not render properly, but my basic code is probably wrong

I was coding a simple shape-collision-detector, but I noticed the rectangle which I move using the mouse vanishes in some window's areas. I can't figure out why. Here you can see the video and below the code I used. Any advice? Rectangle r = new…
-3
votes
3 answers

Drawing box around message

I'm working on this Python task that I can't figure out. It is the last of 3 functions and the first 2 were much easier to program then this one. The instructions are "Given a message that may contain multiple lines, utilize the split() function to…
famguy74
  • 27
  • 2
  • 10
-3
votes
1 answer

make Ball bounce off object edges in C

I am trying to make a ball bounce off the edges of a rectangular shaped paddle, what I have done so far, is making the ball bounce off the top edge of the paddle. But whenever the ball touches any other side (right or left), it gets stuck within the…
Yamen Tawk
  • 67
  • 2
  • 10
-3
votes
1 answer

How to fix method error

I just want to make sure I'm correct here. I am trying to add methods to Change height Change width Change coordinates Calculate perimeter Calculate area public class MyRectangle { public int width; public int height; public int y; public int…
Sunny Dhillon
  • 61
  • 1
  • 1
  • 8
-3
votes
1 answer

Inheritance of Square method in java

I have a class Rectangle laid out like this: package Inheritance; /** * * @author Jacob */ public class Rectangle { final private int length; final private int width; public Rectangle (int l, int w) { length = l; width = w; } public…
user3440443
  • 13
  • 1
  • 7
-3
votes
1 answer

How to make a Java Rectangle move at an angle

I'm a new game developer and I have always wondered about how would I go about making a 'Rectangle' object move at a certain angle? I thought I could make the x increase rapidly and the y increase at a delay, but how would I do that?
-3
votes
2 answers

CHANGE the size of a rectangle?

I need to change the size of a rectangle when something happens. This is C# if (face1.Y > 440) { rndLocation(); //rectangle size changes }
user3103552
  • 1
  • 2
  • 4
-3
votes
1 answer

Find the boundary of a polygon (or a staircase) c++

I'm doing an 2D bin packing algorithm. The goal is to put a set of rectangle into a bin one by one. At each rectangle insertion, i want to update the boundary between occupied area and free area. Thus, i'm looking for an algorithm or the way to do…
Bryan
  • 31
  • 6
-3
votes
2 answers

Java 2D game, Both of my rectangles are moving when only one should move

I have coded a simple Java game where there are two rectangles on the screen, one of the rectangles should move and the other should stays still, the moving Rectangle moves with keyboard arrow input and can move either up, down, left or right. The…
Rahul Khosla
  • 349
  • 8
  • 21
-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…
-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
  • 4
-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
  • 388
  • 1
  • 6
  • 18
-4
votes
2 answers

Given four Corner vertices of a rectangle, how to identify all upper and lower (left & right) corner points?

Four Corner Vertices of a deformed rectangle are given i.e. p1(x1,y1), p2(x2,y2), p3(x3,y3) & p4(x4,y4). How to find position of all co-ordinates i.e. which one is upper left, upper right, lower right and lower left? I am working with MATLAB.…
erbal
  • 411
  • 5
  • 15
-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,014
  • 1
  • 17
  • 27
-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…
1 2 3
85
86