Beyond Animations with Core Animation - John Sundell, Swift by Sundell

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Applause] [Music] [Applause] [Music] so hi everybody my name is John and I should try to say also Bonjour Madame Monsieur Bienvenue ah mah presentation is that good alright awesome excellent so I work as an Iowa's freelancer and I also do a bunch of stuff like a weekly blog post about Swift called Swift bison Dell I also do a podcast which is also called Swift bison Dell because I don't have any imagination when it comes to naming and I also started a new podcast last week with my good friend gear Ambo called stacktrace so a bunch of different different stuff I really love sharing things with the community and I'm a huge fan of Swift so I'm very very happy and I want to thank Greg for inviting me here to talk to fellow Swift enthusiasts here in Paris it's always really really cool so my topic today is going to be about core animation but we're not actually going to talk about animations today and that might seem a little bit strange given that the framework I'm going to talk about literally has animation right there in the name alright but instead what I want to talk about is a little bit how we can use core animation for some really cool custom rendering how it can be a great tool for different types of UI and shapes and different kind of things that we might need to do in our apps so core innovation I think is a framework which some people might have used kind of indirectly or without really knowing it you might be like accessing the layer property of a view and setting like the border color or something and some people might have really dug into it and used it for like really complex animations but I think that it differs a lot like kind of what kind of experience you have with core animation so today I hope to both kind of show you some things that you might not know you could do with core animation or to use it in some new interesting ways but before we dig into the fun stuff I thought it would be a good idea just to kind of take a look at core animation again kind of how it fits into Apple's overall rendering pipeline in case you haven't worked with that much before so as you know you know when we're building apps and working you know against the top-level UI frameworks that apple provides we are using things like UI kid watch kid and app kit depending on the platform and of course this is where we get access to all the common tools that we need like handling images or rendering labels or even building custom views and custom subclasses of UI view or ennis view but you might know that these UI frameworks they don't actually do much rendering they just kind of handle the events and they act that's the kind of top-level API instead you've got this like chain of rendering that kind of builds up the stack so under these UI frameworks on all the different platforms you have core animation so it's kind of like a common denominator for both the Mac and iOS and watch which are all very different when it comes to the UI and the top level api's but they are all relying on core animation underneath and what does core animation do then well its job is really to organize all of the content that we want to render into layers so that we can you know render them in a nice way and to render them using transactions and those can either be animated if we are like performing an animation or they can be instant if we just want to update a background color or set a frame or something like that and on iOS on the Mac is a little bit more complicated but on iOS each view has a layer that backs it and the layers can also make up a hierarchy so one view can have multiple layers but core animation doesn't actually do any rendering either in order to actually start pushing pixels onto the screen we need to step down to metal and this is where it gets really fun you know when we get to deal with things like draw calls and shaders and actually do math you know that's fun right and that's kind of where we program the GPU to actually display all of the content we want to display so we're not going to go that far today we're gonna stick here in the middle in in a core animation land but this is kind of how the rendering pipeline looks from like a bird's eye perspective and one thing I really love about the way Apple usually designs their technology stacks and their frameworks is that you have this option of stepping down to a lower level if you need to but you don't have to you know for 99 percent of all of the tasks that we've got to do in an app in a typical app we can just use the UI kit or we can just use app kit we don't need to step down to the lower levels but sometimes we we want to or sometimes we need to so one way of kind of describing this pipeline is that if we go more to the rights we go more lower level which gives us more performance or potential for higher performance it also gives you more potential for screwing things up but that's another part of the story another kind of way to describe this pipeline is that the more we go to the right the more scary things become all right I mean you are kid these days is pretty nicely annotated for Swift but once we go down to core animation we start seeing things like you know just very string based api's maybe not so nice annotations and things like that so it can get a little bit scary but hopefully today we're gonna make it a little bit less scary so today I want to talk about four different areas in which we can use core animation that are not related to animations per se but are more solving kind of problems that we might face when building apps and how we can use core animations and interesting ways to solve some of these problems so let's dive right in is let's start talking about shapes so shapes are becoming more and more a very important part of modern application design you know back in the good old days in the you know iPhone the iOS 3 and 4 era we had this like super highly textured UI so no there was the green felt in Game Center and wood and all this kind of stuff it was very hard for a typical person to kind of design apps because you need to be like an artist you know going to Photoshop and you know paint something really complicated but these days it's a lot simpler it's also harder in a way but because you need to think more about composition and stuff but the actual creation of these assets is way simpler because we're using more of these kind of simple shapes to create icons and to convey things like States where we can just fill in a shape in order to show selection for example so this presents us with some pretty interesting opportunities as programmers because usually traditionally at least we've always been using images as assets for things like icons and backgrounds and things like that but now when we have shapes as a more and more important part of our apps we can actually take control as programmers and bring things into code and that is always really exciting so let's take a look at how we can use core animation to draw shapes well we're gonna start by creating an instance of C a shape layer and if you're sitting way far in the back you might want to come a little bit closer if the text is too small I don't know maybe you can see on the displace there on the side so we have a CA shape layer that's a specialized subclass for rendering shapes that is provided by core animation and in order to get this layer to be displayed on the screen we need to add it to our view hierarchy so in this case we're going to add it to as a sub layer of a layer we already have which might be coming from one view controllers view so to start setting things up we're gonna start by setting the stroke color and the fill color of our shape so in this case we're going to say that we want our shape to be white the lines to be white and want to fill it out with blue so this is kind of the setup process now let's actually start drawing so to do that we're going to use a path in this case we're going to use an instance of cg mutable path and we're going to start by adding a rounded rectangle so to do that we're going to just use the bounce of the view and we're going to set some corner with and corner height so if we now assign this path back to our shape and we run this little code we're gonna see a rounded rectangle in the in the rendered results and that's pretty cool we just got started we've been we're drawing shapes okay we're warming up that's good stuff but the cool thing here is that we can use a CA shape layer to compose multiple shapes into the same layer we don't need to do what we do with views usually and create this like really complex hierarchies we can just keep drawing so we're gonna keep here and just add an ellipse to this path and then assign it back and that way we're gonna get a circle inside of our round rectangle and we can even use things like transforms to manipulate our shapes so in this case I'm going to add a rectangle but then I'm gonna apply a transform to it so that I'm scaling it by 0.5 in both the X and Y axis ending up with a rectangle in the top left corner of the screen so this is kind of how we can get started drawing shapes using core animation but now let's actually do something useful so let's say we're building an app where we want to have some kind of document icon we might be building like a document browser or something like that so when you first look at this icon you might be thinking well it's time to go to my designer and say hey can you please create a document icon in sketch export it to PNG or wait you need at 3x also no we don't need to at 1x anymore except for the map it gets complicated right but you know what we can do we can actually just draw this because if we think about it this is just lines and they're just like connected lines we can draw this in code so let's take a look at how we can do that well we're gonna do the same thing as before start by creating a shape layer we set the stroke color to whites in this case and then we're gonna create some constants one for the size of the icon and one for the fold and set that like in set right here how much we want to fold it and this is a tip that I have is like if you want to do this kind of programmatic drawing it's usually a good idea to move things out into constants that way you can play around with the values to see what kind of looks good so you don't have to go through and update all of your code now we're gonna start by creating a path again just like last time this time our path is gonna be a little bit more complicated it's gonna look like this now if you've never done any kind of programmatic drawing before this might look like really crazy but you get used to it pretty quickly and you can even use tools like paint code to draw these things in visually and then generate the code which is pretty cool but anyway what we do here is we start just at 0 and then we just move around the shape ending up at the same point again and then to add the fold all we really need to do is move up here again and then draw down and draw to the right and we have our document shape so all we need to do now is assign its back to our see a shape layer just like before we have an icon and I think that's pretty cool this is like an icon completely generated in code so now you might be thinking looking at this well this looks awfully complicated it sounds better if my designer just does this in sketch right I can just do something more fun like write unit tests well the thing is that there are some really good advantages to doing it this way first off is let's say we want to add another state to this icon let's say if the user selects the documents we want to fill it out with blue in order to do that if we have a PNG we either need to like colorize the PNG but that's kind of messy and not very you know nice to do but what's more common is to just generate another asset right now we have two assets to manage we need to make sure they have both the same size maybe Apple launches the new screen sites we need to like export a new version oh we forgot to export a selected version you see what I mean right when we are using programmatic icons well we just update the stroke and fill color and we're done so I think it's really pretty cool it's not a silver bullet there of course a lot of instances where drawing icons is not really feasible because there are too complex but for more simple icons like this I think it can be a really cool way to do it another way you can use shapes is to create really cool kind of onboarding experiences and as part of your UI an app that I'm currently working on which is called multi mate we are using shape layers - as part of our onboarding process so when the user first launched the app we generate this spotlight effect to zoom in on certain parts of the UI and then move it around in this nice way this might look like it took a while to build but it was super super simple all we needed to do was to create a shape layer which was the rectangle of the screen and then a circle cut out where we want to highlight the information and then just animate over that shape super easy it was just like a couple of lines of code which is I think very cool it looks very nice and it is very very simple so shapes can be a very very powerful tool and the good thing about them is that they can be programmatically changed so we don't need to wait for a designer to update an asset we don't need to man these things in fact we don't need any assets at all we can just keep it in code which is you know very nice for us as programmers another nice benefit is that we have things that are resolution independence that both means that if Apple launches like a new at 4x screen on the next WWC well that would be crazy right that means that we don't need to find all these old Photoshop files and update them for the new resolution they will already work out of the box also it means we can play around with things more for example we want might want to generate a smaller UI for like the iPhone se and a larger UI for the iPad pro and we have the freedom to do that if we have in resolution independent assets finally one thing you might be concerned about when doing this approach is performance because if you've been doing for example core graphics based rendering before with these shapes you might have been running into performance problems because core graphics is done on the CPU it's you know not very performant if you need to draw big things very often but the good thing about using CA shape layer is that it's really really efficient core animation renders out a process for a lot of things which means that your own main cue is free to do its own work and it also makes heavy use of the GPU to offload a lot of the CPU bound work so you get really highly efficient rendering but you can still do custom drawing which i think is pretty cool so that shapes now let's move over and talk about replicators replicators I think is like a little bit of a hidden gem in core animation it's something that you might not initially want to hear about them kind of think about what they might be useful for for I I spent a long time just looking at this API I was like who would use this but it turns out that they are pretty cool and you can use them for some interesting things so what are replicators well they're a simple way to take a single copy of a layer and just replicate it multiple times and you can replicate any layer so in this case I'm just replicating a circle three times let's dive back into our code and let's take a look at how we can use a replicator layer so we're going to start by again creating an instance in this case is see a replicator layer and the core property that you use for replicators is the instance counts it's how many Pease the replicator should create in this case we're setting it to three so we want to create three copies of our source material for source material we just want to use a normal CA layer in this case we're just going to create it we called square and we just set its frame and its background color to blue so a very simple layer so to make the Replicators start replicating this all we need to do is to add it as a sub layer to the replicator and it just starts doing its work so if we now run this code and take a look we see a single square no that was not what we were expecting right we were speaking three squares well the problem is that we are not moving them so they're all there they're actually three squares there but we don't see them because they're all rendered at the same coordinates so we need to apply a transform so replicator layers provide this property which is called instance transform where we can set a transform to apply to each instance in this case we're going to move each instance by 50 points so if we now update we can actually see all of our three squares which is pretty cool another really interesting feature of replicators is that you can do color manipulation so you can change the blue offsets of each instance here I'm changing it by 0.3 and what happens is that each instance get a darker shade of blue when I update so again this is something that might not seem super useful at first it's like ok that's a cool API I guess but you can build some really interesting things with it so here are two examples for example you might want to build like a really cool custom background where you have like a like different shading on these rocket I love the rocket emoji it's like the best emoji but here I'm like coloring it with lots of different colors or you might want to build like a custom loading spinner like on the right which might look like really complicated when you look at it but it actually turns out with replicators it's very very simple let's actually dive into that loading spinner a bit more and take a look at how that was built so these are a lot of different there is actually 20 different small little pieces here but it turns out that they are all just a single little shape that are replicated multiple times so there's just a shape layer our good old friend shape layer that we know now so we're just gonna call this this back again and just set the size on it and in this case I'm also going to modify the anchor point the anchor point is like where you want to apply the transform to the layer so in this case I'm applying it to the bottom okay so we know this already setting the path and the fill color you know we've we've been through that so we're good we know that we can set the path and the fill color on the shape and that's really all we need for the shape itself now let's get to the magic let's get to the replicator so we create a replicate layer just like before and we set the instance counts in this case 20 so in order to fill out the whole circle with these little small little pieces we want to calculate the angle which we should rotate each instance so I'm gonna use the full circle that is you know 2 2 times pi and radians and then I just divide that by the number of instances that I have I then use that angle to create a transform and I set that as my instance transform and then I set the size of the replicator and I'm done and I think that's pretty cool this like this spinner which you know look quite complex it's really just under the hood quite simple a single shape that is just replicated 20 times so now if I just add that shape ask the replicator then I'm finished and I can just go ahead and ship my new cool loading spinner which is way cooler than UI activity indicator view all right so replicators they are pretty cool and pretty nice you can create multiple copies of the same layer and very conveniently you can apply transforms and caller manipulations and that's really all you can do and that might seem really limiting but you can do so much with these two tools and because you can replicate any layer you can even replicate other replicators you can turn this into replicator ception and imagine just what you can do with that you can do like 3d things and replicate it's really cool and again we don't have to worry so much about performance because we've got core animation has our back we have really highly efficient rendering we'd see a replicator layer again out of process and a lot of use of GPU so that I'd the CPU is free to run our own code awesome so next up let's talk about masking masking is something that you probably have used a lot of apps use masks to create like round images and things like that but with core animation you can go a little bit further and you can create some really cool masks with that are pretty complex but they're very easy to set up for example let's say we want to create like a social networking app for dogs you know it's like Facebook but for dogs it's gonna be huge my dog really likes it this is my dog and we might want to generate like a chat bubble here with the dogs profile picture you know it's really important have a good profile picture when you're a dog so how can we do this in core animation well we can use masking for these type of things and here's just another example I want to show you in code of how we can use masks in a pretty nice way so we start by creating a CA layer that's gonna act as our mask and then we're gonna load an image in this case I'm gonna load a swift icon I'm gonna set that as the contents of my mask and I'm just gonna update the size of the mask as well then I'm gonna create a gradient and this is a little bonus bonus point here that you can use core animation to very easily create gradients as well which is pretty cool and then I'm going to just set some colors on this gradients some just random colors and then I'm gonna update it hmm it does anyone is there anyone here in the audience who can read you eye color no alright so this is gonna be a surprise then so what do we end up with here we end up with a swift icon with the colors of France isn't that cool yeah it's the best version of the Swift icon yet right yeah awesome so those are some of the things you can do with masks but of course you can do so many more things so you could use masks to create this like slanted images using like a shape layer so you could create a shape layer that asks is your mask and that add that to an image and you get this really cool effect you can also use it to apply gradients to text so if you have a text layer as your mask and then a gradient layer in the bottom then you can get this nice effect you can also use it even to do really interesting things where you are using at one image as the mask for another image talk about inception here I have a Space Shuttle that is being masked by Saturn and to do that well you just create a mask you set the contents and then you assign the mask back so masking is pretty cool to using it you can crop layers in many many different ways and the good thing about that is that any layer can be masked so you can use any layer you want for as a mask or apply a mask to any layer and you can also use any layer as a mask and again you probably know now what the last point is going to be is highly efficient right it's really efficient rendering using any CA layer which is pretty cool all right so we've now reached the last point and the last point might be a little bit surprising because I want to talk about game developments you might be thinking okay what does game development had to do with core animation and why why would anyone want to use core animation for building games I mean we have all of these game engines and tools that our disposal already like really high-powered cross-platform frameworks like unity and unreal and we have Apple's own tools for building games like sprite kit and sync it so why would anyone in their right mind use core animation for games it's kind of sound silly well it turns out that we've been talking a lot about performance in this talk and how everything is kind of all it's highly efficient it's highly efficient well it turns out for games being highly efficient it's really important and core animation is really efficient at doing some really core things that we need for games like rendering images and textures creating shapes and using replicators in ways like to create platforms and things like that and of course we haven't talked so much about animations today but core animation is well really good at the animations so that is also a great thing when it comes to games but we wouldn't necessarily just want to build a game using core animation directly because we want to have some kind of game engine to work with just like we wouldn't start an app tomorrow and build the app from the ground up with core animation we want to use UI kids so does that mean that we need to build a game engine using core animation well the good news is I have already done that and it's called imagine engine and it's a project I started last year to kind of create an alternative game engine for Apple's platforms because I love building games but I got a little bit tired of using sprite kit because it's close source and it was kind of hard to debug performance problems and things like that so I thought let's use core animation which is a really highly efficient and really powerful rendering tool and build a game engine on top of it now I could do a whole talk about imagine engine trust me but I don't want to instead what I want to do is I want to show you a quick demo of what it's like to build a game powered by core animation do you guys want to see it alright so let's jump over to a playground and do a little pray prayer for the Xcode god that you know the playground will actually work today let's see it's in full screen mode so starting good oh here we go there we are all right I'm gonna do this little magic trick perfect maybe I should make it a little bit bigger is this good it's okay perfect alright so what do we have here well we have a playground and here I've just created a little bit of boilerplate where I'm creating a scene which is what game engines usually use as kind of that's their version of the view controller it's like a way to group together content like a level or a menu or something like that and then I'm creating a game instance which is really like running our game and then I'm assigning that game's view to our playground page live view so we see the game actually running here on the right is a very exciting game it's probably gonna win many awards I call it black it's great but now let's actually make it a little bit more exciting we're gonna build a game today called asteroid blaster which is gonna be about blasting asteroids alright so I'm gonna start here by just creating some ground now one type that imagine engine has is a block a block is basically a way to create these more platforms and textures that are tiled so that you can easily create different shapes and different sizes of blocks without having to tile and stretch the textures because that looks very ugly so here I'm creating a block which has the size of the of the width and then 128 points high and then I'm just you know positioning it in the scene and I'm adding it to the scene as a child now the cool thing about blocks here is that if I wanted to experiment and make the block taller I can easily do so I can say like it's gonna be 512 instead well the the engine doesn't have to scale the texture it can just create more instances of it now now you might be connecting the dots here you know what did we learn about just a couple of slides ago that could create multiple instances replicators right and that's actually what this is using under the hood it's just using a C a replicator layer to actually create this very highly efficiently so to show you that that actually is true what I can do is that I can set a debug fly a flag here to show all the layers and you can actually see that all these are all the same see a layer just being replicated multiple times which i think is pretty cool alright so let's move back now again to our to our previous size of the of the blue of the ground because otherwise the game is gonna be a little bit hard if their ground is all the way up here alright so where the ground now let's start creating some asteroids so to do that I'm gonna use imagine Jin's timeline API that enables me to repeat a text repeat a closure with a certain interval now this is something that you might normally use like Grand Central Dispatch for but in a game you want to drive more logic based on the rendering rate of the of the of the engine over the game so you don't want to necessarily use something like Grand Central Dispatch so I'm gonna say that every two seconds we're going to create an actor which is like an active game object and I'm just going to use that asteroid texture for it set its position to X&Y so right now is just being rendered up here in the top hemisphere not very dangerous at the moment but we can start making them move down so let's do that so we're gonna tell the asteroid to rotate by two times pi and then set a vertical velocity on each asteroid so now we see a we're gonna start seeing some asteroids falling down and you can see they're also layers so they're just being rendered they're using the layers as well it doesn't look very realistic at the moment because they're just falling through the ground right so we need to add some explosions I think what do you guys think explosions are cool right every game needs explosions so I'm gonna start by creating a extension on the actor class which adds an explode method that's going to be really useful in this game and what it does is it just creates another actor called explosion it sets it to the same position it runs an explosion animation and then when that is done it just removes itself and it removes the host actor as well so what I can do now is that I can add a collision observation so that when the asteroid collided with my ground block then it explodes so now if we run this we can see boom I have to make the sound effects myself so it's a little bit like boom you know budget budget game but you know it's fine right so we need some imagination all right so now we have these you know crazy asteroids like destroying our planet we can't have that so we need to have a way to defend ourselves so to do that I'm going to add a observation on the clicked event and the reason it's called click the not tapped it's because since core animation is cross-platform imagine engine is also cross-platform so you can run the same game on iOS TV OS and Mac OS so now if I go here and play this game and we click it we can see that the things nothing happens well that's great right maybe it's the playground that is not updated yet let's see No nothing happens asteroid events clicked observe asteroid explode yeah it should be oh you know what I put it in the wrong place I put it in the closure inside of the explosion that you know that obviously doesn't work it has already exploded demo effect it always something has happened but that's how you know it's real it's not a pre pre pre prepared boom now now we exploded yeah now we're now we're talking all right so we're out of our little game here and it's pretty cool we can you know explode some asteroids and it's all working pretty nicely so here is kind of a cool benefit of using core animation for something like this since core animation is so optimized for rendering such a large amount of content just think about how much content we're rendering in an average app these days we have maps we have collection views we have all these kind of things so it's really good at managing all these types of objects so if I want to go really crazy and implement like an ultra hard mode for my game where I'm like creating an asteroid every 0.2 seconds like 10 times the more asteroids this we're gonna give me ten times better reviews on the App Store right so now it's gonna be like I have to really keep up here you know and the cool thing is that the framerate is still really good because core animation is made to handle that kind of thing you don't have to worry and you get really even performance characteristics so that's imagine engine and that's how we can use core animation to build some games which i think is pretty interesting so I show you now a pretty simple example but of course you can use it to create really sophisticated games as well in fact I'm using core animation right now to create an Imagine engine to create my new game rebel sendou which is running here on the right together with some of my friends and we also made some prototypes with like really large amount of objects and they're all you know animating in this scene here in the middle there's over 10,000 objects and they're all rendering at 60 frames per second and again this is not something I can take credit for its core animation it's like wow just how powerful and how fast it actually is so we talked about four different areas in which core animation can be really useful for creating custom shapes for icons and animations and tutorial screens for things like replicators to create loading spinners or interesting backgrounds and different kind of things we've talked about masking how that can be used to create like new custom ways to render images and to create the gradient based labels and things like that and finally how you can go a little bit crazy and even use core animation for game developments so that's all I had for you today I hope it was interesting and that I've inspired you a little bit to check out maybe some of these things in core animation again I'm not saying that you should always use core animation for everything use it whenever it's appropriate and whenever you can harness some of this power and you know whenever it can give you some benefits so if you want to follow me online I'm at Johnson Dell on Twitter I usually tweet a lot about Swift as you can probably imagine I also run a weekly blog called Swift bison delcom and you can find imagine engine and a lot of other open source frameworks on my get up page merci beaucoup thank you very much are you drunk thanks and I will also say the slides will be available later this week as well as a lot of sample code and I will also write in more detail about this on my blog as well so questions yeah where is the ball and he's throw the ball that seems like the fun part hello hey just a quick question about the game engine yes asteroids so you use CIA animation to animate them it's not like you don't have a customer it's a custom animation controller yeah because it's based on the display display link yes exactly okay so basically all the collision things are made using the actual presentation exactly exactly so it's using the internal game objects position not the actual rendered position because if you are dropping frames for some reason we try not to drop frames but if you do then you still want your game logic to work the same way right you still want this to be predictable okay yeah cool well there's a question there cool thanks thanks for coming it's great to welcome to Paris and everything else so thanks I wanted to ask how did that work out actually comparing it to sprite get your imagine engine that's cool that you've done that yeah how does that work out performance wise okay yeah so one kind of key reason why I started this project was that I was using sprite kit and a lot of games that was building and I realized that even though sprite kit is amazing it's a really great tool and I'm very happy that Apple has like provides something out of the box there's a there's a ceiling kind of to it where it's optimized for a different kind of games where you know maybe a little bit more simpler not so many objects and once you started building these like large levels and like this big like grand scale strategy games you know I saw really really poor frame rates because you know a lot of game engines they are linear and complexity when it comes to the amount of objects because they need to update each object on every frame and that's how sprite kit works for example for many things so with the imagine engine I tried to learn a little bit from that to create like a more like lazily update controller where things are only updated whenever they need to be updated and because core animation already does allow like rasterization and things like that and that it renders out of process and does all these clever optimizations can get some really good performance even with this large amount of objects so it's not Apple to Apple to compare sprite kit with the match engine because spike it also has a lot of features imagine engine doesn't have but in terms of just sheer amount of objects I think image engine performs really well great so there's no physics engine built in and instead you can it has a plug-in system so you could take like something like box2d I'm going to plug that into the engine if you want to alright yeah it provides some like lightweight physics like the velocity but that's just like linear velocity it's not like real physics and it also provides like a collision API but that's also just hitbox Tech's testing instead of real like coalition testing like physics yeah the cool thing about it so I'm using it also a little bit as an experiments for myself because one thing I've seen with some of my source projects is that they tend to revolve very much around me and I don't want that I want them to be more community driven and I want you know anybody to be able to pick it up so one thing I've really tried to do as much as possible is to encourage other people to contribute so whenever there's a new feature that I think of I don't implement them myself I put it up as a task on github so right now we even have I think 16 or 17 contributors to the project so I'm still working on it but hopefully even one day when I will stop working on it for some reason there will be enough people to kind of continue moving it forward I'll try to contribute awesome yeah looking forward to it yeah please do yes questions you can ask me about anything you want oh I'm not I'm not gay I'm not gay I can't promise that I will answer well one other thing I was gonna ask you when you're doing a lot of there join with the images did you do testing like for example I use a lot of core animation for icons and stuff like you're doing yeah and applications and sometimes you have to weigh out whether it's cheaper to draw it or to have the image already available yeah what point do you have some kind of criteria it's usually I mean if we're talking about performance or complexity or performance performance okay yeah usually I try to measure those things and you know if you still want to draw programmatically you can always rest her eyes so you could draw once and then save that image and you can you you know you probably already know but you can super easily do that using a layer you can tell the layer - rasterize so yeah I usually do that but mostly for me it's not hitting performance a performance ceiling is sitting at complexity ceiling where what I'm trying to draw is just so complex too much code you know and it's like the thing I showed with the document I think that level of complexity is great for shapes yes perfect but once you reach more like you know really custom like if you try to draw like the github icon I would probably not do that to shape you know that would be like pretty hard maybe this may be the Twitter icon like I don't know I've seen guys that can do though yeah he's like if you just do it a bunch of circles right yeah no worries thanks that was our question yeah down there hello hey we heard that you are gone right now it revolves a lot around coordination but it doesn't it's structured the code structure in a way so that the core animation doesn't like that those implementation details don't leak to the rest of the engine so there's a layer type alias that the rest of the ange engine uses and it uses some of the properties of the of the layer but it doesn't like there's it that's contained in like a very small part so if we wanted to like you know they're Swift on Android but it's not really practically used that much but let's say that Swift on Android becomes like a thing and a lot of people want to use it then I don't think it would be too much work to actually abstract that out into more like a rendering protocol in fact I've been working on Imagine engine for like three years or something like just on-and-off not every single day I actually have a day job so but in an initial version I actually had a protocol like a rendering context but I did to actually just use core animation directly because I could make more assumptions about the rendering kind of pipeline instead of having to code very defensively because whenever I have a protocol I want the code pretty defensively against that because you never know how it's implemented right but yeah to answer your question I think it shouldn't be too hard definitely doable another question all right maybe you will have more questions after some beers I don't know that usually what happens is that's the point but thank you again so much for having me and thanks for listening and [Applause]
Info
Channel: Algolia
Views: 13,078
Rating: undefined out of 5
Keywords: swift, swift paris, meetup, algolia, john sundell
Id: J-rruNKcY0Y
Channel Id: undefined
Length: 42min 18sec (2538 seconds)
Published: Wed Mar 21 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.