rectangle

How to perform a rectangular hit test in PHP

Hi, I have WYSIWYG style javascript interface that allows a designer to create rectangular regions to generate a document server side. It is important that these regions do not overlap. I was wondering what is the single most efficent way to perform a hit test on 2 rectangular regions, there could potentially be hundreds, so efficenc...

How do I scale one rectangle to the maximum size possible within another rectangle?

I have a source rectangle and a destination rectangle. I need to find the maximum scale to which the source can be scaled while fitting within the destination rectangle and maintaining its original aspect ratio. Google found one way to do it but I'm not sure if it works in all cases. Here is my home-brewed solution: Calculate Height/W...

Which version of OpenGL supports rectangular textures (w/o extensions)?

Rectangular textures used to be support through extensions and at some version of OpenGL are now directly supported, i.e I can create textures with the same basic opengl methods just supplying non-power-of-two sizes. I've googled and can't seem to find a definitive changelog for the OpenGL spec. I need this information to dynamically de...

Rectangles & Parsing in vb.net

This is kinda....a two part question. The first one is much more important than the second one, both of these are in the same project, and in vb.net. How can I constrain the bounds of a rectangle object, which is controlled by a mouse, so it cannot be drawn outside a PictureBox? It is kindof a standard lasso control, the user can click ...

why there is no Center() method for Rectangle class in c#?

previously, there is such method for Rectangle in MFC, i dont know why there is not for the c# version. ...

iPhone button with non-rectangle shape?

How can I get a non-rectangular shaped button? For example I do have a PNG image with alpha transparency. How can I set the shape of a button to this image without the transparent color. ...

How to find the intersection point between a line and a rectangle?

I have a line that goes from points A to B; I have (x,y) of both points. I also have a rectangle that's centered at B and the width and height of the rectangle. I need to find the point in the line that intersects the rectangle. Is there a formula that gives me the (x,y) of that point? PS: I'm working with C# but a solution in a simila...

how to differentiate between circle rectangle and triangle ?

sorry but i need help how to differentiate between circle rectangle and triangle in black and white images-bitmaps- ...

WPF rectangle - round just top corners

How can I have just the top corners rounded for a WPF rectange? I created a border and set the CornerRadius property and inside the border I've added my rectangle, but it doesn't work, the rectangle is not rounded. <Border BorderThickness="1" Grid.Row="0" Grid.ColumnSpan="2" CornerRadius="50,50,0,0" BorderBrush="Black"> <Rectangle Fill...

Optimal way for partitioning a cell based shape into a minimal amount of rectangles

Assume a boolean array like: 1111 1111 1110 1111 1001 Now you need to find the way of arranging the least rectangles of any size to achieve this shape. So, for example, you'd find this: +-++ | |+ | | +-++ + + Where + is a corner of a rectangle and |, - borders of a rectangle. What I thought about doing is starting with the larges...

How can I know if two rectangles collide in Silverlight 3?

I have program where you cannot place rectangles over each others, so how can I check if rectangles collide? Is there some kind of function for this or do I have to make my own? ...

Checking for intersection points between two rectangles?

If I have two rectangles whose positions are deifned using two 2D vectors (i.e. top left, bottom right) how can I check for the points they are intersecting? ...

How to load a specific patch/rectangle from an image?

We have an application that show a large image file (satellite image) from local network resource. To speed up the image rendering, we divide the image to smaller patches (e.g. 6x6 cm) and the app tiles them appropriately. But each time the satellite image updated, the dividing pre-process should be done, which is a time consuming work. ...

The ol' fitting squares into a rectangle trick

Yes I did see the questions similar to this already posted here (notably this one). But. Am i crazy, or can the size of the square also be a non-integer? For example, in a 2x3 rectangle, one solution is squares that are .2x.2 How can i create a function to find the number of possible square sizes? ...

Capturing the mouse

I have a List<Rectangle> myRectangles that are rendered in a Panel control. If I want to fire an event handler when the mouse is within any of myRectangles, is my best option to do 'foreach'? And then go do whatever myRectangle.OnMouseMove() would do? ...

Test if point is in some rectangle

I have a large collection of rectangles, all of the same size. I am generating random points that should not fall in these rectangles, so what I wish to do is test if the generated point lies in one of the rectangles, and if it does, generate a new point. Using R-trees seem to work, but they are really meant for rectangles and not point...

How to fill a square with smaller squares/rectangles?

This is not a homework or interview question. In my office at work, we are not allowed to paint the walls, so I have decided to frame out squares and rectangles, attach some nice fabric to them, and arrange them on the wall. I am trying to write a method which will take my input dimensions (9' x 8' 8") and min/max size (1' x 3', 2', 4',...

Laying out overlapping rectangles

I am trying to layout a bunch of overlapping rectangles that start out like this: The 2-pass algorithm I thought up is roughly: // Pass 1 - Move all rectangles to the right until they do not overlap any other rectangles rects = getRectsSortedOnTopLeft(); // topmost first, all rects same size foreach(rect in rects) { while(rect.col...

Button inside swing Rectangle2D.double

Hi Gurus, We have a swing application which displays a lot of rectangles. We use Rectangle2D.double class to draw the rectangles on a JPanel. My requirement is this. Upon clicking the rectangle, I have to pick an image from the local filesystem and show it in a popup window or a frame. My question is how can I provide a hyperlink or butt...

My drawRoundRect is not drawing a rounded rectangle :( [Flash]

Hi everyone, I just wrote a Background class for a new project. The background is basically going to be 2 rounded rectangles with a simple stroke and fill color laid on top of each other. Anyways right now I'm just trying to draw out 1 rounded rectangle, but for some reason I don't see it anywhere on stage :( No errors and my traces tra...