Friday Game Design: Tsuvatt Run of Fury

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/8s6ZS_RJ5-0/tsuvatt-run-fury-game-design

Friday Game Design: Tsuvatt Run of Fury
Tsuvatt Run of Fury Game Design

abduzeedoApr 12, 2019

The 80s are definitely back after the amazing Stranger Things Netflix show. For some it never went away and some of the designers that I admire the most are masters at keeping the style of that decade alive. One of the cool things about it is of course the video-games. The pixelated badass action games like Double Dragon. We used to play that like crazy. Tsuvatt Run of Fury mobile game design is a project that brings back the 80s in style.

Tsuvatt Run of Fury was created and shared by Roman Sokolov a design and illustrator from Minsk, Belarus. For more information make sure to check out his Behance profile.

Game Design


Collective #507

Original Source: http://feedproxy.google.com/~r/tympanus/~3/i_jmQ5C4KhM/

C507_WOTW

Inspirational Website of the Week: Home Société

A delightful and refreshing scroll experience with some experimental elements. Our pick this week.

Get inspired

C507_tm

Our Sponsor
HTML Membership

Get lifetime free templates and plugins. Work with the best visual HTML drag and drop builder you’ve ever seen.

Try it now

C507_stackoverflow

Developer Survey Results 2019

The results of Stackoverflow’s survey that was answered by nearly 90,000 developers on how they learn and level up, which tools they’re using, and what they want.

Check it out

C507_quiz

Well-aimed?

Test how well you know CSS selectors with this interactive quiz by Paulina Hetman.

Check it out

C507_display

Digging Into The Display Property: The Two Values Of Display

Rachel Andrew takes a closer look at the CSS display property, a workhorse of a property that doesn’t get a lot of attention.

Read it

C507_city

Citybound

An amazing city building game that uses microscopic models to vividly simulate the organism of a city arising from the interactions of millions of individuals.

Check it out

C507_designtools

What design tools get wrong

An interesting article by Kilian Valkhof on the limitations of modern design tools.

Read it

C507_acctools

Color accessibility: tools and resources to help you design inclusive products

Stéphanie Walter shares some useful resources, tips and tools she regularly uses to build and check the color accessibility of products.

Read it

C507_Puplicsans

Free Font: Public Sans

A strong, neutral, principles-driven, open-source typeface for text or display.

Get it

C507_tunnel

Floating heart

A mesmerizing demo by Yuan Chuan.

Check it out

C507_toggle

How to create a custom radio switch in CSS

Claudia Romano shows how to create a custom accessible radio switch.

Read it

C507_structure

Rocking JS data structures!

Areknawo explores the new data structures in JavaScript that came with ES6 and shows how useful they can be.

Read it

C507_spider

Spider

A Chrome extension by Amie Chen that lets you turn websites into organized data without coding.

Check it out

C507_snake

Writing a Snake Game for the Terminal in Object-Oriented JavaScript (Node.js)

A tutorial by Tania Rascia where you’ll learn how to code a Snake game in JavaScript.

Read it

C507_uxconf

UX Agenda

A website that collects design conferences, workshops and meetups.

Check it out

C507_antimedium

Long-form websites and typography

A very interesting article by Eric Lawler on the art of creating stable, long-term websites and content.

Read it

C507_rickrolled

GitHub got rickrolled

Follow this tweet by GitHub and check out Muhammad Mustadi’s amazing GIF hacked GitHub profile.

Check it out

C507_env

Why you should use CSS env()

Harry Nicholls explains how you can use the upcoming CSS env() feature.

Read it

C507_amp

Google AMP lowered our page speed, and there’s no choice but to use it

An unsettling review of Google’s Accelerated Mobile Pages (AMP).

Read it

C507_perf

Perflink

Live JavaScript benchmarking where you can see results graphed out as you type.

Check it out

C507_nails

Nails

Teeny-tiny, satisfying scratchy hand. Simply epic. By Char Stiles.

Check it out

C507_chriscss

JavaScript vs. CSS – More control means more responsibility

Chris and Sadek talk about when is it best to use JavaScript over CSS, and should we all learn CSS as we learn JavaScript? Read the transcript here.

Watch it

C507_localstorage

Don’t trust the locals: investigating the prevalence of persistent client-side cross-site scripting in the wild

Some valuable insights into the vulnerabilities of local storage.

Read it

C507_sticky

From Our Blog
How to Create a Sticky Image Effect with Three.js

Daniel Velasquez shows how to code a recreation of the sticky image effect seen on the websites of MakeReign and Ultranoir using three.js.

Check it out

Collective #507 was written by Pedro Botelho and published on Codrops.

Designing Better Mobile Experiences for All of Your Clients’ Websites

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/b-Kb0Np6ID0/designing-better-mobile-experiences-for-all-of-your-clients-websites

As a design agency professional, you must design your clients’ websites with a mobile-first approach in mind. Mobile-first user experiences make it easy for visitors to find what they’re looking for quickly and encourage them to take action. Doing so can help increase conversions and boost sales. With this in mind, in this article, we’ll […]

The post Designing Better Mobile Experiences for All of Your Clients’ Websites appeared first on designrfix.com.

Art Direction For The Web Using CSS Shapes

Original Source: https://www.smashingmagazine.com/2019/04/art-direction-for-the-web-using-css-shapes/

