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
32
votes
6 answers

How do i tint an image with HTML5 Canvas?

My question is, what is the best way to tint an image that is drawn using the drawImage method. The target useage for this is advanced 2d particle-effects (game development) where particles change colors over time etc. I am not asking how to tint…
djdolber
  • 3,966
  • 2
  • 18
  • 9
32
votes
4 answers

HTML5 2d Hex Board Game (tabletop) Engine

I'm looking for a very simple HTML5 2D Hex / Touch game engine framework to build board game like: Turn based 2D Hex Grid Wargame Dungeon Crawler Settlers of Catan Krosmaster I found an awesome article on Hexagon grids with a D3.js implementation…
Jean-Philippe Encausse
  • 1,491
  • 2
  • 22
  • 40
32
votes
8 answers

How to convert a Numpy 2D array with object dtype to a regular 2D array of floats

As part of broader program I am working on, I ended up with object arrays with strings, 3D coordinates and etc all mixed. I know object arrays might not be very favorite in comparison to structured arrays but I am hoping to get around this without…
Moe
  • 991
  • 2
  • 10
  • 24
31
votes
6 answers

Simple physics-based movement

I'm working on a 2D game where I'm trying to accelerate an object to a top speed using some basic physics code. Here's the pseudocode for it: const float acceleration = 0.02f; const float friction = 0.8f; // value is always 0.0..1.0 …
Radek
  • 355
  • 1
  • 4
  • 8
31
votes
2 answers

2D tile map generation

For a 2D tile engine I'm working on map generation algorithms. I tried heightmap generation : hill generation Perlin noise Diamond-square Suitable for tile maps that have a height component but I have sprites like grass, sea, desert and they…
Jack
  • 131,802
  • 30
  • 241
  • 343
30
votes
5 answers

Baking transforms into SVG Path Element commands

tl;dr summary: Give me the resources or help fix the below code to transform path commands for SVG elements by an arbitrary matrix. details: I'm writing a library to convert any arbitrary SVG shape into a element. I have it working…
Phrogz
  • 296,393
  • 112
  • 651
  • 745
29
votes
2 answers

Android: 2D. OpenGl or android.graphics?

I'm working with my friend on our first Android game. Basic idea is that every frame of the game the whole surface is redrawn (1 large bitmap) in 2 steps: Background with some static image (PNG) wipes out previous frame Then it is sprinkled all…
Bostone
  • 36,858
  • 39
  • 167
  • 227
28
votes
5 answers

Draw a 2D Image using OpenGL ES 2.0

I've been struggling to draw a 2D image from jpg/png files using openGL ES 2.0 for Android. Everywhere I look the tutorials are for texturing 3D images so its been rough figuring out how to draw a regular 2D Sprite. I got a square to draw and…
Strifex
  • 832
  • 1
  • 7
  • 16
26
votes
9 answers

Most performant way to graph thousands of data points with WPF?

I have written a chart that displays financial data. Performance was good while I was drawing less than 10.000 points displayed as a connected line using PathGeometry together with PathFigure and LineSegments. But now I need to display up to 100.000…
user65199
26
votes
4 answers

Android - How to draw an arc based gradient

I am trying to create an arc (variable number of degrees) that gradually goes from one color to another. From example from blue to red: This is my code: SweepGradient shader = new SweepGradient(center.x, center.y,…
Yoav
  • 2,077
  • 6
  • 27
  • 48
26
votes
5 answers

Algorithm for finding nearest object on 2D grid

Say you have a 2D grid with each spot on the grid having x number of objects (with x >=0). I am having trouble thinking of a clean algorithm so that when a user specifies a coordinate, the algorithm finds the closest coordinate (including the one…
random
  • 353
  • 1
  • 3
  • 5
26
votes
11 answers

2d game : fire at a moving target by predicting intersection of projectile and unit

Okay, this all takes place in a nice and simple 2D world... :) Suppose I have a static object A at position Apos, and a linearly moving object B at Bpos with bVelocity, and an ammo round with velocity Avelocity... How would I find out the angle that…
Led
  • 2,002
  • 4
  • 23
  • 31
25
votes
1 answer

html5 canvas strokeStyle?

I am trying to map an image to a "3d" grid that simulates cloth using strokeStyle and canvas, i have the image included but it is currently acting as a background image and not actually flowing with the "cloth" as is ripples, I.E the image is static…
vimes1984
  • 1,684
  • 3
  • 26
  • 59
24
votes
3 answers

Sending and receiving 2D array over MPI

The issue I am trying to resolve is the following: The C++ serial code I have computes across a large 2D matrix. To optimize this process, I wish to split this large 2D matrix and run on 4 nodes (say) using MPI. The only communication that occurs…
Ashmohan
  • 491
  • 1
  • 11
  • 22
23
votes
2 answers

Graphic Libraries for 2D (No XNA please)

Since Microsoft are dropping XNA (and yes, I know that one can still use it quite successfully, but the fact it's not being developed after only a short period of existence speaks volumes). What are the best C# graphic libraries for simple 2D…
Leo
  • 467
  • 1
  • 4
  • 12