Pulling animation on ios - core-animation

Please i need to know how can i do pulling effect using multiple image.
Those images must follow a specific path each image beside another one like a train.
is there any solution than looping.
what i wanna exactly is those image move simultaneously.

You want to use a CAKeyFrameAnimation, using a CGPath to describe the path you want your objects to follow.
You would create a series of animations, each using the same path, but with different beginTimes. The tricky bit is how to use beginTime. You want to set each animation to a time in the future using code like this:
anAnimation.beginTime = CACurrentMediaTime()+delay;
When an animation is part of a group, beginTime is expressed as a number of seconds from the start of the group animation. You can't group animations on different layers, though, so you need to start each animation independently. To do that, you set beginTime to a time starting from CACurrentMediaTime().

Related

How can I render 19451 circles on Rect Native map efficiently?

I have 19451 points exported by coordinates in a JSON file. I am trying to render them in an efficient way on the map with circles. How can I achieve this? It is the first time I am using https://github.com/react-native-maps/react-native-maps with expo, so I am not that experienced in using maps services. I don't even know where to start from. I was thinking of something like rendering the points dynamically, based on whether one point is to be found in the region of the map that is currently shown on the screen, although I have no idea how to actually achieve this. The first thing I tried was to obviously render them at once: it takes ages and it is very buggy!
You have several options:
Use some kind of clustering when there are multiple circles in the same area, for example when you're zoomed out. Have a look at react-native-maps-clustering. Performance wise is decent enough but it may lag on older devices.
When you go over a zoom level you can limit the number of circles you draw, I guess they overlap anyways. When your limit has been reached, you can display some warning to let the user know that the number of circles was limited and he should zoom in. From my experience, drawing max 50 custom markers was the upper limit to avoid lag on older devices. With circles, that limit might be different.
Manually filter your data and decide whether the circle belongs to the current viewport (visible part of the map) or not.
Some code would help me to give you some more hints.

Rendering multiple objects with different textures, vertex buffers, and uniform values in Vulkan

My background is in OpenGL and I'm attempting to learn Vulkan. I'm having a little trouble with setting up a class so I can render multiple objects with different textures, vertex buffers, and UBO values. I've run into an issue where two of my images are drawn, but they flicker and alternate. I'm thinking it must be due to presenting the image after the draw call. Is there a way to delay presentation of an image? Or merge different images together before presenting? My code can be found here, I'm hoping it is enough for someone to get an idea of what I'm trying to do: https://gitlab.com/cwink/Ingin/blob/master/ingin.cpp
Thanks!
You call render twice per frame. And render calls vkQueuePresentKHR, so obviously the two renderings of yours alternate.
You can delay presentation simply by delaying vkQueuePresentKHR call. Let's say you want to show each image for ~1 s. You can simply std::this_thread::sleep_for (std::chrono::seconds(1)); after each render call. (Possibly not the bestest way to do it, but just to get the idea where your problem lies.)
vkQueuePresentKHR does not do any kind of "merging" for you. Typically you "merge images" by simply drawing them into the same swapchain VkImage in the first place, and then present it once.

UISegmentedControl custom images for each segment

I'm trying to customize a UISegmentedControl to use a custom image for each segment. I've done a lot of searching, but haven't had any luck with the solutions I've tried so far. This is the most recent post I can find, which is still fairly out of date now, and seems pretty hacky yet. Are there any better or more recent guides on how to do this?
Thanks
Unfortunately, UISegmentedControl doesn’t make it easy to set separate background images for each segment separately. If your control is always a known width, you might be able to make a full-size background image with the three segments drawn in, like this: (yellow][green][red) (where parentheses represent rounded corners), and then use -[UISegmentedControl setBackgroundImage:forState:barMetrics:] to set your image.
However, that solution isn’t very flexible if you want to resize the control later. You might be better off faking it with three adjacent UIButtons, or even subclassing UIControl to make a custom segmented control which can have a separate image for each segment.

Need to tell when UIImageviews overlap

I'm currently programming an app that deals with line graphs. I have three "dots" that allow the user to move the whole line or rotate it, one for the former and two for the latter. The problem that I'm having, though, is that sometimes the dots end up overlapping each other. If I try to touch one of the dots that rotate the graph when that happens, it just moves the whole graph itself, as if I'm touching the moving dot. What I want to know is if there is a simple way to calculate whether a uiimageview is overlapping another? Any help is appreciated.
Assuming they have the same superview:
NSIntersectsRect(imageView1.frame, imageView2.frame)
If they have different superviews, you may need to use -convertRect:toView: and friends.

Get size of an expanding circle in a CABasicAnimation at any point in time

I would like to know how I can get the diameter (or radius) of an expanding circle animation at a at any point in time during the animation. I will end up stoping the animation right after I get the size as well, but figure I couldn't stop and remove it form the layer until I get the size of the circle.
For an example of how the expanding circle animation is implemented, it is a variation on the implementation shown in the addGrowingCircleAtPoint:(CGPoint)point method in the answer in the iPhone Quartz2D render expanding circle question.
I have tried to check various values on the layers, animation, etc but can't seem to find anything. I figure worse case I can attempt to make a best guess by taking the current time it is into its animation and use that to figure where it "should" be at based on its to and from size states. This seems like overkill for what I would assume is a value that is incrementing someplace I can just get easily.
Update:
I have tried several properties on the Presentation Layer including the Transform which never seems to change all the values are always the same regardless of what size the circle is at the time checked.
Okay here is how you get the current state of the an animation while it is animating.
While Rob was close he left out two pieces of key information.
First from the layer.presentationLayer.subLayers you have to get the layer you are animating on, which for me is the only sub layer available.
Second, from this sub layer you cannot just access the transform directly you have to do it by valueForKeyPath to get transform.scale.x. I used x because its a circle and x and y are the same.
I then use this to calculate the size of the circle at the time of the based on the values used to create the Arc.
I assume what you're trying to get to is the current CATransform3D, and that from that, you can get to your circle size.
What you want is the layer.presentationLayer.transform. See the CALayer docs for details on the presentationLayer. Also see the Core Animation Rendering Architecture.