Art Direction For The Web Using CSS Shapes

Art Direction For The Web Using CSS Shapes

Andrew Clarke

2019-04-11T13:30:16+02:00
2019-04-11T17:35:05+00:00

Last year, Rachel Andrew wrote an article that took a new look at CSS Shapes in which she reintroduced readers to the basics of using CSS Shapes. For anyone keen to understand how to use properties like shape-outside, shape-margin, and shape-image-threshold, Rachel’s is the ideal primer.

I’ve seen many examples of using the properties, but very few go beyond Basic Shapes, including circle(), ellipse(), inset(). Even examples using polygon() shapes rarely go far beyond them. Considering the creative opportunities CSS Shapes offer, this is disappointing. But, I’m sure that with a little inspiration and imagination, we can make more distinctive and engaging designs. So, I’m going to show you how to use CSS Shapes to create the following five different types of layout:

V-shapes
Z-patterns
Curved shapes
Diagonal shapes
Rotated shapes

A Little Inspiration

Sadly, you won’t find many inspiring examples of websites which use CSS Shapes. That doesn’t mean that inspiration isn’t out there — you just have to look a little further afield at advertising, magazine, and poster design. However, it would be foolish for us to merely mimic work from a previous era and medium.

You can find inspiration in surprising places, such as these vintage advertisements.

You can find inspiration in surprising places, such as these vintage advertisements.

For the past few years, I’ve filled Dropbox folders with inspiration and I really ought to move those examples to Pinterest. Fortunately, Kristopher Van Sant has been more diligent than me in compiling a Pinterest board full of inspiring ‘Shapes Of Text’ examples.

Shapes add energy to design, and this movement draws people in. They help to connect an audience with your story and make tighter connections between your visual and written content.

When you need content to flow around a shape, use the shape-outside property. You must float an element left or right for shape-outside to have any effect.

img {
float: <values>;
shape-outside: <values>;
}

NB: When you flow content around shapes, be careful not to allow any lines of text to become too narrow and fit only one or two words.

It often needs surprisingly little markup to develop dynamic and original layouts. My HTML for this series of five designs consists only of a header and main elements, figures, and images, and is often no more complicated than this:

<header role=”banner”>
<h1>Mini Cooper</h1>
</header>

<figure>
<img src=”mini.png” alt=”Mini Cooper”>
</figure>

<main>

</main>

1. V-Shapes

For me, one of the most incredible aspects of modern-day CSS is that I can create a shape from the alpha channel of a partially transparent image with no need to draw a polygon path. I only need to create an image, and then a browser will take care of the rest.

I think this is one of the most exciting additions to CSS and it makes developing art direction for the web more straightforward, especially if you work with a content management system and dynamically generated content.

Left: Without CSS Shapes, this design feels dull and lifeless. Right: Creating v-shapes makes this design more distinctive and engaging.

Left: Without CSS Shapes, this design feels dull and lifeless. Right: Creating v-shapes makes this design more distinctive and engaging.

To develop shapes from images, they must have an alpha channel which is either entirely or partially transparent. I needn’t draw a polygon to enable content to flow between the triangular shapes either side of my content in this first design; instead, I need only specify the URL of an image file as the shape-outside value:

[src*=”shape-left”],
[src*=”shape-right”] {
width: 50%;
height: 100%;
}

[src*=”shape-left”] {
float: left;
shape-outside: url(‘alpha-left.png’);
}

[src*=”shape-right”] {
float: right;
shape-outside: url(‘alpha-right.png’);
}

CSS Shape Example

Watch out for CORS (cross-origin resource sharing) when using images to develop your shapes. You must host images on the same domain as your product or website. If you use a CDN, make sure it sends the correct headers to enable shapes. It’s also worth noting that the only way to test shapes locally is to use a web server. The file:// protocol simply won’t work.

Generated Content

As Rachel explained in her article:

“You could also use an image as the path for the shape to create a curved text effect without also including the image on the page. You still need something to float, however, and so for this, we can use Generated Content.”

As an alternative to alpha channel, I can use Generated Content — applied to two pseudo-elements — one for a polygon triangle on the left, the other for the right. My running text will now flow between the two generated shapes:

main::before {
content: “”;
display: block;
float: left;
width: 50%;
height: 100%;
shape-outside: polygon(0 0, 0 100%, 100% 100%);
}

main p:first-child::before {
content: “”;
display: block;
float: right;
width: 50%;
height: 100%;
shape-outside: polygon(100% 0, 0 100%, 100% 100%);
}

NB: Bennett Feely’s CSS clip-path maker is a fabulous tool for working out coordinate values for use with CSS Shapes.

Adjusting the width of alpha images at several breakpoints allows the shape of this running text to best suit its viewport.

Adjusting the width of alpha images at several breakpoints allows the shape of this running text to best suit its viewport.

2. Z-Patterns

A Z-pattern is a familiar path our eyes follow when reading content from left–right, top–bottom. By placing content along the hidden lines which form a Z, these patterns help guide a reader along this path, from where we’d like them to start reading towards a destination such as a call-to-action. Z-patterns can be either discreet — implied by focal points or elements with higher visual weight — or made obvious using CSS Shapes.

The z-pattern created by driving a narrow column of running text between two shapes suggests speed and the fun people will have when driving this iconic little car.

The z-pattern created by driving a narrow column of running text between two shapes suggests speed and the fun people will have when driving this iconic little car.

