Best way to animate a spinning wheel thats responsive to touch events - iphone

I need guidance towards the right direction to take here.
I want to build a spinning wheel control where a user can select an element.
I want to accomplish the following:
Receive touch events that will rotate the wheel based on the finger position in touchesMoved
Magnify the image that is inside the selected image indicator when it passes through.
I was thinking of a core animation Basic Animation and animating the rotation.
Using an animation group and rotate it around.
Problem 1:
How do I sync the animation to the touch events.
Problem 2:
How will I know which image is the one I need to magnify with for example an CGAffineTransformMakeScale.
Is there a best practice for my problem. Esp. with performance in mind?
http://img24.imageshack.us/img24/8596/imagezy.png

You can achieve this by update the wheel for every touchmoved event.
For each touchmoved, touchbegin event, you can know the angle of the line from center of the wheel to your finger. You save your begin angle, then you will know the diff angle. The wheel can rotate depends on your finger by using angle.
you can enlarge the image icon by either of these two ways.
1. You can know which image icon angle in all the wheel, and you also know current angle of the wheel. So, if the image icon is between the right angle. Ex. if wheel is at 45 degree, then icon at -45 or 360-45 degree will be enlarged.
2. check the y origin of each image icon, if the image icon origin y is above threshold.

Related

Modifying smooth curve with Anchor points

I wish to emulate this effect in Xcode with Swift. After some research I managed to find some articles about drawing smooth curves using a set of points .But I am still unclear about how I could to dynamically modify curves when the user touches/holds the screen.
Question :
I know how to make a smooth Bezier curve, but how can I add gesture recognizers such that by dragging the curve its shape changes.
I only need someone to point me in the right direction. Is there a guide or article in particular that could be useful?
Create transparent ControlPointView for every control point of the curve with a size of 50*50pt, so that users can easily tap them and drag.
Add a small image in the middle of every ControlPointView, so that users can see where the control point is located.
Add UIPanGestureRecognizer on every ControlPointView and handle it in view controller.
Use centers of control points to rebuild UIBezierPath every time gesture recognizer's state is changed.

How to use rotate 3D in a matlab figure without losing focus?

So basically, I'm using matlab to simulate several lines and points in a plot3 figure.
When I'm trying to navigate the result using then "pan" command, I want to focus on a particular part, but EACH time I try to rotate around the point I'm focusing, I lose the focus and it rotates around the center of the figure. Is there any way to keep the focus when switching between commands to rotate 3d?.
When I use zoom and then I use pan, I don't lose the focus.
When I use pan and then I use zoom, I don't lose the focus.
When I use pan and then rotate 3d, I lose the focus, and I rotate around the center of the plot/figure.
When I use zoom and pan and then rotate 3d, I lose the focus, and I rotate around the center of the plot/figure.
Is there something wrong with the rotate 3d command? Is there an option I can change?
Thank you!

color wheel return value

I have an image of a color wheel that spins on touch. What I cannot figure out is how to determine which color it lands on when rotating stops. What is the easiest way to accomplish this? I am a newbie so sample code helps. Ideas?
Please help.
You know what angle the wheel stops at when it finishes rotating, right?
If your colors are evenly divided along your wheel you can use that to determine the offset from the starting position, which divided by the number of colors will tell you which color is at the top. Offset this again if your wheel's position marker is not dead top.

iPhone animation: how do I animate the filling up of an area?

Consider a circle. Now consider a radius of the circle, drawn from the center of the circle towards the right. Now imagine that the radius is rotating about the center of the circle, sweeping out an area as it rotates. My problem is: I want to use iPhone's animation techniques to fill up the swept out area with a different color from the background area of the circle, as the radius rotates from 0 degrees to any chosen number of degrees about the circle.
I've looked through the Core Animation API, KeyFrame Animations, etc. but I am not able to find out how to do this. Any hints will be most welcome.
Thanks,
Sandeep
Check out CAShapeLayer. It lets you animate between two Core Graphics paths, which can be as complex as you want. In this case, you might want to animate between a path which defines a thin filled wedge and a filled wedge that covers a larger angle of the circle. You may need to use a CAKeyframeAnimation to make sure that it is animated in the sweeping motion you desire, and in the direction you want.

Moving a UIView along a CGPath according to touch position

I have a line graph I've drawn in Quartz, and a UIView 'bubble' that I'd like to ideally pop up when the user touches the single plot line, and moves their finger along it. The bubble displays some extra graph information.
I'd like to 'attach' the UIView to the CGPath plot, but I'm having trouble conceptually figuring out the best way to do this. I know you can animate a view along a CGPath, but this doesn't seem to work for me, because the user needs to 'scrub' along the graph themselves with their finger rather than any automatic animation.
Does anyone have any suggestions of a good approach?
Maybe you don't need to animate it. Touch events fly by pretty quickly -- maybe if you just move the view to the appropriate location relative to the touch without animation the move will be smooth enough. If that's not good enough, you'll have to animate along the graph segment from the current location of the view (see CALayer presentationLayer) to the desired location. The key is that you'll be animating every time you receive a touch event (and any previous animations would be cancelled).
Like Neil said, your best bet is to just move with the touch events, it will look smooth if all you're doing is moving a view. Use [aTouch locationInView:view] to get the touch's position, then find the closest point on the path (maybe use the x value and look up the y value on the path for the x).