Bobrocket Posted August 7, 2015 Share Posted August 7, 2015 (edited) I'm looking into making some simple JFrame animations: Going to make a few, make sure it's all nice and polished and clean and then release it on Github. Goals: Pulling/sliding in all directions (done left & right, have to do up & down now) Alpha-based animations (fading in/out) Size-based animations (shrinking/expanding) Color-based animations (switching from color x to color y) All of this will be based on JFrames, and I am originally building this for my GUIs. "Alpha" animation: This actually uses linear interpolation (10% decrease each time) instead of actual transparency as this should reduce overall strain on the CPU. Edited August 7, 2015 by Bobrocket 2 Quote Link to comment Share on other sites More sharing options...
Czar Posted August 7, 2015 Share Posted August 7, 2015 inspired by the slayer gui i hope Quote Link to comment Share on other sites More sharing options...
Botre Posted August 7, 2015 Share Posted August 7, 2015 Looks neato. However... Alpha-based animations Don't go there. Your CPU will thank me. Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 7, 2015 Author Share Posted August 7, 2015 inspired by the slayer gui i hope Whatever helps you sleep at night Looks neato. However... Alpha-based animations Don't go there. Your CPU will thank me. They will be there should someone want to use them. Instead of drawing transparent colours, I could manually lerp each pixel by x%. That might take less CPU, albeit with different results. 1 Quote Link to comment Share on other sites More sharing options...
Fruity Posted August 7, 2015 Share Posted August 7, 2015 it be like a phone app...on your computer :3 sounds good hope it works out for ya 1 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 7, 2015 Author Share Posted August 7, 2015 it be like a phone app...on your computer :3 sounds good hope it works out for ya Thanks! Having frames like this not only allows for less confusion by the end user (eg "where is the rest of the info?"), it also ensures that users actually fill out everything and simplifies everything (meaning the user is not overwhelmed at first sight) Working on color/"alpha" animations right now. Will post back soon. Quote Link to comment Share on other sites More sharing options...
Botre Posted August 7, 2015 Share Posted August 7, 2015 I really really like this tbh, I would probably prefer G2D buttons instead of the regular Swing ones (they look so 90s...), but I'm deffo going to give it a thorough look-through when I get some time ;) Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 7, 2015 Author Share Posted August 7, 2015 I really really like this tbh, I would probably prefer G2D buttons instead of the regular Swing ones (they look so 90s...), but I'm deffo going to give it a thorough look-through when I get some time I may port some of my .NET themes over to Java, we'll see ;) 1 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 7, 2015 Author Share Posted August 7, 2015 Some interesting debug information for the sliding animations: The red "circles" indicate where I clicked the "animate" button, which would perform the animation. In short, it uses copious amounts of CPU. Why? Currently, we use BufferedImage#getSubImage(x, y, width, height) to create each frame and then Graphics#drawImage(BufferedImage, x, y, ImageObserver) to draw it. Now, in a form of width 480, you're going to be creating 480 frames. This is obviously not going to be very CPU friendly. The solution, I hear you begging for, is (somewhat) simple: reduce the frames, and make the thread sleep a little bit. Now, this still uses a fair amount of CPU, however it does not use as much (and for as long)! By utilising both frame reduction and thread sleeping, I can achieve the same smooth transition while keeping the CPU down a little bit. You can see here that the CPU spikes a lot less (we hit 100% consumption by spam clicking the animate button, whereas we top 40% now by spam clicking) There's also practically no difference in the speed too: Another thing to mention for this animation library is that you can chain effects (I can put an alpha/colour effect on a panel as well as have it pull left/right) 1 Quote Link to comment Share on other sites More sharing options...
Valkyr Posted August 8, 2015 Share Posted August 8, 2015 I'm looking into making some simple JFrame animations: Going to make a few, make sure it's all nice and polished and clean and then release it on Github. Goals: Pulling/sliding in all directions (done left & right, have to do up & down now) Alpha-based animations (fading in/out) Size-based animations (shrinking/expanding) Color-based animations (switching from color x to color y) All of this will be based on JFrames, and I am originally building this for my GUIs. "Alpha" animation: This actually uses linear interpolation (10% decrease each time) instead of actual transparency as this should reduce overall strain on the CPU. Why not use JavaFX instead of fuckugly Swing? It's been in the API for over and does the same thing plus way more. Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 8, 2015 Author Share Posted August 8, 2015 Why not use JavaFX instead of fuckugly Swing? It's been in the API for over and does the same thing plus way more. Right as always, big guy. Quote Link to comment Share on other sites More sharing options...
Valkyr Posted August 8, 2015 Share Posted August 8, 2015 Right as always, big guy. Quote Link to comment Share on other sites More sharing options...