In this next design, a discreet z-pattern is formed as:

The large image spans the full page width, the end-point emphasised with a right aligned headline.
A block of running text is formed by two CSS Shapes.
The thick top border on a figure acting as a footer completes the Z.

There’s no need for complicated markup to implement this design and my simple HTML includes just three elements:

<header role=”banner”>
<h1>Mini Cooper:icon of the ’60s</h1>
<img src=”banner.png” alt=”Mini Cooper”>
</header>

<main>
<img src=”placeholder-left.png” alt=”” aria-hidden=”true”>
<img src=”placeholder-right.png” alt=”” aria-hidden=”true”>

</main>

<figure role=”contentinfo”>

</figure>

My page-width spanning header and figure needs no explanation, but flowing text between two triangular shapes is a little more complicated. To implement this z-pattern design, I choose to include two tiny 1×1px placeholder images onto which I apply two larger, shape-forming images using shape-outside. By attaching an aria-hidden attribute to these images, a screen reader won’t describe them.

After giving the two shape images the same dimensions,
I float one image left and the other to the right, which allows my running text to run between them:

[src*=”placeholder-left”],
[src*=”placeholder-right”] {
display: block;
width: 240px;
height: 100%;
}

[src*=”placeholder-left”] {
float: left;
shape-outside: url(‘shape-right.png’);
}

[src*=”placeholder-right”] {
float: right;
shape-outside: url(‘shape-right.png’);
}

Left: A presentable but predictable design which lacks energy. Right: CSS Shapes suggest fun and speed.

Left: A presentable but predictable design which lacks energy. Right: CSS Shapes suggest fun and speed.

The iconic Mini Cooper was fast and fun to drive. While my design would be perfectly presentable without a z-pattern formed by CSS Shapes, this layout looks predictable and lacks energy. The z-pattern created by driving a narrow column of running text between two shapes suggests speed and the fun people will have when driving this iconic little car.

3. Curved Shapes

One of the most fascinating aspects of CSS Shapes is how I can create elegant shapes using the alpha channel from a partially transparent image. This shape can be anything I imagine. I only need to create the image, and a browser will flow content around it.

While confining content to within a shape has been proposed in the CSS Shapes Module Level 2 specification, there’s currently no way to know if and when this might be implemented in browsers. But while shape-inside isn’t available (yet!), that doesn’t mean I can’t create similar results using shape-outside.

Left: Another presentable, but predictable design. Right: A more distinctive look created by using CSS Shapes.

Left: Another presentable, but predictable design. Right: A more distinctive look created by using CSS Shapes.

By confining my content within a curved image floated right, I can easily add a distinctive look to this next design. To create the shape, I again use the shape-outside property, this time with the value being the same URL as my visible image:

[src*=”curve”] {
float: right;
width: 400px;
height: 100vh;
shape-outside: url(‘curve.png’);
}

To put some distance between my shape and the content flowing around it, the shape-margin property draws a further shape outside the contours of the first one. I can use any CSS absolute length unit — millimeters, centimeters, inches, picas, pixels, and points — or relative units (ch, em, ex, rem, vh, and vw):

[src*="curve"] {
shape-margin: 3rem;
}

More Margins

Adding movement to this curved design relies on more than CSS Shapes. Using viewport width units, I give my headline, image, and running text a different left margin, each one proportional to the width of the viewport. This creates a diagonal from the back of my headline to the front of the car:

h1 {
margin-left: 5vw;
}

img {
margin-left: 10vw;
}

p {
margin-left: 20vw;
}

4. Diagonal Shapes

Angles can help make layouts look less structured and feel more organic. The absence of clear structure encourages the eye to roam freely around a composition. This movement also causes an arrangement to feel energetic.

I see designs set around horizontal and vertical axes every day, but rarely anything based on a diagonal. Every once in a while, I spot an angled element — perhaps a banner graphic with its bottom sloping — but it’s rarely essential to a design.

It’s common to see content flowing around shapes in print design, but this was impossible to achieve on the web before CSS Shapes.

It’s common to see content flowing around shapes in print design, but this was impossible to achieve on the web before CSS Shapes.

Even though CSS Grid involves setting columns and rows, there’s no reason why it can’t be used to create dynamic diagonals. This next design needs just a header and main element:

<header role=”banner”>
<h1>Mini Cooper</h1>
<img src=”banner.png” alt=”Mini Cooper”>
</header>

<main>
<img src=”shape.png” alt=””>

</main>

To create the diagonal detail in this design, I again flow content around a shape image which itself is floated left. Again I use the shape-outside property with the same URL value as my visible image and a shape-margin to put distance between my shape and the content flowing around it:

[src*=”shape”] {
float: left;
shape-outside: url(‘shape.png’);
shape-margin: 3rem;
}

Given that responsiveness is one of the web’s intrinsic properties, we can rarely predict how content will flow, but we avoid designs like this one. When there’s too little space for all my running text to fit above the shape, the fact that each shape is floated means that content will flow into space below the shape.

5. Rotated Shapes

Why settle for just using CSS Grid and Shapes when adding Transforms to the mix can enable layouts which were unimaginable only a few years ago? In this final example, flowing text around the cars in this image, while at the same time rotating the entire composition needed a combination of all those properties.

Why settle for using only CSS Grid and Shapes?

