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
11
votes
3 answers

How to approximate a vector contour from an elevation raster?

I have an elevation map stored as a raster. I'd like to fit a smooth "vector" curve to the contours of constant elevation. In my application, the data are actually geographic elevations, but the problem could be generalized to any function of two…
erickson
  • 265,237
  • 58
  • 395
  • 493
11
votes
1 answer

What is the best practice to render sprites in DirectX 11?

I am currently trying to get used to the DirectX API and I am wondering what is the usual approach to render a sprite in DirectX 11 (e.g. for a tetris clone). Is there a simmilar interface as ID3DX10Sprite, and if not, which would be the usual…
Mario Pistrich
  • 488
  • 2
  • 5
  • 16
11
votes
1 answer

How does Matrix.postScale( sx, sy, px, py) work?

First read Taig's question Taig said: When calling Matrix.postScale( sx, sy, px, py ); the matrix gets scaled and also translated (depending on the given point x, y). That predestines this method to be used for zooming into images because I …
Injury
  • 143
  • 1
  • 1
  • 10
11
votes
5 answers

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

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…
Mithaldu
  • 2,393
  • 19
  • 39
11
votes
2 answers

Function for rotating 2d objects?

Is it possible to write a function in python that could rotate any 2d structure with the arguments being only the coordinates (x,y) of the points in the structure? Additional arguments would be included for axis, speed and direction. To my…
11
votes
3 answers

Efficient 2D Tile based lighting system

What is the most efficient way to do lighting for a tile based engine in Java? Would it be putting a black background behind the tiles and changing the tiles' alpha? Or putting a black foreground and changing alpha of that? Or anything else? This…
Kyranstar
  • 1,650
  • 2
  • 14
  • 35
11
votes
0 answers

2D game engine for Eclipse

I worked on a few projects in Java and now, I want to get a step forward with game programming. I'm not looking for a 3d game engine like Unity, but for a simple 2d game engine for eclipse, that generates the basic codes for a game (like…
muffin
  • 1,456
  • 4
  • 21
  • 44
10
votes
3 answers

Source code for Javascript tree that features in "Inventing on Principle" video

I was quite inspired by Bret Victor's Inventing on Principle video (http://vimeo.com/36579366). Also, I was very fascinated by that tree drawn using Javascript. I have not done much of graphics programming. All my career I have been a middle-tier…
greppz
  • 167
  • 10
10
votes
4 answers

how to generate circle using javascript

How can i create a Circle in Html using javascript. Does it can be done using Javascript or not? I have done creating rectangles and squares but don't know how to accomplish a circle.
user1199059
10
votes
1 answer

OpenGL stretched shapes - aspect ratio

I got my openGL view at a size of (lets say..) 800(width)x600(height). Then i got a 2D object of coords: 0.0 , 0.0 0.1 , 0.0 0.1 , 0.1 0.0 , 0.1 this, as you understand is supposed to be a square (based on analogy). But on my openGL view prints…
apoiat
  • 576
  • 2
  • 5
  • 16
10
votes
2 answers

Creating 3D volume from 2D slice set of grayscale images

I am to create a 3D volume out of grayscale image set using Matlab. A set contains a continuous and quantized slices of 2D grayscale image. I am still considered myself a rookie in Matlab, but this is what I currently have in my mind: create an…
Karl
  • 5,613
  • 13
  • 73
  • 107
10
votes
4 answers

Programmatically Reducing JPEG file size

Apologies for any ignorance, but I have never worked with jpeg images (let alone any types of images) in Java before. Supposing I want to send a jpeg image from a web service to a client. Is there any way that I can reduce the jpeg file size by…
Joeblackdev
  • 7,217
  • 24
  • 69
  • 106
10
votes
10 answers

How to work around a very large 2d array in C++

I need to create a 2D int array of size 800x800. But doing so creates a stack overflow (ha ha). I'm new to C++, so should I do something like a vector of vectors? And just encapsulate the 2d array into a class? Specifically, this array is my…
Bryan Denny
  • 27,363
  • 32
  • 109
  • 125
10
votes
2 answers

Placing 2D shapes in a rectangle efficiently. How to approach it?

I've been searching far and wide on the seven internets, and have come to no avail. The closest to what I need seems to be The cutting stock problem, only in 2D (which is disappointing since Wikipedia doesn't provide any directions on how to solve…
LWolf
  • 188
  • 1
  • 2
  • 7
10
votes
9 answers

How to draw a Perspective-Correct Grid in 2D

I have an application that defines a real world rectangle on top of an image/photograph, of course in 2D it may not be a rectangle because you are looking at it from an angle. The problem is, say that the rectangle needs to have grid lines drawn on…
Neil N
  • 24,862
  • 16
  • 85
  • 145