News for hackers. Stuff that matters.
Re:Mona Lisa in pure CSS by phoboslab on Wednesday October 03, 2012 @09:21PM (#4610489)
And here I am, upvoting the thread because I thought it's a statement about how ridiculous all the 'X in pure CSS' posts have gotten, while everyone else in this thread seems to be genuinely impressed.
Re:Mona Lisa in pure CSS by skrebbel on Thursday October 04, 2012 @02:41AM (#4611201)
It's even more ridiculous once you realise that data: URLs work in CSS.

Thus, I hereby present to you, the Mona Lisa in pure css (!!), using even fewer bytes!

http://codepen.io/anon/pen/gnqlc

Re:Mona Lisa in pure CSS by notum on Thursday October 04, 2012 @04:00AM (#4611346)
Why not go oldschool?

Behold: Mona Lisa in pure html (!!), because more bytes is better.

http://codepen.io/anon/pen/lJxAe (may crash browsers)

Re:Mona Lisa in pure CSS by lowboy on Wednesday October 03, 2012 @09:53PM (#4610554)
At least it's better than X in pure HTML5.
Re:Mona Lisa in pure CSS by grimlck on Thursday October 04, 2012 @03:28AM (#4611281)
And that is better than the X in pure javascript posts, with X being something which was impressive 10 years ago in other languages
Re:Mona Lisa in pure CSS by egeozcan on Thursday October 04, 2012 @07:23AM (#4611779)
...doing the same in a more restrictive environment (in this case, browser) is always an accomplishment.
Re:Mona Lisa in pure CSS by novalis on Thursday October 04, 2012 @02:01PM (#4613502)
Conflating positive fruition with positive value is just a positivistic error. That would mean that any fruition is beneficial by default. Unless someone made "logic in css". It doesn't stop others from having a valid pov because a made b in a more restrictive c env.

Having said that, I like all the Mr Doob stuff and most openGL demo stuff coming out.

Re:Mona Lisa in pure CSS by jere on Wednesday October 03, 2012 @09:31PM (#4610516)
Jeez.

If your underlying method is pixels, you can render any image you want. I'm afraid I'm missing the "hack" here.

Re:Mona Lisa in pure CSS by jayflux on Thursday October 04, 2012 @08:44AM (#4611991)
I agree, I was expecting some CSS hackery.

But this is nothing more than using CSS for pixels. With that logic you could theoretically create anything.

Re:Mona Lisa in pure CSS by suyash on Thursday October 04, 2012 @01:59AM (#4611103)
that is the hack....I know it's kinda stupid or awesome..depends how you look at it...but pixel by pixel..we can draw anything!
Re:Mona Lisa in pure CSS by josteink on Thursday October 04, 2012 @04:10AM (#4611375)
So... It's a bitmap-image written in CSS boxshadows. It's a bitmap written in text.

The resulting CSS is 247KB. Taking the same image and saving as a JPG (which I think is fair, since it's fairly blurry) results in a 40KB file. That's more than 6 times smaller.

If you scale it down to the detail level found the CSS (each CSS-"pixel" being a 4x5 unit) even a PNG will easily beat it at 24KB. Here the JPG also clocks in at 6KB.

So I don't get it. Using CSS, using a text-format to encode bitmaps has always been and will always provide subpar results. Ok. So it can be done. We know that. It has been proven times and times again.

Apart from that: What's the point?

Re:Mona Lisa in pure CSS by dandelany on Friday October 05, 2012 @12:19AM (#4615665)
It's just a hack. You're on Hacker News. If you don't like it, don't upvote it.

This reminds me of when I brought a friend of mine to Maker Fair in NYC last year... We were surrounded by a strange amalgamation of weird gadgets and "art", and sometimes the line between the two is not always so clear :) The entire time we were there she kept asking "but what is it FOR?!" or "but who would WANT a thing like that?". I've always found myself asking questions like "ooh what does it do?" and "what can I learn from it?"

Re:Mona Lisa in pure CSS by josteink on Friday October 05, 2012 @04:35AM (#4616092)
Sure. It's a hack. I get it. Hacks are cool. But this is a hack which has been posted a million times over and over the last few months.

At some point the novelty wears off and IMO this one is way past due.

Apart from that, I was asking if there was anything else I was missing. From the responses I got, it seems the answer is "no".

Re:Mona Lisa in pure CSS by TazeTSchnitzel on Thursday October 04, 2012 @12:07PM (#4612969)
I was going to say this sort of thing would be useful on reddit for subreddit stylesheets, but they allow uploading images. So there's no practical application at all.
Re:Mona Lisa in pure CSS by hk__2 on Thursday October 04, 2012 @05:16AM (#4611518)
Even the gzipped version is 49kb.
Re:Mona Lisa in pure CSS by steffanwilliams on Wednesday October 03, 2012 @09:02PM (#4610436)
There is a generator on Codepen that allows you to do this, that probably deserves more praise: http://codepen.io/blazeeboy/pen/bCaLE
Re:Mona Lisa in pure CSS by suyash on Thursday October 04, 2012 @01:57AM (#4611098)
True, how cheap that the author is trying to take full credit as shown on his codepen example: /* Mona Lisa with pure CSS Pointless but fun!

  By Jay Salvat
  http://jaysalvat.com
*/
Re:Mona Lisa in pure CSS by TazeTSchnitzel on Thursday October 04, 2012 @12:16PM (#4613017)
Warning: Loading a large (e.g. 1920x1080) image will grind your computer to a halt as it fills up paged memory.
Re:Mona Lisa in pure CSS by pan69 on Wednesday October 03, 2012 @09:25PM (#4610497)
About ten years ago I made a converter application that converted a image (jpg/png/gif) to an HTML table. The result at the time was great. Unfortunately the generated HTML was quite verbose so it took a lot of bandwidth to download. I guess a similar conversion program has been used here and it seems that CSS these days can take off quite a bit of fat of that generated code.

PS: Forgot to mention. The reason I wrote the converter at the time was as an experiment to avoid people from right-click and saving images.

Re:Mona Lisa in pure CSS by cup on Wednesday October 03, 2012 @09:39PM (#4610525)
While some websites stop people from right clicking and saving (such as flickr) you can get around that by just screen printing. So why would you invest time in trying to stop one route of copying when there is a second unstoppable?
Re:Mona Lisa in pure CSS by jere on Wednesday October 03, 2012 @10:03PM (#4610575)
>So why would you invest time in trying to stop one route of copying when there is a second unstoppable?

http://en.wikipedia.org/wiki/Analog_hole

http://en.wikipedia.org/wiki/Digital_rights_management

Good question. I'd like to know also.

On another note, let's be honest. A lot of people today don't know print screen. I'd say the majority. But 10 years ago? That image to table conversion must have been a bank vault.

Re:Mona Lisa in pure CSS by Scottopherson on Wednesday October 03, 2012 @09:41PM (#4610529)
Clients.
Re:Mona Lisa in pure CSS by cup on Wednesday October 03, 2012 @10:04PM (#4610577)
Would it not be easier to explain to them that what they're asking for is impossible to deliver?
Re:Mona Lisa in pure CSS by gsteinb88 on Wednesday October 03, 2012 @11:03PM (#4610704)
Sometimes, yes. Frequently it's very difficult to explain to a client that the way you[1] interpret the words they[2] are using is rather different than what may be in their head.

That is, from the technical perspective it may be 'impossible' to achieve perfect DRM. But from another perspective, if the added cost of circumventing that DRM is large enough that most[3] people won't bother, it /may/ be a success. See: Steam.

In short, the language/terminology barrier between people in different fields results in a lot of client/developer miscommunication, frustration, and, frankly, poor results.

A rather complete discussion on this (w/r/t a client wanting 100% uptime): http://news.ycombinator.com/item?id=3056414

[1] The technical party in the relationship

[2] The party paying someone you to handle the technical side

[3] Again, we run into a problem with precise definitions using 'most' - do we mean 99.9%? Do we mean enough that the cost of implementing the DRM is larger than the $ saved. Though the lost sales due to /having/ DRM is an entirely different discussion.

Re:Mona Lisa in pure CSS by petsos on Wednesday October 03, 2012 @10:41PM (#4610653)
Probably not.
Re:Mona Lisa in pure CSS by yozmsn on Thursday October 04, 2012 @02:20AM (#4611149)
See the thing is that often at least for me when I want to save a picture it's because I like it and want to use it as a background, the trouble with printscreen is that it only captures the picture at your screen resolution not the photo's resolution so you end up with a grainy unusable image... if someone goes through the trouble of making a picture uncopyable I give up immediately, it's just not worth the hassle.
Re:Mona Lisa in pure CSS by iSnow on Thursday October 04, 2012 @03:59AM (#4611342)
Uhm, doesn't this spur your ambition?

With something like firebug installed, it takes about 20s to find "div#main-photo-container>noscript" holding the image on flickr in all it's glory.

Re:Mona Lisa in pure CSS by Edootjuh on Saturday October 06, 2012 @04:56PM (#4621680)
Or select the picture and copy it to the desktop.
Re:Mona Lisa in pure CSS by cousin_it on Thursday October 04, 2012 @08:45AM (#4611994)
If you want to stop people from right-clicking and saving, why not just cut the image into 16 smaller images? That would also make right-clicking and saving more difficult than screen-printing, so there's no point doing anything more advanced. For even more entertainment value, you could make the pieces irregular shaped, with transparency :-)
Re:Mona Lisa in pure CSS by borplk on Wednesday October 03, 2012 @10:48PM (#4610668)
Yeah good old times. I did exactly the same thing although not that long ago. It turned amazingly well (although yes no matter what you do the size will be higher than the original image) but the quality was identical. You can use a very small font with the ASCII square character which basically gives you pixel perfect images.
Re:Mona Lisa in pure CSS by xutopia on Wednesday October 03, 2012 @10:11PM (#4610591)
Screenshot?
Re:Mona Lisa in pure CSS by corwinstephen on Wednesday October 03, 2012 @09:15PM (#4610474)
The best part about this is that now I know that the box-shadow property can take multiple arguments. The more you know...
Re:Mona Lisa in pure CSS by jgv on Wednesday October 03, 2012 @09:21PM (#4610490)
7 thousand of them
Re:Mona Lisa in pure CSS by dpham on Wednesday October 03, 2012 @10:05PM (#4610579)
bet you there's a limit. 65536 maybe?
Re:Mona Lisa in pure CSS by joshj19 on Wednesday October 03, 2012 @10:43PM (#4610659)
Probably browser dependent. Edit: unless W3C mentioned something about it.
Re:Mona Lisa in pure CSS by seanlinehan on Wednesday October 03, 2012 @11:10PM (#4610726)
Me, in 60,000 lines of pure CSS: http://codepen.io/anon/pen/ItbEm

If anybody wants to take a gander at my very slow PHP code, it's here: https://gist.github.com/3831235

Anybody have any optimization tips?

Re:Mona Lisa in pure CSS by kevsamuel on Friday October 05, 2012 @06:17PM (#4618925)
A friend of the guy did even crazier, a animated nyan cat (including the annoying music) with only one html tag, and thousand lines of CSS ^^

http://codepen.io/JBay1337/pen/Ejtfl

Webkit only though

It started kinda supidly over a beer yesterday with the joconde guy, then one friend posted a 50 mo animated nyan cat, I posted a 22mo version, and we kept iterating until he won.

His last version is kinda smart: it uses css keyframes like divx use video keyframes, with diff in between. Almost the first css video codec :-p

Re:Mona Lisa in pure CSS by tlrobinson on Wednesday October 03, 2012 @09:35PM (#4610521)
We get it, you can draw anything in "pure CSS".
Re:Mona Lisa in pure CSS by RKearney on Wednesday October 03, 2012 @09:39PM (#4610524)
Not entirely. This also requires HTML.
Re:Mona Lisa in pure CSS by lowboy on Wednesday October 03, 2012 @09:52PM (#4610549)
You know, I was going to write that it was a given since CSS is applied to a markup language so you need some sort of markup, and that you were being pedantic.

But then I thought it would be neat if someone were to make the Mona Lisa as ASCII art using only valid CSS, thus rendering a truly pure CSS version. I guess you could further argue that it isn't pure CSS because it also involves something to display the text.

Re:Mona Lisa in pure CSS by ______ on Wednesday October 03, 2012 @11:04PM (#4610706)
You don't need HTML at all. Using pseudo elements and taking advantage of browser assumptions you can make HTML-free webpages:

http://css-tricks.com/using-css-without-html/

Re:Mona Lisa in pure CSS by lowboy on Thursday October 04, 2012 @02:01AM (#4611107)
The example doesn't work for me on Chrome stable, Win7. So looks like we need some markup.
Re:Mona Lisa in pure CSS by darkstalker on Thursday October 04, 2012 @08:19AM (#4611927)
Works for me on Firefox 15 (linux)
Re:Mona Lisa in pure CSS by kd0amg on Wednesday October 03, 2012 @10:22PM (#4610609)
And apparently, "This Site Totally Doesn't Work Without JavaScript."
Re:Mona Lisa in pure CSS by mukhabbat on Wednesday October 03, 2012 @11:56PM (#4610825)
As pan69 said this technique isn't new! I've experimented this but I don't like it, it's heavy for coding images. It's good for smaller codes like http://codepen.io/joshnh/pen/ohbHl
Re:Mona Lisa in pure CSS by diggan on Thursday October 04, 2012 @03:36AM (#4611302)
Yeah, smaller code... Only 2000 lines for something you can do with 2 or 3.
Re:Mona Lisa in pure CSS by nowarninglabel on Thursday October 04, 2012 @01:12AM (#4610991)
It's a bit disappointing that a project which is supposed to show me something in "pure CSS" is hosted on a site which gives me a big warning/block that the site "doesn't work with out javascript, like at all".
Re:Mona Lisa in pure CSS by diggan on Thursday October 04, 2012 @03:34AM (#4611294)
Codepen is just a viewer and editor for HTML, CSS and Javascript.
Re:Mona Lisa in pure CSS by andrus on Wednesday October 03, 2012 @08:33PM (#4610352)
Cool hack. It would be neat if the box-shadows used relative units rather than `px` so that you could resize the result, but then why not use SVG?
Re:Mona Lisa in pure CSS by jtreminio on Wednesday October 03, 2012 @08:56PM (#4610425)
Re:Mona Lisa in pure CSS by eranation on Wednesday October 03, 2012 @11:19PM (#4610755)
What would be nice is the source code of the code generator that did that CSS so everyone can post tomorrow their favorite image in pure CSS...
Re:Mona Lisa in pure CSS by seanlinehan on Wednesday October 03, 2012 @11:40PM (#4610798)
Re:Mona Lisa in pure CSS by eranation on Wednesday October 03, 2012 @11:59PM (#4610830)
Did you just find it, or wrote it right now? either way, this makes the point of the top voted comment even stronger.
Re:Mona Lisa in pure CSS by seanlinehan on Thursday October 04, 2012 @12:16AM (#4610869)
I wrote it after seeing the thread.

It's a pretty simple technique, but it's intensely resource heavy. If the op (or anybody) wrote a script that does this algorithmically to produce as few drop shadows as necessary while maintaining quality... Well, then I'd be thoroughly impressed.

Regardless, this clearly struck a chord with some people so I say cheers to the op! Easy or not, he did it, did it well, and captured peoples' wonder.

Re:Mona Lisa in pure CSS by raldi on Wednesday October 03, 2012 @11:26PM (#4610766)
How do you know he didn't draw it by hand?
Re:Mona Lisa in pure CSS by eranation on Wednesday October 03, 2012 @11:57PM (#4610826)
I don't, I just know I wouldn't
Re:Mona Lisa in pure CSS by elliotlai on Wednesday October 03, 2012 @09:18PM (#4610481)
I want a Ecce Homo version of this please ><
Re:Mona Lisa in pure CSS by vidarh on Wednesday October 03, 2012 @10:24PM (#4610614)
And the price for most horrible abuse of box-shadow goes to....

(Nice hack, though; didn't know box-shadow could be abused that way)

Re:Mona Lisa in pure CSS by kidh0 on Thursday October 04, 2012 @08:57AM (#4612039)
Seems that everybody that has plenty of time, a little bit of talent and knows this tool http://kushagragour.in/lab/picssel-art/ can make something like that
Re:Mona Lisa in pure CSS by ftwinnovations on Wednesday October 03, 2012 @08:39PM (#4610368)
So is there just an app making these types of things at this point? I'd have to imagine so... And if that's the case it's about as impressive as a generated ASCII art Mona Lisa.
Re:Mona Lisa in pure CSS by s_m on Wednesday October 03, 2012 @08:51PM (#4610409)
Almost certainly. You could probably do this in about twenty lines of PHP, it's just a map of pixels from an image into CSS pseudo-pixels.
Re:Mona Lisa in pure CSS by gavinpc on Wednesday October 03, 2012 @10:24PM (#4610616)
If I had a thousand dollars for every HN post that works in Chrome and not Firefox, I'd feel somewhat better about what that suggests.
Re:Mona Lisa in pure CSS by woah on Thursday October 04, 2012 @01:13AM (#4610993)
Yea, I'm a designer, I use chrome- you know why? The inspector is a lot better. The firefox inspector is sure sexy but it is simply not very powerful. Yea, there's firebug, but chrome has a very powerful set of tools built right in. I can amaze people by redesigning a page on the fly- as long as I don't accidently refresh.
Re:Mona Lisa in pure CSS by gavinpc on Thursday October 04, 2012 @02:01AM (#4611108)
I like Chrome, too. But I'm not ready to see Firefox abandoned. My hope is that the demo projects I've seen here are just bleeding-edge experiments that people were too excited about sharing to bother with the grunt work of browser compatibility.
Re:Mona Lisa in pure CSS by iSnow on Thursday October 04, 2012 @04:17AM (#4611390)
Works just fine here in FF 15 - and even looks better than in Chrome, because the stripey distortions are missing.
Re:Mona Lisa in pure CSS by vacri on Wednesday October 03, 2012 @10:04PM (#4610576)
I've always said that recreating the Mona Lisa is the 'Hello World!' of the art community. Curious to see the two combining like this.
Re:Mona Lisa in pure CSS by enos_feedler on Wednesday October 03, 2012 @11:42PM (#4610801)
I thought Lenna was the Hello World of the art community. Or is that the image processing community? :P

http://en.wikipedia.org/wiki/Lenna

Re:Mona Lisa in pure CSS by Fletch137 on Thursday October 04, 2012 @04:19AM (#4611397)
The script that generated the CSS is far more impressive than the image itself, would definitely like a look at that.
Re:Mona Lisa in pure CSS by aw3c2 on Thursday October 04, 2012 @05:04AM (#4611495)
for each pixel coordinate and color, output an offset and color. Not sure how it is impressive.
Re:Mona Lisa in pure CSS by diggan on Thursday October 04, 2012 @03:37AM (#4611305)
How big would the CSS-image of Mona Lisa be compered to a "normal" image with the same resolution and pixel density?
Re:Mona Lisa in pure CSS by jimmyhwang on Wednesday October 03, 2012 @08:37PM (#4610365)
Amazing job! How long did it take and were there any tools you used to make this faster?
Re:Mona Lisa in pure CSS by borplk on Wednesday October 03, 2012 @10:52PM (#4610677)
It's simpler than you might think. Takes less than 20-30 lines of Python. Read the pixels in the image and for each pixel print some parts of the box-shadow CSS with the right numbers... done.
Re:Mona Lisa in pure CSS by acjohnson55 on Thursday October 04, 2012 @06:16AM (#4611633)
No big deal. Let me know when you can do it using VIM syntax highlighting and ASCII
Re:Mona Lisa in pure CSS by dj2stein9 on Wednesday October 03, 2012 @11:27PM (#4610770)
The Da Vinci's of the future will use HTMLx and CSSx instead of paint and canvas.
Re:Mona Lisa in pure CSS by jameshsi on Thursday October 04, 2012 @02:21AM (#4611154)
i actually like this better than the other "pure CSS" examples i've seen. in a sense, i think of this as an interactive lesson to illustrate a box shadow hack that could conceivably be useful
Re:Mona Lisa in pure CSS by lsh on Sunday October 07, 2012 @09:50AM (#4623312)
"This Site Totally Doesn't Work Without JavaScript."

Pure CSS my arse.

Re:Mona Lisa in pure CSS by masonlee on Thursday October 04, 2012 @04:15AM (#4611383)
"Of course, it's not handcrafted" LOL
Re:Mona Lisa in pure CSS by epascarello on Thursday October 04, 2012 @10:29AM (#4612424)
More bytes for a pixelated look!
Re:Mona Lisa in pure CSS by brownBananas on Thursday October 04, 2012 @10:49AM (#4612509)
Better version of Mona Lisa:

http://codepen.io/anon/pen/zbcJq

Re:Mona Lisa in pure CSS by leecGoimik7 on Thursday October 04, 2012 @09:49AM (#4612250)
Doesn't work in Opera 12.
Re:Mona Lisa in pure CSS by christianblais on Wednesday October 03, 2012 @10:45PM (#4610665)
But... why?
Re:Mona Lisa in pure CSS by javajosh on Wednesday October 03, 2012 @08:46PM (#4610388)
Extremely clever!
Re:Mona Lisa in pure CSS by jgv on Wednesday October 03, 2012 @08:25PM (#4610324)
this is insane
Re:Mona Lisa in pure CSS by bashzor on Thursday October 04, 2012 @01:49AM (#4611079)
Oh come on... Let me make you one in HTML4.01! Or HTML5! Or Javascript!

Pixel by pixel... seriously.

Re:Mona Lisa in pure CSS by derleth on Thursday October 04, 2012 @03:07AM (#4611249)
It's in 'pure CSS', yet it requires Javascript.
Re:Mona Lisa in pure CSS by fuddle on Thursday October 04, 2012 @03:09AM (#4611253)
Disgraceful!
Re:Mona Lisa in pure CSS by ejpastorino on Wednesday October 03, 2012 @08:31PM (#4610344)
amazing!!!
Re:Mona Lisa in pure CSS by zawaideh on Wednesday October 03, 2012 @08:32PM (#4610348)
wahhh! box-shadow can do that?! Crazy!