Why settle for using only CSS Grid and Shapes?

As the image of these cars has no transparent alpha channel, flowing text around the shapes, it contains needs a second image which includes only alpha channel information.

Implementing this design requires two images; one visible, the other proving alpha channel information.

Implementing this design requires two images; one visible, the other proving alpha channel information.

This time, I float the visible image right and apply the shape-outside property with a URL value which matches my alpha channel image:

[src*=”shape”] {
float: right;
width: 50%;
shape-outside: url(‘alpha.png’);
shape-margin: 1rem;
}

You may have noticed that both my images contain elements which I rotated clockwise by ten degrees. With those images in place, I can rotate the entire layout ten degrees in the opposite direction to give the illusion that my images are upright:

body {
transform: rotate(-10deg);
}

I rotate this layout just enough to make the design more appealing, without sacrificing readability.

I rotate this layout just enough to make the design more appealing, without sacrificing readability.

Bonus Example: Polygon Shapes Sculpt Columns

An extract from ‘Art Direction for the Web’ available from 26th March 2019.

You can create strong, structural shapes with nothing more than type. Combining polygon() shapes and pseudo-elements, you can sculpt shapes from solid blocks of running text, in the style of Alexey Brodovitch and his influential work for Harper’s Bazaar.

Left: These beautiful numerals are almost too lovely to hide. They’re also perfect for carving into those columns. Right: When I use invisible pseudo-elements with no background or borders to develop polygon shapes, the result is two unusually shaped columns.

Left: These beautiful numerals are almost too lovely to hide. They’re also perfect for carving into those columns. Right: When I use invisible pseudo-elements with no background or borders to develop polygon shapes, the result is two unusually shaped columns.

I formed these columns from two article elements, i.e. with a gutter between them and a maximum width, which help maintain a comfortable measure:

body {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 2vw;
max-width: 48em;
}

Because there are two article elements and I also specified
two columns for my grid, there’s no need to be specific about the position of those articles. I can let a browser place them for me, and all that remains for me is to apply shape-outside to a generated pseudo-element in each column:

article:nth-of-type(1) p:nth-of-type(1)::before {
content: “”;
float: left;
width: 160px;
height: 320px;
shape-outside: polygon(0px 0px, 90px 0px, […]);
}

article:nth-of-type(2) p:nth-of-type(2)::before {
content: “”;
float: right;
width: 160px;
height: 320px;
shape-outside: polygon(20px 220px, 120px 0px, […]);
}

The Pay-Off

Now that Firefox has released a version which supports CSS Shapes, and has launched a Shape Path Editor inside its Developer Tools, there’s now only Edge without support for Shapes. This situation will soon change now that Microsoft has announced a change from their own EdgeHTML rendering engine to Chromium’s Blink, the same engine as Chrome and Opera.

Tools like CSS Shapes now give us countless opportunities to use art direction to capture readers’ attention and keep them engaged. I hope by now you’re as excited about them as I am!

Editorial’s Note: Andy’s new book, Art Direction for the Web (pre-order your copy today), explores 100 years of art direction and how we can use this knowledge and the newest web technologies to create better digital products. Read an excerpt chapter to get a taste of what the book has to offer.

Further Resources

“Art Direction for the Web,” Andy Clarke
“Take A New Look At CSS Shapes,” Rachel Andrew
“CSS Shapes,” MDN web docs, Mozilla
“Edit Shape Paths In CSS,” MDN web docs, Mozilla
“Art Direction For The Web: A New Smashing Book,” Smashing Magazine

Smashing Editorial
(mr, ip, il)

3 Tips to Improve the Composition of Video Content by Cropping

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/mJA2bGo0XKc/3-tips-to-improve-the-composition-of-video-content-by-cropping

Cropping a video is about much more than just removing part of its frame. Instead it is a powerful tool that will let you directly improve the composition of your videos. To do that however, you need to make sure that you take advantage of what the crop feature can do and use it to […]

The post 3 Tips to Improve the Composition of Video Content by Cropping appeared first on designrfix.com.

How to Create a Sticky Image Effect with Three.js

Original Source: http://feedproxy.google.com/~r/tympanus/~3/FDQVPCkh4Lo/

If you recently browsed Awwwards or FWA you might have stumbled upon Ultranoir’s website. An all-round beautifully crafted website, with some amazing WebGL effects. One of which is a sticky effect for images in their project showcase. This tutorial is going to show how to recreate this special effect.

The same kind of effect can be seen on the amazing website of MakeReign.

Understanding the effect

When playing with the effect a couple of times we can make a very simple observation about the “stick”.

In either direction of the effect, the center always reaches its destination first, and the corners last. They go at the same speed, but start at different times.

With this simple observation we can extrapolate some of the things we need to do:

Differentiate between the unsticky part of the image which is going to move normally and the sticky part of the image which is going to start with an offset. In this case, the corners are sticky and the center is unsticky.
Sync the movements

Move the unsticky part to the destination while not moving the sticky part.
When the unsticky part reaches its destination, start moving the sticky part

Getting started

For this recreation we’ll be using three.js, and Popmotion’s Springs. But you can implement the same concepts using other libraries.

We’ll define a plane geometry with its height as the view height, and its width as 1.5 of the view width.

