2d

Drawing a grid of images with WPF

℡╲_俬逩灬. 提交于 2019-12-22 04:45:15
问题 I'm trying to draw a grid of images/icons with WPF. The grid dimensions will vary but will typically range from 10x10 to 200x200. The user should be able to click on cells, and some cells will need to update (change image) 10-20 times per second. The grid should be able to grow and shrink in all four directions, and it should be able to switch to a different "slice" of the 3D structure it represents. My goal is to find a suitably efficient method for drawing the grid given those requirements.

How to calculate end points of perpendicular line segments?

一笑奈何 提交于 2019-12-22 03:24:38
问题 I know the end points of a line segment and the distance/size of the perpendicular end caps I'd like to create but I need to calcuate the end points of the perpendicular line. I've been banging my head against the wall using either 45-45-90 triangles and dot products but I just can't seem to make it come together. I know the points in blue and the distance to the points in red, I need to find the points in red. Before marking as duplicate, I tried the answer posted in this question but it

Distortion with 'pixel accurate' OpenGL rendering of sprites

谁说我不能喝 提交于 2019-12-22 01:14:55
问题 To define what I'm trying to do: I want to be able to take an arbitrary 'sprite' image from a ^2x^2 sized PNG, and display just the pixels of interest to a given x/y position on screen. My results are the problem - major distortion - it looks awful! (Note these SS's are in iPhone sim but on real retina device they appear the same.. junky). Here is a screenshot of the source PNG in 'preview' - which looks wonderful (any variations on rendering that I describe in this question look almost

Offscreen Rendering in OpenGL or Directx

风格不统一 提交于 2019-12-21 23:32:10
问题 I want to be able to render complex 2D and 3D images using hardware acceleration on a server with no user context or logged in user. The best thing I could do so far is Mesa3D, but because it is pure software 3D rendering it is slow and does not take advantage of the video hardware acceleration. Could be Windows or Linux. Most of my work I have done so far in Windows. Any suggestions on how to do this with OpenGL or DirectX? 回答1: For Linux, EGL + MESA_platform_gbm should let you get a

How to approach Java 2D performance variations between different computers?

核能气质少年 提交于 2019-12-21 12:42:36
问题 I've been designing a card game in Java on Windows. It runs really well on my laptop and a few others, but on a lot of other systems (even a few newer ones both Mac and Windows) the animation is incredibly slow. I've found User Interface Toolkits for Java to be the best resource so far, but haven't been able to make a significant improvement. I'm using the AWT/Swing libraries. Question: Looking at my game, (<1.5Mb), how could it be that on some computers (of similar spec) the performance

2d balls not colliding properly

守給你的承諾、 提交于 2019-12-21 11:29:13
问题 I'm just trying to code a nice looking physics game. The ball collision looks nice but if the balls are colliding too slow, they "stick" in each other. I have no clue why they do. Here's my collision function: private void checkForCollision(ArrayList<Ball> balls) { for (int i = 0; i < balls.size(); i++) { Ball ball = balls.get(i); if (ball != this && ball.intersects(this)) { this.collide(ball, false); } } } public boolean intersects(Ball b) { double dx = Math.abs(b.posX - posX); double dy =

how to traverse though a 2d char array searching for words in java?

喜你入骨 提交于 2019-12-21 06:24:24
问题 I am having trouble with a school assignment and would really appreciate some insight. I am asked to create a wordsearch using a 25x25 2d char array and somehow go through that array by developing an algorithm that will search through it to find 21 pre-defined words. So far I have been able to create a ragged array of the words that I need to find and the 2d array with the chars placed in each position. in = new ASCIIDataFile("wordsearch.txt"); display = new ASCIIDisplayer(); int numberWords

Collision detection with bitmaps on SurfaceView's canvas in Android

∥☆過路亽.° 提交于 2019-12-21 06:19:10
问题 In Android I use a SurfaceView to display a simple 2D game. The bitmaps (.png) with alpha (representing the game objects) are drawn on the canvas. Now I would like to do a simple but accurate collision detection. Checking whether these bitmaps are overlapping is quite easy. But how do I check for collisions when these bitmaps have transparent areas? My challenge is detecting whether two balls collide or not. They fill up the whole bitmap in width and height both but in all four edges, there

Drawing aliased, pixel-perfect 1px splines (Catmull-Rom, specifically)

徘徊边缘 提交于 2019-12-21 04:36:06
问题 A brief background: I'm working on a web-based drawing application and need to draw 1px thick splines that pass through their control points. The issue I'm struggling with is that I need to draw each of the pixels between p1 and p2 as if I were using a 1px pencil tool. So, no anti-aliasing and one pixel at a time. This needs to be done manually without the use of any line/curve library code as my brush system depends upon having a pixel coordinate to apply the brush tip to the canvas.

What's a good, simple, 2D rectangles-only collision detection algorithm?

允我心安 提交于 2019-12-21 03:34:25
问题 I'm designing a collision detection game tutorial for young adults, so I want this to be as simple as possible to make it easier to explain. The requirements are very simple. The world is 2D and contains only rectangles (of arbitrary sizes). BSP and even quadtrees seems like it would be overkill (again, the emphasis is on simplicity) but I would like something more efficient than brute forcing through all n(n-1)/2 possible collisions. 2D, rectangles only, and simple. Can anyone point to an