Questions tagged [2d]

2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models.

Flat perspective, having no three-dimensional geometry. Including two-dimensional space and 2D geometric models, or two-dimensional images having only height, and width with no depth.

7489 questions
10
votes
1 answer

Understanding Android's Canvas.saveLayer(...)

I am hoping the saveLayer methods will allow me to do draw onto different "layers" and then once the drawing has finished, merge the layers with the canvas in whichever order i choose. The obvious question is "why dont you just rearrange your…
Nick
  • 8,181
  • 4
  • 38
  • 63
10
votes
1 answer

Does anyone know of any good tutorials for the Slick 2D lib?

There is a 2D java graphics library called Slick 2D (http://slick.cokeandcode.com/) that seems to be used by a bunch of indie games (mostly applets), but the documentation is a little lacking. Does anyone know of any good tutorials for this lib?
Flynn81
  • 4,108
  • 29
  • 28
10
votes
1 answer

Area covered by a point cloud with R

I have a cloud of points scattered in a 2D Euclidean space. I would like to calculate the area inside the polygon linking the most extreme (=peripheral) points of the cloud. In other words, I would like to estimate the area covered by the cloud in…
Julien R
  • 101
  • 1
  • 3
10
votes
5 answers

operator overloading [][] 2d array c++

I have a 2D array and I want to define a function that returns the value of the index that the user gives me using operator overloading. In other words: void MyMatrix::ReturnValue() { int row = 0, col = 0; cout << "Return Value From the last…
LIMA
  • 125
  • 1
  • 1
  • 8
10
votes
1 answer

How can I find the minimal circle include some given points?

I have given some points (2D-coordinates) and want to find the smallest circle, that includes all of this points. The algorithm doesn't have to be very efficient (while it would be nice naturally).
Mnementh
  • 50,487
  • 48
  • 148
  • 202
10
votes
10 answers

Finding closest non-black pixel in an image fast

I have a 2D image randomly and sparsely scattered with pixels. given a point on the image, I need to find the distance to the closest pixel that is not in the background color (black). What is the fastest way to do this? The only method I could…
shoosh
  • 76,898
  • 55
  • 205
  • 325
10
votes
4 answers

High-End 2D Java (SE) Graphics Library

I am looking for a high-end graphics library for Java Standard Edition. I know some fairly low-level libraries: AWT/Swing, JOGL, SDL. Are/is there an alternative? My requirements are (atleast): Anti-aliased Fullscreen support Alpha channel Blend…
Pindatjuh
  • 10,550
  • 1
  • 41
  • 68
10
votes
1 answer

How can I force QGraphicsView/QGraphicsScene to shrink back to minimal size

I use QGraphicsView/QGraphicsScene for plotting in Qt. Scale and fit work decently as long as i keep plotting bigger things. However, when the boundign rectangle size reduces the View does not. It just shows the same (or a bigger area). Before I…
Martin
  • 4,738
  • 4
  • 28
  • 57
10
votes
3 answers

A divide-and-conquer algorithm for counting dominating points?

Let's say that a point at coordinate (x1,y1) dominates another point (x2,y2) if x1 ≤ x2 and y1 ≤ y2; I have a set of points (x1,y1) , ....(xn,yn) and I want to find the total number of dominating pairs. I can do this using brute force by comparing…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
10
votes
1 answer

Move an object in the direction its facing using 2d html5Canvas and ctx.rotate function

The title kind of says it all, I am trying to move an object forward depending on the angle it is at. Here is my relevant code: xView = this.x-this.width/2; yView = this.y-this.height/2; playerCtx.drawImage(imgSprite, 0, 0, this.width,…
user2582299
  • 305
  • 2
  • 6
  • 15
10
votes
3 answers

Calculate a bezier spline to get from point to point

I have 2 points in X,Y + Rotation and I need to calculate a bezier spline (a collection of quadratic beziers) that connects these 2 points smoothly. (see pic) The point represents a unit in a game which can only rotate slowly. So to get from point…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
10
votes
3 answers

How to get 2D subarray from 2D array in JAVA?

Suppose I have 2D array as follow: int[][] temp={ {1,2,3,4}, {5,6,7,8}, {9,10,11,12}}; and i want to get sub-array start from X direction 1 to 2 and Y direction 1 to 2 i.e. {6,7} {10,11} can anyone give…
Somnath Kadam
  • 6,051
  • 6
  • 21
  • 37
10
votes
3 answers

2d Sprite Animations without using XNA or other third-party libraries

I want to create a simple game, similar to what can be created with RPG Maker. What I am primarily looking for at the moment is a tutorial which can guide me on how to accomplish it without using XNA or any other specific library. The ideal would be…
WiiMaxx
  • 5,322
  • 8
  • 51
  • 89
10
votes
2 answers

Win32 clipboard and alpha channel images

My application should be able to copy 32-bit images (RGB + alpha channel) to the clipboard and paste these images from the clipboard. For this I plan to use CF_DIBV5 because the BITMAPV5HEADER structure has a field bV5AlphaMask. The problem is that…
Andreas
  • 9,245
  • 9
  • 49
  • 97
10
votes
2 answers

Fill rectangle with pattern in Java Swing

I know how to fill a rectangle in Swing with a solid color: Graphics2D g2d = bi.createGraphics(); g2d.setColor(Color.RED); g2d.fillRect(0,0,100,100); I know how to fill it with an image: BufferedImage bi; Graphics2D g2d =…
Edward Ruchevits
  • 6,411
  • 12
  • 51
  • 86