const camera = new THREE.PerspectiveCamera(45, 1, 0.1, 10000);
const fovInRadians = (camera.fov * Math.PI) / 180;
// Camera aspect ratio is 1. The view width and height are equal.
const viewSize = Math.abs(camera.position.z * Math.tan(fovInRadians / 2) * 2);
const geometry = new THREE.PlaneBufferGeometry(viewSize *1.5,viewSize,60,60)

Then we’ll define a shader material with a few uniforms we are going to use later on:

u_progress Elapsed progress of the complete effect.
u_direction Direction to which u_progress is moving.
u_offset Largest z displacement

const material = new THREE.ShaderMaterial({
uniforms: {
// Progress of the effect
u_progress: { type: “f”, value: 0 },
// In which direction is the effect going
u_direction: { type: “f”, value: 1 },
u_waveIntensity: { type: “f”, value: 0 }
},
vertexShader: vertex,
fragmentShader: fragment,
side: THREE.DoubleSide
});

We are going to focus on the vertex shader since the effect mostly happens in there. If you have an interest in learning about the things that happen in the fragment shader, check out the GitHub repo.

Into the stick

To find which parts are going to be sticky we are going to use a normalized distance from the center. Lower values mean less stickiness, and higher values mean more sticky. Since the corners are the farthest away from the center, they end up being most sticky.

Since our effect is happening in both directions, we are going to have it stick both ways. We have two separate variables:

One that will stick to the front. Used when the effect is moving away from the screen.
And a second one that will stick to the back. Used when the effect is moving towards the viewer.

uniform float u_progress;
uniform float u_direction;
uniform float u_offset;
uniform float u_time;
void main(){
vec3 pos = position.xyz;
float distance = length(uv.xy – 0.5 );
float maxDistance = length(vec2(0.5,0.5));
float normalizedDistance = distance/sizeDist;
// Stick to the front
float stickOutEffect = normalizedDistance ;
// Stick to the back
float stickInEffect = -normalizedDistance ;
float stickEffect = mix(stickOutEffect,stickInEffect, u_direction);
pos.z += stickEffect * u_offset;
gl_Position =
projectionMatrix *
modelViewMatrix *
vec4(pos, 1.0);
}

Depending on the direction, we are going to determine which parts are not going to move as much. Until we want them to stop being sticky and move normally.

The Animation

For the animation we have a few options to choose from:

Tween and timelines: Definitely the easiest option. But we would have to reverse the animation if it ever gets interrupted which would look awkward.
Springs and vertex-magic: A little bit more convoluted. But springs are made so they feel more fluid when interrupted or have their direction changed.

In our demo we are going to use Popmotion’s Springs. But tweens are also a valid option and ultranoir’s website actually uses them.

Note: When the progress is either 0 or 1, the direction will be instant since it doesn’t need to transform.

function onMouseDown(){

const directionSpring = spring({
from: this.progress === 0 ? 0 : this.direction,
to: 0,
mass: 1,
stiffness: 800,
damping: 2000
});
const progressSpring = spring({
from: this.progress,
to: 1,
mass: 5,
stiffness: 350,
damping: 500
});
parallel(directionSpring, progressSpring).start((values)=>{
// update uniforms
})

}

function onMouseUp(){

const directionSpring = spring({
from: this.progress === 1 ? 1 : this.direction,
to: 1,
mass: 1,
stiffness: 800,
damping: 2000
});
const progressSpring = spring({
from: this.progress,
to: 0,
mass: 4,
stiffness: 400,
damping: 70,
restDelta: 0.0001
});
parallel(directionSpring, progressSpring).start((values)=>{
// update uniforms
})

}

And we are going to sequence the movements by moving through a wave using u_progress.

This wave is going to start at 0, reach 1 in the middle, and come back down to 0 in the end. Making it so the stick grows in the beginning and decreases in the end.

void main(){

float waveIn = u_progress*(1. / stick);
float waveOut = -( u_progress – 1.) * (1./(1.-stick) );
float stickProgress = min(waveIn, waveOut);
pos.z += stickEffect * u_offset * stickProgress;
gl_Position =
projectionMatrix *
modelViewMatrix *
vec4(pos, 1.0);
}

Now, the last step is to move the plane back or forward as the stick is growing.

Since the stick grow starts in different values depending on the direction, we’ll also move and start the plane offset depending on the direction.

void main(){

float offsetIn = clamp(waveIn,0.,1.);
// Invert waveOut to get the slope moving upwards to the right and move 1 the left
float offsetOut = clamp(1.-waveOut,0.,1.);
float offsetProgress = mix(offsetIn,offsetOut,u_direction);
pos.z += stickEffect * u_offset * stickProgress – u_offset * offsetProgress;
gl_Position =
projectionMatrix *
modelViewMatrix *
vec4(pos, 1.0);
}

And here is the final result:


Conclusion

Simple effects like this one can make our experience look and feel great. But they only become amazing when complemented with other amazing details and effects. In this tutorial we’ve covered the core of the effect seen on ultranoir’s website, and we hope that it gave you some insight on the workings of such an animation. If you’d like to dive deeper into the complete demo, please feel free to explore the code.

We hope you enjoyed this tutorial, feel free to share your thoughts and questions in the comments!

How to Create a Sticky Image Effect with Three.js was written by Daniel Velasquez and published on Codrops.

90% Off: Get the Essential Digital Photography Master Class Bundle for Only $19

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/-tz6LxtX2vg/90-off-get-the-essential-digital-photography-master-class-bundle-for-only-19

