graphics

Which Haskell library for computer graphics geometry?

ε祈祈猫儿з 提交于 2020-01-01 04:35:06
问题 I would like to do some experiments in computer graphics in Haskell. This will include doing some geometry calculations and ultimately writing a ray tracer. Which library should I pick for easy handling of vectors, matrices and relevant operations on them? There are few on Hackage including nice looking ones like vect and AC-Vector, but it's easy to miss a good candidate among so many different libraries. 回答1: For vectors and matrices that are used for transformations, vect probably is your

Need a way to scale a font to fit a rectangle

社会主义新天地 提交于 2020-01-01 04:18:09
问题 I just wrote some code to scale a font to fit within (the length of) a rectangle. It starts at 18 width and iterates down until it fits. This seems horribly inefficient, but I can't find a non-looping way to do it. This line is for labels in a game grid that scales, so I can't see a work-around solution (wrapping, cutting off and extending past the rectangle are all unacceptable). It's actually pretty quick, I'm doing this for hundreds of rectangles and it's fast enough to just slow it down a

How to use GL_REPEAT to repeat only a selection of a texture atlas? (OpenGL)

南楼画角 提交于 2020-01-01 04:03:06
问题 How can I repeat a selection of a texture atlas? For example, my sprite (selection) is within the texture coordinates: GLfloat textureCoords[]= { .1f, .1f, .3f, .1f, .1f, .3f, .3f, .3f }; Then I want to repeat that sprite N times to a triangle strip (or quad) defined by: GLfloat vertices[]= { -100.f, -100.f, 100.f, -100.f, -100.f, 100.f, 100.f, 100.f }; I know it has something to do with GL_REPEAT and textureCoords going passed the range [0,1] . This however, doesn't work: (trying to repeat N

White vertical lines and jittery horizontal lines in tile map movement

筅森魡賤 提交于 2020-01-01 03:57:16
问题 I'm having trouble finding an answer as to why the tile sheets I am making for our tile maps create vertical white lines and jittery horizontal lines while moving around on screen, using libGDX. Here is a video showing the white vertical lines: https://www.youtube.com/watch?v=34V64WacMo4 Here is one showing the horizontal jittery lines: https://www.youtube.com/watch?v=LiozBZzxmy0 For comparison, here is a project I worked on earlier this year without GDX. You can see the tilemap moves

WPF - Graphics.CopyFromScreen returns a black image

前提是你 提交于 2020-01-01 02:33:28
问题 The following method is taken from a WinForms app. It simply captures the screen, but I needed to modify it to work in a WPF application. When I use it, it returns a black image. The dimensions are correct. I have not got any open DirectX or videos and it wouldn't work even on my desktop. public static Bitmap CaptureScreen() { // Set up a bitmap of the correct size Bitmap CapturedImage = new Bitmap((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight, System

The Need To Restore Graphics Original State When Overwritten paint or paintComponent

断了今生、忘了曾经 提交于 2019-12-31 22:52:36
问题 I realize most of the Java code to overwritten paint or paintComponent, most of them doesn't restore the old state of graphics object, after they had change the state of graphics object. For example, setStroke, setRenderingHint... I was wondering whether it is a good practice that we restore back the old state of graphics object, before returning from the method. For example public void paintComponent(Graphics g) { super.paintComponet(g); Stroke oldStroke = g.getStroke(); g.setStroke

How can I create a hardware-accelerated image with Java2D?

不问归期 提交于 2019-12-31 13:52:35
问题 I'm trying to create a fast image generator that does lots of 2d transformations and shape rendering, so I'm trying to use a BufferedImage and then acquire the Graphics2D object to perform all my drawing. My main concern now is to make is really fast so I'm creating a BufferedImage like this: GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration(); BufferedImage bImage = gc

animated background java game

孤者浪人 提交于 2019-12-31 07:16:12
问题 I was programming a game similar to asteroid, but I do not understand how to spawn the asteroids in the background. now i spawn an asteroid in the main class but i want create a class for the asteroid ho i do it? MAIN CLASS public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; if(flag_img) { background(g2d); logo(g2d); menu(g2d); spaceship(g2d); crediti(g2d); } } background function(now) private void background(Graphics2D g2d) { asteroidi_g_x+=r

Java Rotate Image

血红的双手。 提交于 2019-12-31 06:04:08
问题 @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2=(Graphics2D) g.create(); //rotation of player if(player.newDirection) { int rotationX=player.getImage().getWidth(null)/2; int rotationY=player.getImage().getHeight(null)/2; AffineTransform at=new AffineTransform(); if(player.direction==LEFT) { //graphics.rotate(Math.toRadians(90),bufferedImage.getWidth()/2,bufferedImage.getHeight()/2); //graphics.drawImage(player.getImage(), player.getX(), player.getY(),

How to save graphics created on a PictureBox?

落花浮王杯 提交于 2019-12-31 04:30:54
问题 In c# and Visual Studio Windows forms I have loaded an image into a picture box (pictureBox2) and then cropped it and show in another picture box (pictureBox3). Now I want to save what is inside pictureBox3 as an image file. How can I do this? private void crop_bttn_Click(object sender, EventArgs e) { Image crop = GetCopyImage("grayScale.jpg"); pictureBox2.Image = crop; Bitmap sourceBitmap = new Bitmap(pictureBox2.Image, pictureBox2.Width, pictureBox2.Height); Graphics g = pictureBox3