graphics

Calling paintComponent() with parameters using repaint()

那年仲夏 提交于 2019-12-12 01:31:54
问题 I am very new to graphics with Java, so just ask if any additional information is needed :) I am trying to paint shapes based on where the mouse clicks on the screen. Because of this, I need to pass the x and y coordinates of where I clicked to the paintComponent() method so that it will know where to paint the shape. public void mouseClicked(MouseEvent e) { System.out.println("Adding Shape"); repaint(); } class CanvasDrawArea extends JPanel{ //this should run when the program first starts

Is this a 3d or 2d character for iPhone game?

天大地大妈咪最大 提交于 2019-12-12 00:59:34
问题 I'm making an iphone game, and need some graphics for it. I was wondering if the graphics I need are considered 2d or 3d. I only a few distinct actions, My character isnt going to be rotating at the users interaction. Basically, If you can imagine a checker board, I need my character to be seen to be able move forward, turn right and move forward, and turn left and move forward. So basically just move on that checkerboard in all directions on a birds eye view. Yet, when he is moving backwards

How to change MovieClip transparency based on mouse position?

别等时光非礼了梦想. 提交于 2019-12-12 00:07:07
问题 So, I'm trying to make a grid of rectangles each get more transparent the closer the mouse is to it. Using some basic maths, I thought I had got it, but instead it seems I got a weird graphic bug(maybe?) shown here: The middle of the rings is where the mouse is. Part of code that deals with transparency: private function update(e:Event = null):void { for (var i:int = 0; i < buttons.length; i++) { lightFact = getDistance(buttons[i]) lightBrightness = lightPower - (lightFact * 10) buttons[i]

How can drawing routines be optimized to achieve the maximum refresh rate in Windows CE?

假如想象 提交于 2019-12-11 23:42:46
问题 In my application i am drawing some set of lines (like a vertical graph), and the refresh rate will be around 30 times in a second. I have calculated the performance and it is taking 400 milliseconds to draw complete lines, but this won't be fast enough since we have to refresh the screen every 34 milliseconds. I am drawing on CDC. We will be drawing on a Windows CE device with a 400 MHz processor. Drawing involves the simple MFC APIs like MoveTo , LineTo , FillRect , etc. on DC of View: CDC*

Problems with SDL_SetColorKey

时间秒杀一切 提交于 2019-12-11 23:41:55
问题 I'm trying to create a transparent sprite with SDL. I'm using SDL_SetColorKey on a bitmap with magenta (0xff00ff) background (it's 100% magenta, I checked it with the GIMP :)) The call to SDL_SetColorKey looks like this: SDL_SetColorKey( bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(bitmap->format, 255, 0, 255) ); The call to SDL_SetColorKey apparently returns 0, however there is no transparency. Can anyone tell me what I am missing here? Here is the problematic code in case anyone wants to test it:

How to draw portions of circles based on percentages in Graphics2D?

纵然是瞬间 提交于 2019-12-11 22:31:54
问题 I am working on a circular health bar for a top-down 2d shooter and would like some opinions of the best way to do this in only graphics2D. Wondering if drawing many arcs or just using images would be best. 回答1: The answer depends on what you want to achieve... This is a very basic example... You can go backwards Even start at a different angle. With a little bit of work you could reduce the extended so you could have an "open" progress, for example, starting at 245 degrees with a total

Undo method for a paint program [duplicate]

妖精的绣舞 提交于 2019-12-11 21:25:42
问题 This question already has answers here : Extending Swing's UndoManager to provide repeat and multiple undo/redo (2 answers) Closed 5 years ago . I am trying to create a little drawing pad in one of my programs. This is the class: class DrawPad extends JComponent { Image image; Graphics2D graphics; int currentX, currentY, oldX, oldY; public DrawPad() { setDoubleBuffered(false); addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { oldX = e.getX(); oldY = e

UIImageEffects: white image when Gaussian radius above 280, vImageBoxConvolve_ARGB8888 issue?

五迷三道 提交于 2019-12-11 21:22:31
问题 I'm using the Gaussian blur algorithm found in Apple's UIImageEffects example: CGFloat inputRadius = blurRadius * inputImageScale; if (inputRadius - 2. < __FLT_EPSILON__) inputRadius = 2.; uint32_t radius = floor((inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5) / 2); radius |= 1; // force radius to be odd so that the three box-blur methodology works. NSInteger tempBufferSize = vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize |

Issue / Image Corruption Using Graphics.DrawImage With Task Parallel Library?

亡梦爱人 提交于 2019-12-11 21:13:38
问题 I have some code which takes an uploaded image, resizes it to 5 different sizes, then uploads those to another storage repository. I'm trying to execute the 5 image resizing operations in parallel using TPL. Upfront I'll mention that the resizing function is a static method, but that it doesn't use any static resources (so multiple parallel calls shouldn't be stepping on each other, from what I can tell). Also very relevant is that this is in the context of ASP.NET which has some different

How to get Semiotic plot to display in browser

断了今生、忘了曾经 提交于 2019-12-11 21:12:59
问题 I am brand new to Semiotic (https://semiotic.nteract.io/), and I have what is likely an embarrassingly easy question. I am trying to make a line chart. How do I get the following Semiotic code - taken directly from https://semiotic.nteract.io/guides/line-chart - to display in my browser? I have a Mac. What I have tried is to first install yarn and then do yarn add -E semiotic as the first link says. Next, I copied the below code directly into a text file, which I saved as a .js file. I then