The use of digital cameras have become more and more common since the 1990s. Even smartphone cameras take decent quality photos. As such, it is easier now more than ever to get started with photography. If you want to take better photos, then the Essential Digital Photography Master Class Bundle can be of great hep […]

The post 90% Off: Get the Essential Digital Photography Master Class Bundle for Only $19 appeared first on designrfix.com.

Understanding Subresource Integrity

Original Source: https://www.smashingmagazine.com/2019/04/understanding-subresource-integrity/

Understanding Subresource Integrity

Understanding Subresource Integrity

Drew McLellan

2019-04-09T12:30:59+02:00
2019-04-09T15:15:05+00:00

If you’ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code.

All that junk is actually a really useful security feature called Subresource Integrity (SRI) that can help to defend your site against certain types of hacks and compromises. In this article, we’ll take a look at what SRI is, how it can help protect you, and how you can start using it in your own projects, not just for files hosted on CDNs.

A Bit Of History

Way back in the days when JavaScript was very much the poorer cousin to HTML and CSS, we didn’t need to think too much about how our scripts could be used as an attack vector for our websites. Most sites were all hosted on a single physical server somewhere on our own hosting infrastructure, and it was the server we thought about defending when it came to security best practices.

As browsers became more capable and net connections got fatter, we started to use more and more JavaScript, and eventually, reusable JavaScript libraries began to spring up. In those early days, libraries like script.aculo.us, Prototype and eventually jQuery began to gain adoption amongst developers looking to add more interactivity into their pages.

With these added libraries and subsequent plugins came added page weight, and before long we were starting to think seriously about front-end performance. Resources like Content Delivery Networks (CDNs) that had previously been the reserve of giant corporations were becoming commonplace for everyday folk building snappy websites.

Along the way, some bright spark noticed that sites were all requesting their own copies of common libraries — things like the latest jQuery — and if there was a common CDN version of those libraries that could be used by every site, then the user wouldn’t need to keep downloading the same file. They’d take the hit for the first site to use the file, but then it would sit in their local browser cache and downloads could be skipped for each subsequent site. Genius!

This is why you’ll see CDN links for your favorite libraries using URLs like jsdelivr.com — they’re making use of a common CDN to host the files so that their users see the performance benefits.

What Could Go Wrong?

This remains a good, practical way to work, but it does introduce a potential vector for attack. Let’s imagine that it’s 2012 and everyone is using the brand new jQuery 1.8. Back with the traditional way of doing things, everyone would have their own jQuery 1.8 file hosted as part of their own website on their own server.

If you were some kind of evil actor — like some sort of jQuery-based Hamburglar — and had figured out a sneaky way to hack the library for your own evil gains, you’d have to target every website individually and compromise their servers to have any impact. That’s a lot of effort.

But that’s not how things are now, as everyone is using jQuery loaded from a common CDN. And when I say everyone, I don’t mean hundreds of web pages. I mean millions of web pages. Suddenly that one file has become a very attractive target for our shady hacker. If they can compromise that one file, they can very quickly have code running in millions of web pages across the globe.

It doesn’t matter what that code is. It could be a prank to deface pages, it could be code to steal your passwords, it could be code to mine cryptocurrency, or it could be sneaky trackers to follow you around the web and make a marketing profile. The important thing is that the innocent file that the developer added to a page has been changed and you now have some evil JavaScript running as part of your site. That’s a big problem.

Enter Subresource Integrity

Rather than rolling back the clocks and abandoning a useful way to use code, SRI is a solution that adds a simple level of security on top. What SRI and the integrity attribute does is make sure that the file you linked into a page never changes. And if it does change, then the browser will reject it.

Checking that code hasn’t changed is a very old problem in computer science and thankfully it has some very well established solutions. SRI does a good job of adopting the simplest — file hashing.

File hashing is the process of taking a file and running it through an algorithm that reduces it to a short string representation, known as a hash or checksum. Without getting into the weeds, the process is either repeatable or reversible, so much that if you were to give someone else a file along with the hash they’d be able to run the same algorithm to check that the two match. If the file changes or the hash changes, then there’s no longer a match and you know something is wrong and should distrust the file.

When using SRI, your webpage holds the hash and the server (CDN or anywhere) holds the file. The browser downloads the file, then quickly computes to make sure that it is a match with the hash in the integrity attribute. If it matches the file is used, and if not it is blocked.

Trying It Out

If I go to getbootstrap.com today to get a CDN link to a version of Bootstrap, I’m given a tag that looks like this:

<script src=”https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js” integrity=”sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM” crossorigin=”anonymous”></script>

You can see that the src attribute is as we’re used to, and the integrity attribute holds what we now know to be a hash.

The hash is actually in two parts. The first is a prefix to declare which hashing algorithm to use. In this case, it’s sha384. This is followed by a dash and then the hash itself, encoded with base64.

You may be familiar with base64 as a way of encoding inline files like images into pages. It’s not a cryptographic process — it’s just a fast and convenient way to encode potentially messy data in a way that translates neatly to ASCII. This is why it’s used a lot on the web.

On seeing this, the browser will download bootstrap.min.js. Before executing it, it will base64 decode the hash and then use the sha384 hashing algorithm to confirm that the hash matches the file it’s just downloaded. If it matches, the file is executed.

