2d

OpenGL GLSL Binding Sampler for Fragment Shader

こ雲淡風輕ζ 提交于 2019-12-04 05:28:54
问题 I am hoping to implement a shader on a 2D OpenGL application. My plan is to render a scene to a framebuffer object, and then render that framebuffer object to the screen using a shader. Here is the scene, which I have drawn to a framebuffer object, and then to the screen from there. Using the arrow keys makes the moon move around (I am quite proud of it!) However, when I try to render the framebuffer object to the screen using my shader program, I get this: It is very sad. This fragment

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

爷,独闯天下 提交于 2019-12-04 05:14:32
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 seems to be significantly less that what it is on my laptop? The entire app is event-driven and I've done

How to load Pdf file on Canvas as a image.src?

强颜欢笑 提交于 2019-12-04 04:21:20
问题 I am able to load image on canvas but now I want to replace the Image with pdf file. How to load Pdf file on Canvas as a image.src? 回答1: You can achieve this with pdf.js https://github.com/mozilla/pdf.js/ Take a look at this article http://www.codediesel.com/javascript/rendering-pdf-in-html5-canvas/ 来源: https://stackoverflow.com/questions/17489261/how-to-load-pdf-file-on-canvas-as-a-image-src

Java: Rotate Point around another by specified degree value

守給你的承諾、 提交于 2019-12-04 04:14:33
问题 I am trying to rotate a 2D Point in java around another with a specified degree value, in this case simply around Point (0, 0) at 90 degrees. Method: public void rotateAround(Point center, double angle) { x = center.x + (Math.cos(Math.toRadians(angle)) * (x - center.x) - Math.sin(Math.toRadians(angle)) * (y - center.y)); y = center.y + (Math.sin(Math.toRadians(angle)) * (x - center.x) + Math.cos(Math.toRadians(angle)) * (y - center.y)); } Expected for (3, 0): X = 0, Y = -3 Returned for (3, 0)

2D collision between a moving circle and a fixed line segment

本秂侑毒 提交于 2019-12-04 03:56:11
In the context of a game program, I have a moving circle and a fixed line segment. The segment can have an arbitrary size and orientation. I know the radius of the circle: r I know the coordinates of the circle before the move: (xC1, yC1) I know the coordinates of the circle after the move: (xC2, yC2) I know the coordinates of the extremities of the line segment: (xL1, yL1) - (xL2, yL2) I am having difficulties trying to compute: A boolean : If any part of the circle hits the line segment while moving from (xC1, yC1) to (xC2, yC2) If the boolean is true, the coordinates (x, y) of the center of

2D Elastic Ball Collision Physics

依然范特西╮ 提交于 2019-12-04 03:28:48
I am making a program that involves elastic ball physics. I have worked out all of the maths for collision against walls and stationary objects, but I cannot figure out what happens when two moving balls collide. I have mass and velocity (x and y velocity to be exact, but velocity of each ball and their direction will do) and would like the formulae for those. Remember - this is a perfectly elastic collision - so no spinning balls, etc. This wikipedia article provides a formula to compute velocities after collision between two particles : There are many reasons to use this formula : you just

How to change value of array element in 2D arrays?

£可爱£侵袭症+ 提交于 2019-12-04 02:56:08
问题 Let's say I got this map that prints out: 00000 00000 00000 How do I change the element in [0][0] into an X? In other words, how to make it look like this using Screen input: X0000 00000 00000 回答1: Considering Its an 2D Array of String Type... arr[0][0] = "X"; 回答2: Run this: import java.util.*; import java.lang.*; class Main { public static void main (String[] args) throws java.lang.Exception { String[][] array = {{"0","0","0"},{"0","0","0"},{"0","0","0"}}; System.out.println("Before: ");

Programmatically Reducing JPEG file size

社会主义新天地 提交于 2019-12-04 00:57:43
问题 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 manipulating the colour profile of the image in some way? I have already been able to reduce the image size by scaling it using a neat tool for BufferedImages called imgscalr . See here. I would also like a jpeg that has less colours than a high

Animation with animationSet() in android

ぐ巨炮叔叔 提交于 2019-12-04 00:08:04
问题 OK here's the problem i have an ImageView in my activity, here's what it looks in main.xml: <ImageView android:id="@+id/ic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_gravity="center_horizontal"/> I want this image to move -200(left) and then to 100(right) and then back to 0 with bouncing effect. I've implement this with my code: as = new AnimationSet(true); as.setFillEnabled(true); as.setInterpolator(new

Corner Stitching Datastructure, Any Open Source Implementations? [closed]

北战南征 提交于 2019-12-03 22:21:37
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I recall learning about the corner-stitched data structure a number of years ago and have been fascinated with it ever since. It originated with a paper by Ousterhout . I've searched and not been able to find a free/open implementations. I'd prefer a C++ implementation, but at this point would accept any pointers people might have. Note: a corner-stitched data structure is a way to store 2