Live data from Hacker News

HTML5 Deck of Cards

pakastin.github.io

101–110 of 165 posts

Re: HTML5 Deck of Cards

#101
post #38

Earlier quoted context omitted.

It's done in CSS3 + JS, so it should be pretty easy. https://desandro.github.io/3dtransforms/examples/card-01.htm... #card.flipped { -webkit-transform: rotateY( 180deg ); -moz-transform: rotateY( 180deg ); -o-transform: rotateY( 180deg ); transform: rotateY( 180deg ); }

Sure but implementing the card back image is more difficult, which is what I think the parent post was getting at, rather than the flipping itself. The rest of the page is implemented without any images, which is neat; you'd have to work some SVG magic or something to create e.g. a Bicycle-esque card back without loading an image.

Displaying an image on a web page shouldn't be that difficult.

I like the svg suggestion.

https://commons.wikimedia.org/wiki/Category:SVG_playing_card...

https://upload.wikimedia.org/wikipedia/commons/d/d4/Card_bac...

Re: HTML5 Deck of Cards

#103
post #40

Earlier quoted context omitted.

Great work, I love this. Here is a quick playing card example with pseudo elemenets view-source: http://www.clarkeology.com/card.html

That’s nice CSS but the HTML is so borked… why not ︎ Or something?

On the "least amount of HTML possible" theme here's a version using only "class", e.g.

http://codepen.io/femto113/pen/avzWJq

Doesn't include the card centers, but does have top and bottom corners.

EDIT: HN doesn't seem to like unicode characters? The class should include the suit symbol.

Re: HTML5 Deck of Cards

#104
post #89

Maybe it's a weird takeaway, but this line is really clever: var suit = i / 13 | 0; That's such a clean way to get a 0, 1, 2 or 3 from each card's `i` and I never would have thought of it.

Putting aside whether this sort of thing is clever and clean or occult and confusing, another pattern of the same ilk is: ~~(i/13)

for me I see `~~` and I think coerce to integer value (the result will be an integer regardless of i's value, 0 if it fails a clean coercion)

Similar to seeing `!!` and thinking true/false coercion.

Re: HTML5 Deck of Cards

#105

This is similar to something my room mate is working on: https://github.com/thejoshwolfe/board-gamer-2d The user can create a JSON string that represents a game (checkers, solitare, dominion, smash up, etc). Then the engine creates cards, tokens, dice, etc. It does not enforce rules but it supports multi player and some rules about visibility to other players. Its intended use case is for testing out new games or exp…

This is actually something you can do with Tabletop Simulator on steam, as I'm using it for that exact purpose. It even uses JSON as the underlying data structure. Granted, it's proprietary and not free.

Re: HTML5 Deck of Cards

#106
nitpick: when fanning out the cards and then clicking on one it should stay in the orientation it was in the fan, it jumps weirdly around.

same when clicking on the top card of a stack, it jumps ~40px.

Re: HTML5 Deck of Cards

#107

Earlier quoted context omitted.

Yes, but it is 18% faster do run the bitwise or on my machine: https://jsperf.com/or-vs-floor/2

And every time a developer sees that, they're going to google "bar javascript" "single bar javascript" "bitwise or javascript" "bitwise or javascript effect" until they figure out WTF is going on. This all to save a fraction of a microsecond on an operation that's called 60 times on the page.

Actually only 52 :D

But yeah, I agree about googling part: I remember having Googled "tilde javascript" and "pipe javascript".. :)

Tilde is useful with indexOf:

if (~array.indexOf(item)) {}

..equals to:

if (array.indexOf(item) > -1) {}

Re: HTML5 Deck of Cards

#109

nitpick: when fanning out the cards and then clicking on one it should stay in the orientation it was in the fan, it jumps weirdly around. same when clicking on the top card of a stack, it jumps ~40px.

That's already on the "todo" list - check out readme ;)

Re: HTML5 Deck of Cards

#110

Earlier quoted context omitted.

Font should be Open Sans.. I have Chrome/Mac and it's working :/

Why spend the time and effort pulling a custom font across the wire if you're only going to use symbols that exist in the web safe fonts included with the browser? Seems kinda wasteful.

Open Sans is used everywhere in the page. Also the buttons on top..
Post reply on HN