I can test this out by putting that tag in a page, and then flipping to the Network tab in my browser tools to see that the file has been loaded.

Network tab

(Large preview)

I can see that bootstrap.min.js (and also the jQuery file it needs) have loaded successfully.

Let’s see what would happen if I update the hash to be something I know to be incorrect.

<script src=”https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js” integrity=”sha384-SmashingMagazineIsCoolForCats” crossorigin=”anonymous”></script>

hash

(Large preview)

As you can see, the hash that’s specified in my page no longer matches the file, so the file gets blocked.

Using SRI In Your Own Projects

Having this capability for libraries on a CDN is great, and if you see the option to use an embedded file with an integrity attribute then you should definitely favor that option. But it’s not limited to big projects on CDNs, you can use this yourself for your own sites.

It’s not at all far fetched to imagine a scenario where a hacker manages to get access to just a few files on your site. I think most of us have see a client, colleague or friend who has at some point had a WordPress site compromised with a load of nasty junk that they didn’t even realise was there.

SRI can protect you from this too. If you generate integrity hashes for your own files, then you can have your site reject any changes just as it would for a remotely hosted file.

Generating Hashes

You can, as you’d expect, run some commands at your computer’s terminal to generate a hash for a file. This example of how to do so comes from the MDN Subresource Integrity page:

cat FILENAME.js | openssl dgst -sha384 -binary | openssl base64 -A

That’s getting the content of FILENAME.js and passing it as input to openssl to create a digest using sha384, which is then passed as input into another openssl command to base64 encode the result. Not only is that complicated and obscure, but it’s also not the sort of thing you want to be doing by hand every time your JavaScript file changes.

More usefully, you’ll want to integrate this somehow into your site’s build process, and as you’d imagine, there are plenty of ready-made options there. The exact implementation is going to vary wildly based on your project, but here are some building blocks.

If you use Gulp to build your sites, there’s gulp-sri which will output a JSON file with a list of your files and their hashes. You can then make use of this in your site. For example, for a dynamically rendered site, you might create a template plugin to read that file and add the hashes to your templates where needed.

If you’re still with Gulp but have a static site (or a statically generated site) you might use gulp-sri-hash which will actually run through your HTML pages and modify the pages to add hashes where needed, which is very handy.

If you’re using Webpack, there’s webpage-subresource-integrity which in true Webpack style is more complex than any human might expect it to be, but does appear to work.

For those using the Handlebars templating engine, there appear to be options available to you, and if your build process is just basic JavaScript, there are simple solutions there too.

If you’re using a CMS like WordPress, I found a plugin that appears to make it easy, although I’ve not tried it myself. Googling for your own platform of choice with SRI or Sub Resource Integrity will likely point you in the right direction.

You essentially want to hook your hashing in after your JavaScript files have been minified and then make that hash available in some way to whatever part of your system outputs the <script> tags. One of the wonders of the web platform is that it’s so technically diverse, but that sadly leaves me unable to give you good implementation instructions!

Other Things To Note

In this article, I’ve talked a lot about JavaScript files because that’s really where it makes the most sense to defend against hacking attacks. SRI also works with CSS, and so you can use it in exactly the same way there. The risk for malicious CSS is much lower, but the potential to deface a site still exists and who knows what browser bugs could also lead to CSS inadvertently exposing your site to a hacker. So it’s work using SRI there too.

Another interesting thing you can do is use a Content Security Policy to specify that any script (or styles) on your page must use SRI, and of course that SRI must validate.

Content-Security-Policy: require-sri-for script;

This is a way to ensure that SRI is always used, which could be useful on sites worked on by multiple team members who may or may not be fully up to speed with how to do things. Again, a good place to read more about this is the always-great MDN docs for Subresource Integrity.

The last thing that’s worth talking about is browser support for SRI. Support in modern browsers is broad, with the main exception being Internet Explorer. Due to the backwards-compatible way the specification has been implemented, however, it’s safe to use immediately. Browsers that understand the integrity attribute will use the hash and check integrity, and older browsers will just carry on as they always have and keep working. Of course, you’ll not get the added protection in those older browsers, but you will in the browsers that do offer support.

Conclusion

We’ve seen not only what those weird hashes in the integrity attributes do, but how we can use them to defend against certain types of attacks on our website. Of course, there’s no one silver bullet that will defend our sites against every type of exploit, but Subresource Integrity is a really useful tool in the chain.

Exploiting a security flaw is often about getting multiple small pieces to line up. If A is in place, and you can make B happen, then a bug in C makes D possible. Browser features like SRI give us a good way to tie things down just a little bit more and potentially break that chain and prevent a hacker from getting what they want. What’s more, if you can integrate it into your build process or CMS, it’s something you should be able to set up once and then forget about and it won’t cause you day to day inconvenience.

As such, I’d really recommend taking a serious look at Subresource Integrity and implementing it on your sites if you can.

Smashing Editorial
(yk, il)

Relive your Snake addiction with Google's April Fool's gag

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/0VBAOZSEVGo/relive-your-snake-addiction-with-googles-april-fools-gag

For readers of a certain age, the game Snake will bring back hazy memories of squinting at the screen of a Nokia 3210 as you furiously try to beat your best mate's high score. To give people the chance to relive the classic game, Google has added a version of Snake to Google Maps today as an April Fool's Day treat.

Rolling out worldwide today across Android and iOS, Snake on Google Maps sees players control buses and trains instead of a slithering serpent. The aim of the game is still the same though: players have to gobble up objects, in this case tourists and famous landmarks, while making sure they don't overlap themselves or run off the map. After a few goes, you'll realise (or remember) that this isn't as easy as it sounds.

Players get to choose from a variety of locations from Google Maps, including Cairo, London, San Francisco, São Paulo, Sydney and Tokyo. Each map and its associated landmarks are picked out in colourful pixel art, ensuring that this version of Snake brings out all of your '90s nostalgia.

According to Google Maps product manager Omar Abdelaziz, Snake on Google Maps will be available in the app for "about a week". However, if you just can't get enough of the game, you'll be pleased to hear that it has a standalone site, so you will be able to keep playing "long after April Fools is over."

As far as pranks go, Google is playing it very safe this year. That's if you can even call Snakes on Google Maps a prank. However, given that your social media feeds have probably been inundated with joke stories this morning, we appreciate that the search engine giant is saving you a bit of hassle by being upfront with its mild tomfoolery.

Another reason that Google is treading carefully around April Fool's Day could be related to a 2016 prank that backfired. That year Google launched the 'Mic Drop', a feature which temporarily replaced the 'Send and Archive' button. By clicking 'Mic Drop', users sent everyone in the conversation a GIF of a Minion dropping a microphone, as well as stopping further replies from appearing in your inbox.

The Mic Drop prank caused headaches for companies, with at least one freelancer losing work as a result of it burying their replies. Hilarious. In response to the fallout, Google issued an apology and deactivated the feature, so we can't really blame it for not taking a risk this April Fool's Day.

Related articles:

Google's new gaming logo is cleverly off-brandThe Period Game is Dream Phone with ovaries5 ads that tried to be cool, but failed

SitePoint Premium New Releases: Node, Android, React Native & More

Original Source: https://www.sitepoint.com/sitepoint-premium-new-releases-node-android-react-native-more/

We’re working hard to keep you on the cutting edge of your field with SitePoint Premium. We’ve got plenty of new books and mini-books to check out in the library — let us introduce you to them.

Mastering the Faster Web with PHP, MySQL, JavaScript

Make data-driven web apps run faster with advanced PHP, SQL and JS techniques. Ensure seamless implementation of a JS-, HTML 5- and CSS-based front end and PHP-based back end. Learn about problem identification, best strategies, and UI design patterns as well to build a clean, fast web app.

Read Mastering The Faster Web with PHP, MySQL, JavaScript.

Learning Java by Building Android Games Second Edition

Develop engaging games for the Android platform with Java. Learn Java, Android, and object-oriented programming from scratch. Build games including Sub Hunter, Retro Pong, and Bullet Hell. Create and design your own games, such as an open-world platform game.

Read Learning Java by Building Android Games Second Edition.

Internet of Things Programming Projects

This book is a practical, project-based guide to help you build and control your IoT projects. Leverage the full potential of IoT with the combination of Raspberry Pi 3 and Python. Build complex, Python-based apps with IoT. Work on various IoT projects and understand the basics of electronics.

Read Internet of Things Programming Projects.

Real-Time 3D Graphics with WebGL 2 – Second Edition

Create interactive, visually stunning, high-performance 3D applications for the web with JavaScript and WebGL 2. This complete course on 3D computer graphics covers rendering, 3D math, lighting, cameras, and more, unlocking a variety of new and advanced WebGL 2 features.

Read Real-Time 3D Graphics with WebGL 2 – Second Edition.

Android Programming for Beginners – Second Edition

Through this first-principles introduction to Java, via Android, you’ll learn all the Java and Android skills you need to start making powerful mobile apps with practical and actionable steps, and how to publish apps to the Google Play marketplace.

Read Android Programming for Beginners Second Edition.

Mastering React Native

Get up to speed with all the React Native building blocks necessary for creating expert, cutting-edge apps. Learn how to apply Flexbox, build rich animations, integrate third-party libraries, develop customized components, combine React Native with Redux, Redux middleware, a remote API, and more.

Read Mastering React Native.

Vue.js: Tools & Skills

In this book, we’ll examine some of the most popular Vue,js tools, and look at some related skills that will help you on your journey to becoming an expert Vue developer.

Read Vue.js: Tools & Skills.

CSS Animation 101

We’re going to learn about CSS transitions and animations. By the end of the book, you’ll have a good understanding of CSS animations as well as the tools to create and experiment with our own.

Read CSS Animation 101.

How to Build a Game with Vue.js

In this tutorial, we’ll explore one of the less obvious uses for Vue: game development,. We’ll build an electronic variant of the popular Match Pairs game.

Read How to Build a Game with Vue.js.

Node.js Web Development Fourth Edition

Create real-time apps with Node.js, Docker, MySQL, MongoDB, and Socket.IO. Learn about live deployment, including HTTPS and hardened security, the latest JS features and ES modules, and walk through different stages of developing robust apps using Node.js 10.

Read Node.js Web Development Fourth Edition.

And More to Come…

We’re releasing new content on SitePoint Premium almost every day, so we’ll be back next week with the latest updates. And don’t forget: if you haven’t checked out our offering yet, take our 7 day free trial for a spin.

The post SitePoint Premium New Releases: Node, Android, React Native & More appeared first on SitePoint.