The epicenter of change.
WWDC15
---
layout: post
title: WWDC 2015
description: Using opacity and colour to create and animate the WWDC 2015 invitation image
categories: [animation, tips, animations, transitions, wwdc]
customCSS: wwdc15.css
imageURL: /images/posts/wwdc15/wwdc15.png
home_image: /images/posts/wwdc15/wwdc15.png
tweet_text: Animate the WWDC logo with CSS
custom_header: posts/wwdc15.html
demo_url: https://cssanimation.rocks/demo/wwdc15/
source: https://raw.githubusercontent.com/cssanimation/posts/master/2015-04-30-wwdc15.md
---
Every year, Apple runs a special event for their developers. [WWDC](https://developer.apple.com/wwdc/) (Apple's Worldwide Developer Conference) is a chance for iOS and OSX designers and developers to learn all about what cool stuff Apple's up to and what to expect in the new versions of the mobile and desktop software.
With each year's event, they create a beautiful invitation. This year I was quite taken with the overlapping circles and shapes, and decided to have a go making it in HTML and CSS.
/pl/
## WWDC 15 invitation
Apple's icons often use overlapping colours and shapes, like a [iOS 7 Photos icon](https://cssanimation.rocks/demo/photos/). This year the invitation to WWDC included this image:
It's made up of a set of overlapping, semi-transparent shapes. Perfect to recreate with some HTML and CSS.
## Planning: HTML
Taking on a complex piece like this involves a bit of planning. For this example, I broke the layout down into it's parts.
The logo is made up of 3 sets of shapes. The basis is made up of 8 large circles, so I began by listing them out:
WWDC15
Let's add the CSS to position each of these circles. Looking carefully at the invitation image, we can see that the circle sitting behind all the rest is on the bottom-left. With this in mind we'll make sure the first circle in the HTML is rotated around to that position.
.one {
background: rgba(16, 63, 236, 0.75);
transform: rotateZ(225deg);
}
.two {
background: rgba(37, 172, 162, 0.75);
transform: rotateZ(180deg);
}
.three {
background: rgba(233, 124, 32, 0.75);
transform: rotateZ(135deg);
}
.four {
background: rgba(235, 67, 35, 0.75);
transform: rotateZ(90deg);
}
.five {
background: rgba(190, 28, 65, 0.75);
transform: rotateZ(45deg);
}
.six {
background: rgba(208, 57, 159, 0.75);
transform: rotateZ(0);
}
.seven {
background: rgba(150, 32, 198, 0.75);
transform: rotateZ(-45deg);
}
.eight {
background: rgba(95, 33, 203, 0.75);
transform: rotateZ(-90deg);
}
Each of these styles has a colour and a `transform` to rotate it into position. This animation shows how all the circles are placed at the top-middle of the screen, then rotated into place.
With the circles in place, we can style the other shapes. Firstly, a `squircle` is a `circle` but with a different border radius.
.squircle {
border-radius: 25%;
}
When we positioned the circles, we specified a rotation and a colour. Happily enough, the smaller shapes can use this same CSS too. We'll first need to give these `small` shapes some styles of their own.
.small {
width: 4em;
height: 4em;
left: calc(50% - 2em);
top: calc(50% - 15em);
transform-origin: 50% 15em;
box-shadow: 0 0.25em 0.5em rgba(0,0,0,0.2);
}
We set up these shapes to be smaller and position them a greater distance up from the middle. By using the same `transform-origin` trick, the `rotate` transforms from earlier will put them into the correct position without need for any more CSS.
### Small squircles
The small `squircle` shapes are the wrong angle. They need to be rotated a further 45 degrees.
There are a couple of ways we could do this. We could add an extra element to each `squircle` and add a transform, or we could use a [pseudo-element](/pseudo-elements/) in the CSS. Either way is good but I thought it would be interesting to handle it in the CSS.
First we remove the background, border and box shadow from the small squircles.
.small.squircle {
background: none;
border: none;
box-shadow: none;
}
We can now use the `::after` pseudo-element to create a new squircle within each, and rotate them 45 degrees.
.small.squircle::after {
background: red;
border-radius: 25%;
box-shadow: -0.25em 0.25em 0.5em rgba(0,0,0,0.2);
content: "";
height: 100%;
position: absolute;
transform: rotateZ(-45deg);
width: 100%;
}
.small.squircle.two::after {
background: rgba(37, 172, 162, 0.75);
}
.small.squircle.four::after {
background: rgba(235, 67, 35, 0.75);
}
.small.squircle.six::after {
background: rgba(208, 57, 159, 0.75);
}
.small.squircle.eight::after {
background: rgba(95, 33, 203, 0.75);
}
We should now have both the large circles and the smaller shapes in place.
## Content squircles
The last piece of the image is the two squircles that contain the content. Let's position them in the middle and give them a slightly transparent dark colour.
.large.squircle {
background: rgba(30, 7, 66, 0.65);
border: none;
height: 15em;
left: calc(50% - 7.5em);
position: absolute;
top: calc(50% - 7.5em);
transform: none;
width: 15em;
}
We can then rotate the first of these squircles (the one that sits behind the squircle containing the content).
.large.squircle.one {
transform: rotateZ(45deg);
}
## Adding animation
The original invitation image is not animated, but this site is called [CSS Animation Rocks](https://cssanimation.rocks) after all, so let's try some animation.
I'd like to make each of the sets of circles and squircles spin. To do this we can wrap each in a `span` and apply an animation to the `span` wrapper.
First we position these `span` elements so that they don't break the layout.
span {
display: block;
height: 20em;
left: calc(50% - 10em);
position: absolute;
top: calc(50% - 10em);
width: 20em;
}
This places the `span` wrappers in the middle of the page.
Next we will apply animations to each of these three `span` elements.
.large-circles {
animation: spin 10s linear infinite;
}
.small-shapes {
animation: spin 30s linear infinite;
}
.content-squircle {
animation: spin 20s linear infinite;
}
We're using the same set of keyframes each time, but changing the `animation-duration` of each. I've chosen 10 seconds, 20 seconds and 30 seconds so that they'll line up every minute.
With the `animation` property in place, let's put together the `keyframes`.
@keyframes spin {
0% {
transform: rotateZ(0);
}
100% {
transform: rotateZ(360deg);
}
}
This starts with zero rotation and finishes the animation having rotated around 360 degrees. [See it in action in this demo](https://cssanimation.rocks/demo/wwdc15/).
## Reusing CSS
This is a fun experiment in creating overlapping shapes using CSS but one thing that I found most helpful was the way the CSS was reused in some places. Rotating both the circles and the smaller shapes was handled by the same CSS, and the animations all used one set of keyframes. This can be a good way to keep your CSS files small and make sure they load quickly.
## Prefixes
When creating this example, I used [autoprefixer](https://github.com/postcss/autoprefixer) to avoid having to think about adding browser prefixes. Do keep this in mind if you're using `transitions`, `animations` or `transforms` in production.