Search Results

Search found 2528 results on 102 pages for 'animation'.

Page 13/102 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • jQuery background-position animation

    - by depi
    Hi guys, I've created an image which is basically a CSS sprite of 3 images together. It's size is 278x123 so they are basically 3 images of 278x41. What I am trying to do is to make an animation of that by changing the background position. I've tried many things, one of my not very working solution is the following: var $slogan = $('#header h2 span'); $slogan.css({backgroundPosition: '0px 0px'}); function slogan_animation() { if ($slogan.css('background-position') == '0px 0px') { $slogan.fadeIn('slow').css('background-position', '0px -41px').fadeOut('slow'); } else if ($slogan.css('background-position') == '0px -41px') { $slogan.fadeIn('slow').css('background-position', '0px -82px').fadeOut('slow'); } else if ($slogan.css('background-position') == '0px -82px') { $slogan.fadeIn('slow').css('background-position', '0px 0px').fadeOut('slow'); } } setInterval(slogan_animation, 2000); Any ideas how could I do that? Basically I just need to: - set my background position to "0px 0px", then move it to "0px -41px", then "0px -82px" and then loop it again from "0px 0px". It would be also great to have fadeIn() effect between those. Any ideas? Thank you.

    Read the article

  • WPF abnormal CPU usage for animation

    - by 0xDEAD BEEF
    HI! I am developing WPF application and client reports extreamly high CPU usage (90%) (whereas i am unable to repeat that behavior). I have traced bootleneck down to these lines. It is simple glowing animation for small single led control (blinking led). What could be reason for this simple annimation taking up SO huge CPU resources? <Trigger Property="State"> <Trigger.Value> <local:BlinkingLedStatus>Blinking</local:BlinkingLedStatus> </Trigger.Value> <Trigger.EnterActions> <BeginStoryboard Name="beginStoryBoard"> <Storyboard> <DoubleAnimation Storyboard.TargetName="glow" Storyboard.TargetProperty="Opacity" AutoReverse="True" From="0.0" To="1.0" Duration="0:0:0.5" RepeatBehavior="Forever"/> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <StopStoryboard BeginStoryboardName="beginStoryBoard"/> </Trigger.ExitActions> </Trigger>

    Read the article

  • C# WPF abnormal CPU usage for animation

    - by 0xDEAD BEEF
    I am developing WPF application and client reports extreamly high CPU usage (90%) (whereas i am unable to repeat that behavior). I have traced bootleneck down to these lines. It is simple glowing animation for small single led control (blinking led). What could be reason for this simple annimation taking up SO huge CPU resources? <Trigger Property="State"> <Trigger.Value> <local:BlinkingLedStatus>Blinking</local:BlinkingLedStatus> </Trigger.Value> <Trigger.EnterActions> <BeginStoryboard Name="beginStoryBoard"> <Storyboard> <DoubleAnimation Storyboard.TargetName="glow" Storyboard.TargetProperty="Opacity" AutoReverse="True" From="0.0" To="1.0" Duration="0:0:0.5" RepeatBehavior="Forever"/> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <StopStoryboard BeginStoryboardName="beginStoryBoard"/> </Trigger.ExitActions> </Trigger>

    Read the article

  • Flex 4 animation question

    - by Jerry
    Hello.. I am trying to do the move vertically animation on a button nested in the vertical layout. I am not sure if the Hgroup restricts the button moving vertically. Are there ways to go around it? Thanks for the helps. <s:states> <s:State name="default"/> <s:State name="addRecommend"/> <s:State name="seeOther"/> </s:states> AS: protected function add_clickHandler(event:MouseEvent):void { currentState="addRecommend"; addRecommendMove.play(); } <s:transitions> <s:Transition fromState="default" toState="addRecommend"> <s:Sequence id="addRecommendMove"> <s:Move yTo="50" target="{add}"/> // add button doesn't move at all </s:Sequence> </s:Transition> <s:Transition fromState="addRecommend" toState="seeOther"> <s:Sequence> <s:Move yBy="50" target="{seeOthers}"/> </s:Sequence> </s:Transition> </s:transitions> <s:layout> <s:VerticalLayout paddingTop="15" paddingRight="10" paddingLeft="7"/> </s:layout> <button id="add" click=add_clickHandler(event)/> <button id="seeOthers"/>

    Read the article

  • How to know why an animation stutters?

    - by Patrick Klug
    I have a few fairly simple animations (moving text around, moving ellipses etc.) and running in full screen (1920x1080 minus the task bar) the WPF Performance Suite reports a good framerate around 50 FPS throughout the animation. Dirty Rect Addition is somewhere around 300 rect/s, the SW frames are between 0 and 4 and the HW frames are between 3 and 5. Video memory usage is around 80 MB. Problem is that the animations stutters every other half second. My machine is a new Dell laptop XPS 15 with the GeForce GT 435 with 2GB memory. - The drivers are up to date. (The same behavior occurs on my netbook (in full screen) as well so I don't think it is hardware related.) If I make the window smaller the stutter goes away. The stutter occurs with the simplest of animations - even with just a couple of elements but adding more elements certainly makes it more noticeable. How can I find out what causes this stutter? When I think of it, I have not actually seen any WPF animations which run smoothly in full screen. Is this even possible?

    Read the article

  • How to start/stop/restart jQuery animation

    - by Emin
    I have the following function that when I call displays a message to the user for a certain amount of time (5 secs in my case). During this "period" if I call the function again to display another message, practically it should hide, then re-appear with the new message for another 5 seconds. What happens with my code below, I call the function to display the message. Then, lets say on the 4th second, I call it again to display another message, the new message is displayed for 1 second. I need to somehow -reset- the time but can't figure out how. Tried stopping the animation, checking if the element was visible and hiding it if it was, and many other things. I believe the solution is a simple chaining issue but can't get it right. So any help would be appreciated! function display_message(msgType, message) { var elem = $('#ur_messagebox'); switch (msgType) { case 'confirm': elem.addClass('msg_confirm'); break; case 'error': elem.addClass('msg_error'); break; } elem.html(message); elem.show().delay(5000).fadeOut(1000); } thanks in advance...

    Read the article

  • How do I stop a bouncy JQuery animation?

    - by Miguel
    In a webapp I'm working on, I want to create some slider divs that will move up and down with mouseover & mouseout (respectively.) I currently have it implemented with JQuery's hover() function, by using animate() and reducing/increasing it's top css value as needed. This works fairly well, actually. The problem is that it tends to get stuck. If you move the mouse over it (especially near the bottom), and quickly remove it, it will slide up & down continuously and won't stop until it's completed 3-5 cycles. To me, it seems that the issue might have to do with one animation starting before another is done (e.g. the two are trying to run, so they slide back and forth.) Okay, now for the code. Here's the basic JQuery that I'm using: $('.slider').hover( /* mouseover */ function(){ $(this).animate({ top : '-=120' }, 300); }, /* mouseout*/ function(){ $(this).animate({ top : '+=120' }, 300); } ); I've also recreated the behavior in a JSFiddle. Any ideas on what's going on? :) ==EDIT== UPDATED JSFiddle

    Read the article

  • jQuery animation loop not working

    - by Marko Ivanovski
    Hi, I'm trying to create a looping animation that starts on onmousedown and stops on onmouseout. The effect is a simple scroll that will continue looping until you release the mouse. I've created a function which performs the .animate method and it passes itself as a callback but the code only runs once. Here's the entire code: $(document).ready(function() { var $scroller = $("#scroller"); var $content = $("#content", $scroller); // lineHeight equal to 1 line of text var lineHeight = $content.css('line-height'); //Amount to scroll = 3 lines of text a time var amountToScroll = lineHeight.replace("px","")*3; var maxScroll = $content.height() - $scroller.height(); function scrollDown() { var topCoord = $content.css("top").replace("px",""); if(topCoord > -maxScroll) { if((-maxScroll-topCoord) > -amountToScroll) { $content.stop().animate({ top: -maxScroll }, 1000 ); } else { $content.stop().animate({ top: "-=" + amountToScroll }, 1000, function(){ scrollDown() } ); } } } function scrollUp() { var topCoord = $content.css("top").replace("px",""); if(topCoord < 0) { if(topCoord > -amountToScroll) { $content.stop().animate({ top: 0 }, 1000 ); } else { $content.stop().animate({ top: "+=" + amountToScroll }, 1000, function(){scrollUp()} ); } } } $("#scroll-down").mousedown(function() { scrollDown(); }); $("#scroll-down").mouseup(function() { $content.stop(); }); $("#scroll-up").mousedown(function() { scrollUp(); }); $("scroll-up").mouseup(function() { $content.stop(); }); });

    Read the article

  • Managing flash animations for a game

    - by LoveMeSomeCode
    Ok, I've been writing C# for a while, but I'm new to ActionScript, so this is a question about best practices. We're developing a simple match game, where the user selects tiles and tries to match various numbers - sort of like memory - and when the match is made we want a series of animations to take place, and when they're done, remove the tile and add a new one. So basically it's: User clicks the MC Animation 1 on the MC starts Animation 1 ends Remove the MC from the stage Add a new MC Start the animation on the new MC The problem I run into is that I don't want to make the same timeline motion tween on each and every tile, when the animation is all the same. It's just the picture in the tile that's different. The other method I've come up with is to just apply the tweens in code on the main stage. Then I attach an event handler for MOTION_FINISH, and in that handler I trigger the next animation and listen for that to finish etc. This works too, but not only do I have to do all the tweening in code, I have a seperate event handler for each stage of the animation. So is there a more structured way of chaining these animations together?

    Read the article

  • What is the standard technique for shifting the frames of a sprite according to user input?

    - by virtual__
    From my own experience, I developed two techniques for changing the sprites of a character that's reacting to user input -- this in the context of a classic 2D platformer. The first one is to store all character's pixmaps in a list, putting the index of the currently used pixmap in an ordinary variable. This way, every time the player presses a key -- say the right arrow for moving the character forward -- the graphics engine sees what's the next pixmap to draw, draws it, and increments the index counter. That's a pretty common approach I believe, the problem is that in this case the animation's quality depends not only on the number of sprites available but also on how often your engine listens to user input. The second technique is to actually play an animation every key press event. For this you can use any sort of animation framework you want. It's only necessary to set the timer, the animation steps and to call the animation's play() method on your key press event handler. The problem with that approach is that is lacks responsiveness, since the character won't react to any input while the current animation is still being played. What I want to know is whether you are using one of these techniques -- or something similar -- in your games, or whether there's a standard method for animating sprites out there that's widely known by everybody but me.

    Read the article

  • Add animation when user control get visible and collapsed In Wpf

    - by sanjeev40084
    I have two xaml files MainWindow.xaml and other user control WorkDetail.xaml file. MainWindow.xaml file has a textbox, button, listbox and reference to WorkDetail.xaml(user control which is collapsed). Whenever user enter any text, it gets added in listbox when the add button is clicked. When any items from the listbox is double clicked, the visibility of WorkDetail.xaml is set to Visible and it gets displayed. In WorkDetail.xaml (user control) it has textblock and button. The Textblock displays the text of selected item and close button sets the visibility of WorkDetail window to collapsed. Now i am trying to animate WorkDetail.xaml when it gets visible and collapse. When any items from listbox is double clicked and WorkDetail.xaml visibility is set to visible, i want to create an animation of moving WorkDetail.xaml window from right to left on MainWindow. When Close button from WorkDetail.xaml file is clicked and WorkDetail.xaml file is collapsed, i want to slide the WorkDetail.xaml file from left to right from MainWindow. Here is the screenshot: MainWindow.xaml code: <Window...> <Grid Background="Black" > <TextBox x:Name="enteredWork" Height="39" Margin="44,48,49,0" TextWrapping="Wrap" VerticalAlignment="Top"/> <ListBox x:Name="workListBox" Margin="26,155,38,45" FontSize="29.333" MouseDoubleClick="workListBox_MouseDoubleClick"/> <Button x:Name="addWork" Content="Add" Height="34" Margin="71,103,120,0" VerticalAlignment="Top" Click="Button_Click"/> <TestWpf:WorkDetail x:Name="WorkDetail" Visibility="Collapsed"/> </Grid> </Window> MainWindow.xaml.cs class code: namespace TestWpf { public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { workListBox.Items.Add(enteredWork.Text); } private void workListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { WorkDetail.workTextBlk.Text = (string)workListBox.SelectedItem; WorkDetail.Visibility = Visibility.Visible; } } } WorkDetail.xaml code: <UserControl ..> <Grid Background="#FFD2CFCF"> <TextBlock x:Name="workTextBlk" Height="154" Margin="33,50,49,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="29.333" Background="#FFF13939"/> <Button x:Name="btnClose" Content="Close" Height="62" Margin="70,0,94,87" VerticalAlignment="Bottom" Click="btnClose_Click"/> </Grid> </UserControl> WorkDetail.xaml.cs class code: namespace TestWpf { public partial class WorkDetail : UserControl { public WorkDetail() { this.InitializeComponent(); } private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e) { Visibility = Visibility.Collapsed; } } } Can anyone tell how can i do this?

    Read the article

  • JLabel animation in JPanel

    - by Trizicus
    After scratching around I found that it's best to implement a custom image component by extending a JLabel. So far that has worked great as I can add multiple "images" (jlabels without the layout breaking. I just have a question that I hope someone can answer for me. I noticed that in order to animate JLabels across the screen I need to setlayout(null); and setbounds of the component and then to animate eventually setlocation(x,y);. Is this a best practice or a terrible way to animate a component? I plan on eventually making an animation class but I don't want to do so and end up having to chuck it. I have included relevant code for a quick review check. import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JPanel; import javax.swing.Timer; public class GraphicsPanel extends JPanel { private Timer timer; private long startTime = 0; private int numFrames = 0; private float fps = 0.0f; private int x = 0; GraphicsPanel() { final Entity ent1 = new Entity(); ent1.setBounds(x, 0, ent1.getWidth(), ent1.getHeight()); add(ent1); //ESSENTIAL setLayout(null); //GAMELOOP timer = new Timer(30, new ActionListener() { public void actionPerformed(ActionEvent e) { getFPS(); incX(); ent1.setLocation(x, 0); repaint(); } }); timer.start(); } public void incX() { x++; } @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g.create(); g2.setClip(0, 0, getWidth(), getHeight()); g2.setColor(Color.BLACK); g2.drawString("FPS: " + fps, 1, 15); } public void getFPS() { ++numFrames; if (startTime == 0) { startTime = System.currentTimeMillis(); } else { long currentTime = System.currentTimeMillis(); long delta = (currentTime - startTime); if (delta > 1000) { fps = (numFrames * 1000) / delta; numFrames = 0; startTime = currentTime; } } } } Thank you!

    Read the article

  • Smooth animation using MatrixTransform?

    - by Mattias Konradsson
    I'm trying to do an Matrix animation where I both scale and transpose a canvas at the same time. The only approach I found was using a MatrixTransform and MatrixAnimationUsingKeyFrames. Since there doesnt seem to be any interpolation for matrices built in (only for path/rotate) it seems the only choice is to try and build the interpolation and DiscreteMatrixKeyFrame's yourself. I did a basic implementation of this but it isnt exactly smooth and I'm not sure if this is the best way and how to handle framerates etc. Anyone have suggestions for improvement? Here's the code: MatrixAnimationUsingKeyFrames anim = new MatrixAnimationUsingKeyFrames(); int duration = 1; anim.KeyFrames = Interpolate(new Point(0, 0), centerPoint, 1, factor,100,duration); this.matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, anim,HandoffBehavior.Compose); public MatrixKeyFrameCollection Interpolate(Point startPoint, Point endPoint, double startScale, double endScale, double framerate,double duration) { MatrixKeyFrameCollection keyframes = new MatrixKeyFrameCollection(); double steps = duration * framerate; double milliSeconds = 1000 / framerate; double timeCounter = 0; double diffX = Math.Abs(startPoint.X- endPoint.X); double xStep = diffX / steps; double diffY = Math.Abs(startPoint.Y - endPoint.Y); double yStep = diffY / steps; double diffScale= Math.Abs(startScale- endScale); double scaleStep = diffScale / steps; if (endPoint.Y < startPoint.Y) { yStep = -yStep; } if (endPoint.X < startPoint.X) { xStep = -xStep; } if (endScale < startScale) { scaleStep = -scaleStep; } Point currentPoint = new Point(); double currentScale = startScale; for (int i = 0; i < steps; i++) { keyframes.Add(new DiscreteMatrixKeyFrame(new Matrix(currentScale, 0, 0, currentScale, currentPoint.X, currentPoint.Y), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(timeCounter)))); currentPoint.X += xStep; currentPoint.Y += yStep; currentScale += scaleStep; timeCounter += milliSeconds; } keyframes.Add(new DiscreteMatrixKeyFrame(new Matrix(endScale, 0, 0, endScale, endPoint.X, endPoint.Y), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); return keyframes; }

    Read the article

  • Adding UIView animation mysteriously changes starting frame

    - by clozach
    I'm working on an app that shows a thumbnail of a photo taken by the user. In order to show a seemless transition from the full-screen image shown in the UIImagePickerController to the thumbnail, I set the frame on my copy of the image to [[UIScreen mainScreen] bounds] and then change the frame to match the frame of an invisible button. (The button allows users to re-take their photo by tapping the thumbnail image.) The trouble is that the starting x-origin of my UIImageView (imageView) is mysteriously starting nearly offscreen to the left: As you can see from the alert, the imageView purports to be located at (0,0), yet it's displaying at something like (-255,0). Here's the code: CGRect frame = [[UIScreen mainScreen] bounds]; imageView.frame = frame; [[[[UIAlertView alloc] initWithTitle:@"Yo!" message:[NSString stringWithFormat:@"starting frame:%@",NSStringFromCGRect(imageView.frame)] delegate:nil cancelButtonTitle:@"K." otherButtonTitles:nil] autorelease] show]; // Slide the enlarged image seamlessly "onto" the photo button [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1000]; [UIView setAnimationDelay:.5]; imageView.frame = pictureButton.frame; [UIView commitAnimations]; As if to taunt me, the image actually does go full screen if I comment out the animation code: CGRect frame = [[UIScreen mainScreen] bounds]; imageView.frame = frame; [[[[UIAlertView alloc] initWithTitle:@"Yo!" message:[NSString stringWithFormat:@"starting frame:%@",NSStringFromCGRect(imageView.frame)] delegate:nil cancelButtonTitle:@"K." otherButtonTitles:nil] autorelease] show]; // Slide the enlarged image seamlessly "onto" the photo button // [UIView beginAnimations:nil context:nil]; // [UIView setAnimationDuration:1000]; // [UIView setAnimationDelay:.5]; // // imageView.frame = pictureButton.frame; // // [UIView commitAnimations]; (Note: animationDuration will of course be set to something more like .5 in production, not 1000 seconds.) Update — Other weirdness worth mentioning in case it's relevant: It turns out the offset changes depending on the orientation of the camera when the photo was taken. If I take the picture with the phone upside-down, for instance, then the image gets offset vertically as well as horizontally. The picker seems to be filling the image's imageOrientation incorrectly: I have to hold the phone sideways, Home button on the left, to get an image with UIImageOrientationUp. At one point I experimented with setting imageView.clipsToBounds = YES;, which revealed that my image view's frame is in fact correct. Rather, it's the UIImage's placement within the UIImageView that gets offset. Fwiw, the image view's contentMode is the default, UIViewContentModeScaleToFill.

    Read the article

  • Slow Jquery Animation

    - by Pyronaut
    I have this webpage : http://miloarc.pyrogenicmedia.com/ Which atm is nothing special. It has a few effects but none that break the bank. If you mouse over a tile, it should change it's opacity to give it a fade effect. This is done through the Jquery Animation, not through CSS (I do this so it can fade, instead of being a straight change). Everything looks nice when the page loads, and the fades look perfect. Infact if you drag your mouse all over the place, if gives you a "trail" almost like a snake. Anyway, My next problem is that you will see there is a box in the top left, which is going to tell you information about the tile you are hovering over. This seems to work fine. When you mouse over that information box, it switches it's position (So that you can reach the tiles that were previously hidden underneath it). From my understanding, this is all working fine, and to the letter. However, After one move of the info box (One hover). Viewing the page in Firefox turns slugish. As in, after a successful move of the info box, the fade effects become very stuttered, and it doesn't pick up events as fast meaning you can't draw a "trail" on the screen. Chrome doesn't have this issue. It seems to work fine no matter what. Safari also seems ok. Although I do notice if I move my mouse really fast, it does jump a bit but not as much as firefox. Internet explorer doesn't work at all. Seems to crash the browser... And there is an error with the rounded corner plugin im using (Not sure why...). All in all, I think whatever I'm doing inside my code must be heavily sluggish. But I don't know where it is happening. Here is the full code, but I would advise go to the link to view everything. <script type="text/javascript"> $(document).ready(function() { var WindowWidth = $(window).width(); var WindowMod = WindowWidth % 20; var WindowWidth = WindowWidth - WindowMod; var BoxDimension = WindowWidth / 20; var BoxDimensionFixed = BoxDimension - 12; var dimensions = BoxDimensionFixed + 'px'; $('.gamebutton').each(function(i) { $(this).css('width', dimensions); $(this).css('height', dimensions); }); var OuterDivHeight = BoxDimension * 10; var TopMargin = ($(window).height() - OuterDivHeight) / 2; var OuterDivWidth = BoxDimension * 20; var LeftMargin = ($(window).width() - OuterDivWidth) / 2; $('#gamePort').css('margin-top', TopMargin).css('margin-left', LeftMargin).css('margin-right', LeftMargin); $('.gamebutton img').each(function(i) { $(this).hover( function () { $(this).animate({'opacity': 0.65}); }, function () { $(this).animate({'opacity': 1}); } ); }); $('.rounded').corners(); $('.gamebutton').each(function(i) { $(this).hover(function() { $('.gameTitlePopup').html($(this).attr('title')); FadeActive(); }); }); function FadeActive() { $('.activeInfo').fadeIn('slow'); } $('#gameInfoLeft').hover(function() { $(this).removeClass('activeInfo'); $(this).fadeOut('slow', function() { $('#gameInfoRight').addClass('activeInfo'); FadeActive(); }); }); $('#gameInfoRight').hover(function() { $(this).removeClass('activeInfo'); $(this).fadeOut('slow', function() { $('#gameInfoLeft').addClass('activeInfo'); FadeActive(); }); }); }); </script> Thanks for any help :).

    Read the article

  • Optimizing a 3D World Javascript Animation

    - by johnny
    Hi! I've recently come up with the idea to create a tag cloud like animation shaped like the earth. I've extracted the coastline coordinates from ngdc.noaa.gov and wrote a little script that displayed it in my browser. Now as you can imagine, the whole coastline consists of about 48919 points, which my script would individually render (each coordinate being represented by one span). Obviously no browser is capable of rendering this fluently - but it would be nice if I could render as much as let's say 200 spans (twice as much as now) on my old p4 2.8 Ghz (as a representative benchmark). Are there any javascript optimizations I could use in order to speed up the display of those spans? One 'coordinate': <div id="world_pixels"> <span id="wp_0" style="position:fixed; top:0px; left:0px; z-index:1; font-size:20px; cursor:pointer;cursor:hand;" onmouseover="magnify_world_pixel('wp_0');" onmouseout="shrink_world_pixel('wp_0');" onClick="set_askcue_bar('', 'new york')">new york</span> </div> The script: $(document).ready(function(){ world_pixels = $("#world_pixels span"); world_pixels.spin(); setInterval("world_pixels.spin()",1500); }); z = new Array(); $.fn.spin = function () { for(i=0; i<this.length; i++) { /*actual screen coordinates: x/y/z --> left/font-size/top 300/13/0 300/6/300 | / |/ 0/13/300 ----|---- 600/13/300 /| / | 300/20/300 300/13/600 */ /*scale font size*/ var resize_x = 1; /*scale width*/ var resize_y = 2.5; /*scale height*/ var resize_z = 2.5; var from_left = 300; var from_top = 20; /*actual math coordinates: 1 -1 | / |/ 1 ----|---- -1 /| / | 1 -1 */ //var get_element = document.getElementById(); //var font_size = parseInt(this.style.fontSize); var font_size = parseInt($(this[i]).css("font-size")); var left = parseInt($(this[i]).css("left")); if (coast_line_array[i][1]) { } else { var top = parseInt($(this[i]).css("top")); z[i] = from_top + (top - (300 * resize_z)) / (300 * resize_z); //global beacause it's used in other functions later on var top_new = from_top + Math.round(Math.cos(coast_line_array[i][2]/90*Math.PI) * (300 * resize_z) + (300 * resize_z)); $(this[i]).css("top", top_new); coast_line_array[i][3] = 1; } var x = resize_x * (font_size - 13) / 7; var y = from_left + (left- (300 * resize_y)) / (300 * resize_y); if (y >= 0) { this[i].phi = Math.acos(x/(Math.sqrt(x^2 + y^2))); } else { this[i].phi = 2*Math.PI - Math.acos(x/(Math.sqrt(x^2 + y^2))); i } this[i].theta = Math.acos(z[i]/Math.sqrt(x^2 + y^2 + z[i]^2)); var font_size_new = resize_x * Math.round(Math.sin(coast_line_array[i][4]/90*Math.PI) * Math.cos(coast_line_array[i][0]/180*Math.PI) * 7 + 13); var left_new = from_left + Math.round(Math.sin(coast_line_array[i][5]/90*Math.PI) * Math.sin(coast_line_array[i][0]/180*Math.PI) * (300 * resize_y) + (300 * resize_y)); //coast_line_array[i][6] = coast_line_array[i][7]+1; if ((coast_line_array[i][0] + 1) > 180) { coast_line_array[i][0] = -180; } else { coast_line_array[i][0] = coast_line_array[i][0] + 0.25; } $(this[i]).css("font-size", font_size_new); $(this[i]).css("left", left_new); } } resize_x = 1; function magnify_world_pixel(element) { $("#"+element).animate({ fontSize: resize_x*30+"px" }, { duration: 1000 }); } function shrink_world_pixel(element) { $("#"+element).animate({ fontSize: resize_x*6+"px" }, { duration: 1000 }); } I'd appreciate any suggestions to optimize my script, maybe there is even a totally different approach on how to go about this. The whole .js file which stores the array for all the coordinates is available on my page, the file is about 2.9 mb, so you might consider pulling the .zip for local testing: metaroulette.com/files/31218.zip metaroulette.com/files/31218.js P.S. the php I use to create the spans: <?php //$arbitrary_characters = array('a','b','c','ddsfsdfsdf','e','f','g','h','isdfsdffd','j','k','l','mfdgcvbcvbs','n','o','p','q','r','s','t','uasdfsdf','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9',); $arbitrary_characters = array('cat','table','cool','deloitte','askcue','what','more','less','adjective','nice','clinton','mars','jupiter','testversion','beta','hilarious','lolcatz','funny','obama','president','nice','what','misplaced','category','people','religion','global','skyscraper','new york','dubai','helsinki','volcano','iceland','peter','telephone','internet', 'dialer', 'cord', 'movie', 'party', 'chris', 'guitar', 'bentley', 'ford', 'ferrari', 'etc', 'de facto'); for ($i=0; $i<96; $i++) { $arb_digits = rand (0,45); $arbitrary_character = $arbitrary_characters[$arb_digits]; //$arbitrary_character = "."; echo "<span id=\"wp_$i\" style=\"position:fixed; top:0px; left:0px; z-index:1; font-size:20px; cursor:pointer;cursor:hand;\" onmouseover=\"magnify_world_pixel('wp_$i');\" onmouseout=\"shrink_world_pixel('wp_$i');\" onClick=\"set_askcue_bar('', '$arbitrary_character')\">$arbitrary_character</span>\n"; } ?>

    Read the article

  • Core Animation bad access on device

    - by user1595102
    I'm trying to do a frame by frame animation with CAlayers. I'm doing this with this tutorial http://mysterycoconut.com/blog/2011/01/cag1/ but everything works with disable ARC, when I'm try to rewrite code with ARC, it's works on simulator perfectly but on device I got a bad access memory. Layer Class interface #import <Foundation/Foundation.h> #import <QuartzCore/QuartzCore.h> @interface MCSpriteLayer : CALayer { unsigned int sampleIndex; } // SampleIndex needs to be > 0 @property (readwrite, nonatomic) unsigned int sampleIndex; // For use with sample rects set by the delegate + (id)layerWithImage:(CGImageRef)img; - (id)initWithImage:(CGImageRef)img; // If all samples are the same size + (id)layerWithImage:(CGImageRef)img sampleSize:(CGSize)size; - (id)initWithImage:(CGImageRef)img sampleSize:(CGSize)size; // Use this method instead of sprite.sampleIndex to obtain the index currently displayed on screen - (unsigned int)currentSampleIndex; @end Layer Class implementation @implementation MCSpriteLayer @synthesize sampleIndex; - (id)initWithImage:(CGImageRef)img; { self = [super init]; if (self != nil) { self.contents = (__bridge id)img; sampleIndex = 1; } return self; } + (id)layerWithImage:(CGImageRef)img; { MCSpriteLayer *layer = [(MCSpriteLayer*)[self alloc] initWithImage:img]; return layer ; } - (id)initWithImage:(CGImageRef)img sampleSize:(CGSize)size; { self = [self initWithImage:img]; if (self != nil) { CGSize sampleSizeNormalized = CGSizeMake(size.width/CGImageGetWidth(img), size.height/CGImageGetHeight(img)); self.bounds = CGRectMake( 0, 0, size.width, size.height ); self.contentsRect = CGRectMake( 0, 0, sampleSizeNormalized.width, sampleSizeNormalized.height ); } return self; } + (id)layerWithImage:(CGImageRef)img sampleSize:(CGSize)size; { MCSpriteLayer *layer = [[self alloc] initWithImage:img sampleSize:size]; return layer; } + (BOOL)needsDisplayForKey:(NSString *)key; { return [key isEqualToString:@"sampleIndex"]; } // contentsRect or bounds changes are not animated + (id < CAAction >)defaultActionForKey:(NSString *)aKey; { if ([aKey isEqualToString:@"contentsRect"] || [aKey isEqualToString:@"bounds"]) return (id < CAAction >)[NSNull null]; return [super defaultActionForKey:aKey]; } - (unsigned int)currentSampleIndex; { return ((MCSpriteLayer*)[self presentationLayer]).sampleIndex; } // Implement displayLayer: on the delegate to override how sample rectangles are calculated; remember to use currentSampleIndex, ignore sampleIndex == 0, and set the layer's bounds - (void)display; { if ([self.delegate respondsToSelector:@selector(displayLayer:)]) { [self.delegate displayLayer:self]; return; } unsigned int currentSampleIndex = [self currentSampleIndex]; if (!currentSampleIndex) return; CGSize sampleSize = self.contentsRect.size; self.contentsRect = CGRectMake( ((currentSampleIndex - 1) % (int)(1/sampleSize.width)) * sampleSize.width, ((currentSampleIndex - 1) / (int)(1/sampleSize.width)) * sampleSize.height, sampleSize.width, sampleSize.height ); } @end I create the layer on viewDidAppear and start animate by clicking on button, but after init I got a bad access error -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSString *path = [[NSBundle mainBundle] pathForResource:@"mama_default.png" ofType:nil]; CGImageRef richterImg = [UIImage imageWithContentsOfFile:path].CGImage; CGSize fixedSize = animacja.frame.size; NSLog(@"wid: %f, heigh: %f", animacja.frame.size.width, animacja.frame.size.height); NSLog(@"%f", animacja.frame.size.width); richter = [MCSpriteLayer layerWithImage:richterImg sampleSize:fixedSize]; animacja.hidden = 1; richter.position = animacja.center; [self.view.layer addSublayer:richter]; } -(IBAction)animacja:(id)sender { if ([richter animationForKey:@"sampleIndex"]) {NSLog(@"jest"); } if (! [richter animationForKey:@"sampleIndex"]) { CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"]; anim.fromValue = [NSNumber numberWithInt:0]; anim.toValue = [NSNumber numberWithInt:22]; anim.duration = 4; anim.repeatCount = 1; [richter addAnimation:anim forKey:@"sampleIndex"]; } } Have you got any idea how to fix it? Thanks a lot.

    Read the article

  • How can I run an android frame animation without it skewing?

    - by GameDev123
    I have a small state machine that runs a series of frame by frame animations in an ImageView, in a nested hierarchy of layouts. There is more than adequate space to display each frame of the animation. Each frame of the animation is cropped to fit the minimum amount of area, in order to save memory. If a frame only contains 50x50 worth of pixels then the png is 50x50. There is no transparent padding to keep them the same size. The ImageView is directly within a RelativeLayout, and is anchored to the bottom left with some padding. The general idea being that the character in the animation performs some action, which results in individual frames of the animation growing or shrinking. The issue is that individual frames of animation are skewed, and there does not appear to be any way of preventing this. If I set the source of the imageview directly to one of the frames of animation, it displays fine in the layout manager. I have tried this with Adjust View Bounds set to true, false, and undefined. I have tried using the background and the src attribute of imageview to set the animation drawable, I have tried every configuration of layout manager and setting minimum/maximum size that I can think of, and it still stretches the character on various frames depending on the size of the source png. In essence, all I want to do is say "I want this ImageView to anchor in the bottom left and then display any frame that happens to be in it without stretching or skewing it in any way aside from that which occurred when the frame png's were loaded." Seems simple, but I have yet to come across any way of doing it. Here is the layout of the imageview as of my last test, I had to remove bits of the XML to get it to display but nothing pertinent: RelativeLayout android:orientation="horizontal" android:layout_above="@+id/MenuOptions" android:layout_width="fill_parent" android:id="@+id/AnimationLayout" android:clipChildren="false" android:minHeight="180dp" android:layout_height="fill_parent" android:layout_below="@+id/GameBarLayout" ImageView android:id="@+id/animatedImg" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="visible" android:baselineAlignBottom="true" android:minHeight="180dp" android:minWidth="200dp" android:adjustViewBounds="true" android:layout_alignParentBottom="true" android:paddingLeft="30dp" android:paddingBottom="10dp" android:src="@drawable/idle01"/ImageView /RelativeLayout Here is how an animation is set up: animationDrawable = new AnimationDrawable(); animationDrawable.addFrame(res.getDrawable(R.drawable.idle01), 16); animationDrawable.addFrame(res.getDrawable(R.drawable.idle02), 16); animationDrawable.addFrame(res.getDrawable(R.drawable.idle03), 16);

    Read the article

  • Starting an animation from the ViewModel in WPF/MVVM

    - by RandomEngy
    I'm writing a MVVM app and have started putting in a few animations. I want to call something on the ViewModel which starts the a storyboard. This blog had a promising approach to it, but it doesn't actually work. The IDChanged handler never fires for some reason. I also found that you could start animations on EventTriggers, but I don't know how to raise one on the ViewModel.

    Read the article

  • Android -- Change the AlertDialog Animation?

    - by borg17of20
    Hello all, Does anyone know how to change the in/out animations of an extended AlertDialog? I connot figure out how to do this. See below for what I have so far (it doesn't work though): public class PauseMenu extends AlertDialog { private Context myContext; public PauseMenu(Context context, int theme) { super(context, theme); myContext = context; } protected PauseMenu(Context context, boolean cancelable, OnCancelListener cancelListener) { super(context, cancelable, cancelListener); myContext = context; } public PauseMenu(Context context) { super(context); myContext = context; } @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub //super.onCreate(savedInstanceState); this.setContentView(R.layout.pause_menu); //this.getWindow().getDecorView().setAnimation(new ViewZoomAnimation()); this.getWindow().getDecorView().setAnimation(AnimationUtils.loadAnimation(myContext, R.anim.slide_in_bottom_newgame)); } } Thanks.

    Read the article

  • Android ViewFlipper + homescreen animation

    - by Tim
    I am trying to use a ViewFlipper and make it act like the home screen(The layout will move with your finger). Check out this for an example. I want to do this with a ViewFlipper that only contains two children so the opposite view should be shown on either side of the current view depending on which way the user moves their finger. This code works but only for 1 direction at a time. This is in onTouchEvent. case MotionEvent.ACTION_MOVE: leftView.setVisibility(View.VISIBLE); rightView.setVisibility(View.VISIBLE); // move the current view to the left or right. currentView.layout((int) (touchEvent.getX() - oldTouchValue), currentView.getTop(), (int) (touchEvent.getX() - oldTouchValue) + 320, currentView.getBottom()); // place this view just left of the currentView leftView.layout(currentView.getLeft() - 320, leftView.getTop(), currentView.getLeft(), leftView.getBottom()); // place this view just right of the currentView rightView.layout(currentView.getRight(), rightView.getTop(), currentView.getRight() + 320, rightView.getBottom()); Which ever of the bottom two lines I put last that direction will work correctly but the other will not. Here is how I set the leftView and rightView: final View currentView = myFlipper.getCurrentView(); final View leftView, rightView; if (currentView == meView) { Log.d("current layout: ", "me"); leftView = youView; rightView = youView; } else if (currentView == youView) { Log.d("current layout: ", "you"); leftView = meView; rightView = meView; }else { leftView = null; rightView = null; } Is it going to be possible to set it up so that the same view is shown on both sides of the current view?

    Read the article

  • Rotating a UIButton with a custom image (animation)

    - by Tiago
    Hi, I'm trying to rotate a button that I've connected to the controller from the Interface Builder. I've set it's image right from Interface Builder. I'm using this code on the method that runs when I click it: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2.0]; [UIView setAnimationRepeatCount:5]; updateButton.transform = CGAffineTransformMakeRotation( M_PI ); [UIView commitAnimations]; But this doesn't do anything. Can this be done, or should I create the button programmatically in order to get it to rotate?

    Read the article

  • Smoothing touch-based animation in iPhone OpenGL?

    - by quixoto
    I know this is vague, but looking for general tips/help on this, as it's not an area of significant expertise for me. I have some iPhone code that's basically an EAGL view handling a single touch. The app draws (using GL) a circle via triangle fan at the touch point, and moves it when the user moves the touch point, and re-renders the view then. When dragging a finger slowly, the circle keeps up and consistent with the finger as it moves. If I scribble my finger quickly back and forth across the screen, the rendering doesn't keep up with the touch motion, so you see an optical illusion of "multiple" discrete circles on the screen "at once". (Normal persistence of vision illusion). This optical illusion is jarring. How can I make this look more natural? Can I blur the motion of the circle somehow? Is this result the evidence of some bad frame rate issue? I see this artifact even when nothing else is being rendered, so I think this might just be as fast as we can go. Any hints or suggestions? Much appreciated. Thanks.

    Read the article

  • Core Animation not working on Leopard, working on Snow Leopard

    - by Nick Paulson
    Hi, I animate NSImageViews using its animator proxy. While testing my application on Snow Leopard, everything works as expected. However, on Leopard, none of the animations are functioning. In addition, NSImageViews don't seem to take into effect the alphaValue I set on them, whether through the animator proxy or not. The only way I can get them to disappear is by setting their image to nil. What is weird is that this all works fine in Snow Leopard, but does not work on Leopard 10.5.8. Any idea on why this may be occurring?

    Read the article

  • Slide expand animation in android.

    - by Priyank
    Hi, I have a simple list view listing results in android. Upon click of each item, I would like it to slide down expand and show the content. Is there an easy way to do this in android? Any help will be appreciated. Cheers

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >