On Friday I received the opening and closing slides to include on my presentation for the upcoming talk at Interaction South America 2015 in Cordoba, Argentina.
The opening slide has the title of the talk, the author’s name inside an hexagonal shape with rounded corners in the middle of the screen and some information at the footer.
Everything is laid over a two color background spilt horizontally in the middle. There is also a transparent pattern and a stripe at the top.
They sent the slide in Keynote and Powerpoint flavours, and I though: “what if anyone want to use reveal, there should be an HTML version of this… How hard can it be to build it?”
There was only one way to answer that question, by doing it.
The HTML is simple, with a title on an
h1 tag, the name of the author on a
p tag and a
footer, but framing the authors name on a rounded corner hexagonal box that is horizontally and vertically centred end up been a mathematical challenge.
There are two challenges overcome. The background and the rounded corner hexagonal box.
For the background I am applying CSS multiple background on the
- I start with a linear gradient to generate the stripes at the top;
- Then there are 2 svgs to generate the pattern. It has a blend more of multiply;
- I also am adding a little shadow at the top;
- and finally I paint half of the screen with a gradient stripe.
The hard part: a rounded corner hexagon
To explain how I created this hexagon I have to take you back to school.
The hexagon is a rectangle with two 45º rotated squares on each side. This means that if the height of the squares is x, the rectangle should be x times the square root of 2.
But it’s not that easy, I also need to consider the rounded corner of the squares. Trigonometry to the rescue, again. First I discover the size of the hypotenuse and I subtract the diference of the border radius.
I did all this math, so you don’t have to.
This sass mixing will generate a rounded corner hexagon and absolute position it at the center of the screen. You are welcome.
And here is the code altogether:
<h1>Keynote title</h1> <p>Author's Name</p> <footer>This is an HTML version of the opening slide for ISA 2015 presentations.</footer>
Will I use it?
Of corse not. Keynote is awesome to build presentations, plus it has the way underused flame effect that I alway try to sneak in all my talks.
I am sure there are way better ways to do hexagonal rounded corner shapes, this one doesn’t feel elegant enough. But it was good fun to build it.