rectangles

Algorithm to split an image into smaller images reducing the amount of whitespace and specifying maximum amount of rectangles

萝らか妹 提交于 2019-11-30 15:00:22
I am looking for an algorithm which can split an image into smaller images, with some constraints. One constraint is to use the least amount of "whitespace" meaning empty pixels. And the other is to specify a maximum amount of images to split it into. For example lets look at the below image. There is a lot of "whitespace" in it. I would like to divide this images into a few other images so i can reduce the amount of memory this image occupies, and also to reduce the amount of "drawing" this image will take. .=transparent pixel x=colored pixel .................... .xxxxxxxxxxx........ ...xxxx.

Libgdx - How to draw filled rectangle in the right place in scene2d?

ε祈祈猫儿з 提交于 2019-11-30 14:49:00
问题 I am using scene2d. Here is my code: group.addActor(new Actor() { @Override public Actor hit(float arg0, float arg1) {return null;} @Override public void draw(SpriteBatch batch, float arg1) { batch.end(); shapeRenderer.begin(ShapeType.FilledRectangle); shapeRenderer.setColor(Color.RED); shapeRenderer.filledRect(0, 0, 300, 20); shapeRenderer.end(); batch.begin(); } }); The problem is that it draws this rectangular relative to screen (x = 0, y = 0), but I need it to be drawn relative to my

How to divide an area composed of small squares into bigger rectangles?

谁说胖子不能爱 提交于 2019-11-30 13:26:24
Where would i go to look for algorithms that take a 2d grid of values that are either 0 or 1 as input and then identifies all possible non-overlapping rectangles in it? In a more practical explanation: I am drawing a grid that is represented by a number of squares, and i wish to find a way to combine as many adjacent squares into rectangles as possible, in order to cut down on the time spent on cycling through each square and drawing it. Maximum efficiency is not needed, speed is more important. Addendum: Apparently what i am looking for seems to be a technique called Tesselation. Now i only

Oddly drawn GraphicsPath with Graphics.FillPath

烈酒焚心 提交于 2019-11-30 09:06:02
问题 I have written some code which creates a rounded rectangle GraphicsPath , based on a custom structure, BorderRadius (which allows me to define the top left, top right, bottom left and bottom right radius of the rectangle), and the initial Rectangle itself: public static GraphicsPath CreateRoundRectanglePath(BorderRadius radius, Rectangle rectangle) { GraphicsPath result = new GraphicsPath(); if (radius.TopLeft > 0) { result.AddArc(rectangle.X, rectangle.Y, radius.TopLeft, radius.TopLeft, 180,

How to arrange N rectangles to cover minimum area [duplicate]

无人久伴 提交于 2019-11-30 05:09:52
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Algorithm needed for packing rectangles in a fairly optimal way I have N rectangles, each of a random size (random width & height). All rectangles are parallel to the X & Y axes. I'm looking for an algorithm that helps me arrange these rectangles side-by-side in a way that the resulting bounding rectangle has minimum area and the potential gaps around / between the input rectangles are as small as possible.

Packing rectangles for compact representation

只愿长相守 提交于 2019-11-30 05:03:55
问题 I am looking for pointers to the solution of the following problem: I have a set of rectangles, whose height is known and x-positions also and I want to pack them in the more compact form. With a little drawing (where all rectangles are of the same width, but the width may vary in real life), i would like, instead of. -r1- -r2-- -r3-- -r4- -r5-- something like. -r1- -r3-- -r2-- -r4- -r5-- All hints will be appreciated. I am not necessarily looking for "the" best solution. 回答1: Your problem is

How to draw a rounded rectangle in c#

假装没事ソ 提交于 2019-11-30 03:20:20
I am using this code to make a rounded rectangle. But it only draws upper left and right corners of rectanlge , more it doest not complete the rectangle at lower part. How to make it complete and filled . What changes should I make ? public static Bitmap DrawRoundedRectangle(Bitmap Image, Color BoxColor, int XPosition, int YPosition, int Height, int Width, int CornerRadius) { Bitmap NewBitmap = new Bitmap(Image, Image.Width, Image.Height); using (Graphics NewGraphics = Graphics.FromImage(NewBitmap)) { using (Pen BoxPen = new Pen(BoxColor)) { using (GraphicsPath Path = new GraphicsPath()) {

Algorithm to split an image into smaller images reducing the amount of whitespace and specifying maximum amount of rectangles

霸气de小男生 提交于 2019-11-29 20:41:21
问题 I am looking for an algorithm which can split an image into smaller images, with some constraints. One constraint is to use the least amount of "whitespace" meaning empty pixels. And the other is to specify a maximum amount of images to split it into. For example lets look at the below image. There is a lot of "whitespace" in it. I would like to divide this images into a few other images so i can reduce the amount of memory this image occupies, and also to reduce the amount of "drawing" this

Oddly drawn GraphicsPath with Graphics.FillPath

我只是一个虾纸丫 提交于 2019-11-29 11:56:18
I have written some code which creates a rounded rectangle GraphicsPath , based on a custom structure, BorderRadius (which allows me to define the top left, top right, bottom left and bottom right radius of the rectangle), and the initial Rectangle itself: public static GraphicsPath CreateRoundRectanglePath(BorderRadius radius, Rectangle rectangle) { GraphicsPath result = new GraphicsPath(); if (radius.TopLeft > 0) { result.AddArc(rectangle.X, rectangle.Y, radius.TopLeft, radius.TopLeft, 180, 90); } else { result.AddLine(new System.Drawing.Point(rectangle.X, rectangle.Y), new System.Drawing

Is there a circle class in Java like the Rectangle class

偶尔善良 提交于 2019-11-29 09:17:59
Hey I was writing a quick program and something came across where I need to use a circle for collision detection. But as far as I know, there is only the Rectangle class that has the .intersects(Point p) method. Is there anything like a circle that I could use the same way? There is a class called Ellipse2D in the java.awt.geom package that you can use, since it has some methods that appears to be what you're looking for. An ellipse with a width equal to its height is a circle. One of the overloads for contains allows you to test for circle-point collisions: boolean contains(double x, double y