Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm trying to program a Roulette game for my capstone class. I've been trying to find a way to code the wheel but I'm new to java and have no idea how to start. I found paintComponent(Graphics g) method helps rotating my wheel image but not the way the wheel should spin. Is there any way I can do it, any articles that would give me an ideas how to start. Any help will be much appreciated.
This example shows how to rotate an arbitrary image. This Q&A may suggest how to rotate the text, if you create your own image at run-time.
Addendum: In helpful comments, #Robin recalls this example, as well as #camickr's pivotal article Rotated Icon. As the goal is to model a game of roulette with a rotating wheel view, the MVC pattern may prove useful.
Here's two great rotation libraries that have an out-of-the-box fling-to-spin behaviour
https://bitbucket.org/warwick/hg_dial_v2
https://bitbucket.org/warwick/hgdialrepo
And here's a gesture library that implements the above code.
https://bitbucket.org/warwick/hacergestov3
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I'm learning CSS and I've been looking into parallax effect because it's awesome #.# ... but I don't like how most of them scroll. I really want to figure out how to achieve a nice smooth scrolling like on this website. I've been trying to figure out what it's called. I think it's momentum scrolling? But for some reason, when trying to find more examples or tutorials on how to do it, all examples of "smooth" or "momentum" scrolling I found work just like regular jerky scrolling, at least for me on Chrome.
I was wondering if someone could nudge me in the right direction of where I could learn more about how to code this specifically for Chrome at least.
Thank you.
This site uses CSS Transforms.
If you are familiar with parallax and that is not the question, then the effect you are noticing that differentiates this site from others with parallax is the transitional easing in (CSS Transitions).
So the state of the elements on the page are eased in gradually from a beginning state to an ending state.
More specifically you may want to look into CSS Transform Matrix : https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix.
Also for further research I highly recommend Sarah Drasner's book SVG Animations and also the book CSS Animations and Transitions for the Modern Web by Steven Bradley.
And for more inspiration look into "scrollytelling" and Shirley Wu from http://www.datasketch.es/. She is really into graceful scrollytelling and puts up amazing examples all the time.
Hope that helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Contex: I'm trying to make a 2d physic engine, i'm starting to think about how to draw shapes that i could rotate. So i thought i could draw irregular shapes by drawing lines from several equations of straight. Now i have some doubts:
There is a easy way of draw a straight by giving an equation?
There is a library that can help me to handle equations?
The reason to use equations instead of using functions to draw lines from x1,y1 to x2,y2 is that i want the equations to calculate collisions between shapes.
Do you know a book or an article that could help me pull this off?
I'm gonna work in java, for now this is just an idea.
Not an expert in this field but quick search on java 2d engine collision engine returns dyn4j library on the first page. You can explore their examples and consequently the implementation code.
https://github.com/wnbittle/dyn4j
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
First, I'm new in Java.
Second, sorry for my English but I'm still learning it.
I need to create object in 3D space, which I would can manipulate from my mouse next.
I can make e.g. square like this:
public void paint(Graphics g){
super.paint(g);
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.fillRect(50, 50, 40, 40);
}
But what I can do with that? In my opinion its only contour. Have Java special class for that?
I can use only awt;* and derivative from that. Is Canvas3D count to that?
Please, help me:)
I have used jogl in my projects
One possible option is to use JavaFX.
It involves complex math and requires Java8 and for you to understand the threading mechanism of Swing and JavaFX, but it seems the optimal option for 3D graphics implemented in Java.
It also integrates with Swing if you require or stands-alone.
Check Getting Started with JavaFX 3D Graphics
Check JavaFX Transformation overview.
I found this book helpful, it shows you how to create 3D graphics in Java from the ground up:
http://www.amazon.com/Computer-Graphics-Java-Programmers-Ammeraal/dp/0470031603
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Does anyone have any suggestions as to how I can go about creating an Effect for a JavaFX node that can simulate glass shattering and then (potentially) breaking? if the breaking is more difficult, I can skip that part. Basically I want to layer this pane over an image and then make it look like its a picture frame that then shatters. If it can then break into pieces (after some configurable delay).. that would be great as well!
I've looked everywhere but can't seem to find info on simulating the glass shatter effect in JavaFX.
Thanks!
For a simple solution I'd go with a Path that randomly extends and change the style of the path during time.
More sophisticated code could use a Canvas and paint the shattering on it. Daniel Shiffman with his Nature of Code book may be a base for you with the creation of the shatter effect.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Has anyone idea how to make recently Google Search page in java swing?
Please take a look at http://www.google.com.
Nice effect :-)
If you wanted to do this in Swing, I would take the following approach:
Render the original screen to an offscreen BufferedImage
Render the new screen to an offcreen BufferedImage
Do an animated transition between the two by drawing the new screen then painting over it with the correct portions of the old screen, twisted and rotated to the right location (you can use the Java2D AffineTransformation for the rotating/twisting)
The tricky bit will be getting the position to change over time in a way that looks visually appealing and doesn't cause any nasty visual artefacts. This will take some maths and quite a bit of trial and error!