Search the Community
Showing results for tags 'animation'.
-
I am trying to solve this puzzle in PHP. I have found lots of help in Java and C++, but that isn't helping. I have gotten my code to spit out the first line, but am not sure how to get it to continue until all the particles have cleared the string. Any help would be appreciated! Problem Statement A collection of particles is contained in a linear chamber. They all have the same speed, but some are headed toward the right and others are headed toward the left. These particles can pass through each other without disturbing the motion of the particles, so all the particles will leave the chamber relatively quickly. We will be given the initial conditions by a String init containing at each position an 'L' for a leftward moving particle, an 'R' for a rightward moving particle, or a '.' for an empty location. init shows all the positions in the chamber. Initially, no location in the chamber contains two particles passing through each other. We would like an animation of the process. At each unit of time, we want a string showing occupied locations with an 'X' and unoccupied locations with a '.'. Create a class Animation that contains a method animate that is given an int speed and a String init giving the initial conditions. The speed is the number of positions each particle moves in one time unit. The method will return a String[] in which each successive element shows the occupied locations at the next time unit. The first element of the return should show the occupied locations at the initial instant (at time = 0) in the 'X','.' format. The last element in the return should show the empty chamber at the first time that it becomes empty. Definition Class: Animation Method: animate Parameters: int, String Returns: String[] Method signature: String[] animate(int speed, String init) (be sure your method is public) Constraints - speed will be between 1 and 10 inclusive - init will contain between 1 and 50 characters inclusive - each character in init will be '.' or 'L' or 'R' Examples 0) 2 "..R...." Returns: { "..X....", "....X..", "......X", "......." } The single particle starts at the 3rd position, moves to the 5th, then 7th, and then out of the chamber. 1) 3 "RR..LRL" Returns: { "XX..XXX", ".X.XX..", "X.....X", "......." } At time 1, there are actually 4 particles in the chamber, but two are passing through each other at the 4th position 2) 2 "LRLR.LRLR" Returns: { "XXXX.XXXX", "X..X.X..X", ".X.X.X.X.", ".X.....X.", "........." } At time 0 there are 8 particles. At time 1, there are still 6 particles, but only 4 positions are occupied since particles are passing through each other. 3) 10 "RLRLRLRLRL" Returns: { "XXXXXXXXXX", ".........." } These particles are moving so fast that they all exit the chamber by time 1. 4) 1 "..." Returns: { "..." } 5) 1 "LRRL.LR.LRR.R.LRRL." Returns: { "XXXX.XX.XXX.X.XXXX.", "..XXX..X..XX.X..XX.", ".X.XX.X.X..XX.XX.XX", "X.X.XX...X.XXXXX..X", ".X..XXX...X..XX.X..", "X..X..XX.X.XX.XX.X.", "..X....XX..XX..XX.X", ".X.....XXXX..X..XX.", "X.....X..XX...X..XX", ".....X..X.XX...X..X", "....X..X...XX...X..", "...X..X.....XX...X.", "..X..X.......XX...X", ".X..X.........XX...", "X..X...........XX..", "..X.............XX.", ".X...............XX", "X.................X", "..................." }
-
Hi guys, I have added simple CSS3 opacity animation on scroll down and everything works. Now I am trying to add cool bounce CSS3 effect and it works but disappears after the effect is completed. The effect is applyed to the 'footer' with "addClass('animated bounceInDown');". I don't think that is CSS problem as the animation should just stop playing when its done. Any ideas? <script type="text/javascript"> $(document).ready(function() { /* Every time the window is scrolled ... */ $(window).scroll( function(){ /* Check the location of each desired element */ $('.hideme','footer').each( function(i){ var bottom_of_object = $(this).position().top + $(this).outerHeight(); var bottom_of_window = $(window).scrollTop() + $(window).height(); /* If the object is completely visible in the window, fade it it */ if( bottom_of_window > bottom_of_object ){ $(this).animate({'opacity':'1'},500); $(this).addClass('animated bounceInDown'); } }); $('img').load(function() { $(this).addClass('active'); }); }); }); </script>
-
In general if I know how to do something I want to do I can code it in a language I'm less than fluent in, if I am fluent in a language I can figure out how to code something I want to do but don't know very well how to do it, but this time I have almost no clue how to do what I want to do and very limited fluency in JS. I want a script that will slowly fade from one color (red, green, blue, white, black) to a neutral color (grey) and then fade into one of the randomly selected other 4 colors. Then repeat. Forever. So like Rd>gy>wt>bu>gy>bk etc. I have no clue what to do, if you can help I will be grateful for all time. Oh, and I need to make sure the text color is always contrasting so it can be read, so I need to adjust that too?
- 6 replies
-
- javascript
- css
-
(and 1 more)
Tagged with: