Re:Frosted glass effect with CSS and SVG
by NKCSS on Thursday November 14, 2013 @03:23AM
(#6731260)
Looks nice, but I really love the Google Font API trick there; I did not know that by using the text querystring, you can build a custom font with just the letters you need :)
Re:Frosted glass effect with CSS and SVG
by tripzilch on Thursday November 14, 2013 @11:27AM
(#6733193)
and this is the unescaped/indented version of the SVG in the data-URL.
(figured that, after I decoded it, might as well post it for everyone, couldn't make heads or tails of that side-scrolling oneliner :) it's not very complex an sich but it nicely shows how simple it is to wrap an image in a SVG for filtering/other purposes)
Re:Frosted glass effect with CSS and SVG
by russellsprouts on Thursday November 14, 2013 @02:07AM
(#6731039)
It's difficult, because you cannot see the pixels in an HTML element's rendering with JavaScript. If you could copy a link to a canvas, then you could see if it has been previously visited, for example. So, canvases would not work.
Re:Frosted glass effect with CSS and SVG
by peterhunt on Thursday November 14, 2013 @11:25AM
(#6733181)
Three reasons.
1. Blur filter is only available on WebKit
2. I know for sure how much texture memory is on an iPhone 5
3. The touch event latency on android is too damn high.
Re:Frosted glass effect with CSS and SVG
by peterhunt on Thursday November 14, 2013 @04:14PM
(#6735629)
I do synthetic scrolling (translate3d() + touch event interpretation and inertial math). Then duplicate the DOM for the top and bottom bars, adjust the positioning to make them look fluid and apply the CSS blur filter.
Re:Frosted glass effect with CSS and SVG
by jakobe on Thursday November 14, 2013 @04:16AM
(#6731418)
Awesome demo, but unfortunately rather slow on my (oldish) Macbook.
I also recently made a page with frosted glass effect, but opted for pre-rendered images because of those performance issues: https://eggerapps.at/pgcommander/fancy-index.html
(But I decided the effect was too playful for my website and so it's not public)
Re:Frosted glass effect with CSS and SVG
by mjolk on Thursday November 14, 2013 @06:11AM
(#6731701)
How "oldish" is your Macbook? I'm using a core2duo and didn't have any problems.
In fact, retrieving an image from Placekitten took the longest on the network, followed by the overhead of loading a Google font. The only real CPU time spent on this page is the overhead of codepen.
Are you mistaking network latency for performance issues with the example?
Re:Frosted glass effect with CSS and SVG
by widdershins on Thursday November 14, 2013 @08:38AM
(#6732169)
I'm also on a core2duo, but I found it slow. It loaded and rendered quickly, but when I resized the preview window (the ability to resize being the main point of doing it this way, I assume), it was very choppy.
Re:Frosted glass effect with CSS and SVG
by hmottestad on Thursday November 14, 2013 @04:03AM
(#6731359)
There is still one problem with using the blur filter in CSS. It's all about the edges.
As you increase the blur the edges shrink inwards. This makes it difficult to get a frosted glass effect with more blur. Try setting a higher blur, eg:
Re:Frosted glass effect with CSS and SVG
by oleganza on Thursday November 14, 2013 @10:32AM
(#6732831)
A workaround would be to wrap the blur layer in another one with overflow:hidden and extend the edges of the inner one. I wonder if that would do the trick.
Re:Frosted glass effect with CSS and SVG
by callum85 on Thursday November 14, 2013 @06:02AM
(#6731685)
Thought of a way to do a materialization effect with good performance. Fake it. If you set a low opacity on the blurred element (ie, put "opacity: 0.5" on the ".glass::before", essentially mixing the blurred image with the sharp one beneath it), this actually looks like it's half as blurred as before.
Opacity can be animated very cheaply, entirely on the GPU (source: http://www.html5rocks.com/en/tutorials/speed/high-performanc...), so if you animate this property from 1 to 0, you should a good materialization effect, without ever asking the CPU to recalculate the blur.
I'm going to fork the codepen and try this, will report back...
Re:Frosted glass effect with CSS and SVG
by callum85 on Thursday November 14, 2013 @09:45AM
(#6732542)
Weird. It works pretty smoothly on Chrome (about 50Hz). Just tried on FF/Mac, it's ultra slow there too. I think it must be redrawing the SVG every frame, if it's that slow. But in the HTML5Rocks tutorial Paul Irish says "Chrome, Firefox, Safari and Opera all hardware accelerate transforms and opacity." I'll try a few more things.
EDIT: ha, IE10/Win7 (in a VM) is super smooth for me. Still no idea what's going on with Firefox.
Re:Frosted glass effect with CSS and SVG
by benaiah on Thursday November 14, 2013 @02:02AM
(#6731029)
Really cool effect. Great way to get it without resorting to images.
In the future, I wonder if something like this could be done with the -filter attributes, though those may only work on images. I know those have been used to do blurring before, though possibly not in the same way.
Re:Frosted glass effect with CSS and SVG
by chrismorgan on Thursday November 14, 2013 @07:20AM
(#6731877)
Ah, I implemented frosted glass years ago in SVG using the BackgroundImage source for a feGaussianBlur (composed with other filters, of course). It works fairly well in Inkscape and other such tools, but alas! No browsers supported it and I believe that it is still the case that no browsers support it.
Of course, there are security implications, but those are fairly trivial given the infrastructure already in place.
Re:Frosted glass effect with CSS and SVG
by callum85 on Thursday November 14, 2013 @06:57AM
(#6731811)
There isn't actually as much magic as I first thought. The SVG (which is loaded via data URI) actually loads the same cat image again, and blurs it. (The cat URL is hardcoded into that SVG string in the data URI). So you have to know the image URL in advance, and generate a data URI for an SVG that contains it. Therefore this wouldn't work as a CSS-only technique if you wanted a dynamic image URL - you'd need JavaScript for that.
Tip: you can copy the whole data URI into your browser's location bar it will load the SVG. Then you can open devtools and inspect it to see what's going on.
(figured that, after I decoded it, might as well post it for everyone, couldn't make heads or tails of that side-scrolling oneliner :) it's not very complex an sich but it nicely shows how simple it is to wrap an image in a SVG for filtering/other purposes)
Would be cool if we could do it for translucent toolbar etc.
I may be possible with SVG filters or WebGL, but that also has security implications. It's possible to read cross-origin content using timing attacks and filters. http://www.contextis.com/files/Browser_Timing_Attacks.pdf
It looks better when you see it moving.
1. Blur filter is only available on WebKit 2. I know for sure how much texture memory is on an iPhone 5 3. The touch event latency on android is too damn high.
The funny thing being that I only saw that because I browsed the source, because the page was so broken for me that I only saw a black screen.
In any case, I see
So I'm out of here.It's easy with React :)
I'm still thinking in actually making this thing as a physical object with a handle you put in front of the screen.
I also recently made a page with frosted glass effect, but opted for pre-rendered images because of those performance issues: https://eggerapps.at/pgcommander/fancy-index.html (But I decided the effect was too playful for my website and so it's not public)
In fact, retrieving an image from Placekitten took the longest on the network, followed by the overhead of loading a Google font. The only real CPU time spent on this page is the overhead of codepen.
Are you mistaking network latency for performance issues with the example?
As you increase the blur the edges shrink inwards. This makes it difficult to get a frosted glass effect with more blur. Try setting a higher blur, eg:
Opacity can be animated very cheaply, entirely on the GPU (source: http://www.html5rocks.com/en/tutorials/speed/high-performanc...), so if you animate this property from 1 to 0, you should a good materialization effect, without ever asking the CPU to recalculate the blur.
I'm going to fork the codepen and try this, will report back...
EDIT: see http://codepen.io/callumlocke/pen/EKuvs
[EDITED to fix a stupid mistake: I wrote 0.5Hz but meant once per 0.5s, or 2Hz.]
EDIT: ha, IE10/Win7 (in a VM) is super smooth for me. Still no idea what's going on with Firefox.
In the future, I wonder if something like this could be done with the -filter attributes, though those may only work on images. I know those have been used to do blurring before, though possibly not in the same way.
Of course, there are security implications, but those are fairly trivial given the infrastructure already in place.
Tip: you can copy the whole data URI into your browser's location bar it will load the SVG. Then you can open devtools and inspect it to see what's going on.