Skip to content

Commit 9f972f9

Browse files
author
daniel-lundin
committed
Update cards demo
1 parent f972a7e commit 9f972f9

File tree

3 files changed

+49
-25
lines changed

3 files changed

+49
-25
lines changed

docs/cards.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@
2727
}
2828
.card {
2929
position: absolute;
30-
}
31-
.front {
32-
position: absolute;
33-
width: 100%;
34-
height: 100%;
35-
backface-visibility: hidden;
36-
-webkit-backface-visibility: hidden;
37-
border-radius: 10px;
38-
}
39-
.back {
40-
position: absolute;
41-
width: 100%;
42-
height: 100%;
43-
transform: rotateY(180deg);
44-
backface-visibility: hidden;
45-
-webkit-backface-visibility: hidden;
4630
border-radius: 10px;
4731
}
4832
#toolbar {
@@ -60,6 +44,7 @@
6044
<button id="pile_button">Pile</button>
6145
<button id="house_button">House</button>
6246
<button id="wall_button" class="button-primary">Wall</button>
47+
<button id="cylinder_button">Cylinder</button>
6348
</div>
6449

6550
<script src="snabbt.min.js"></script>

docs/cards.js

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,32 @@ var COLORS = randomColor({
2424
var PILE = 1;
2525
var HOUSE = 2;
2626
var WALL = 3;
27+
var CYLINDER = 4;
2728
var current_mode = PILE;
2829

2930
var formation_builders = {};
3031
formation_builders[PILE] = pile_positions;
3132
formation_builders[HOUSE] = centered_house_positions;
3233
formation_builders[WALL] = wall_positions;
34+
formation_builders[CYLINDER] = cylinder_positions;
3335

3436
function create_card(container, index) {
3537
var card = document.createElement('div');
3638
card.className = 'card';
3739
card.style.height = CARD_HEIGHT + 'px';
3840
card.style.width = CARD_WIDTH + 'px';
41+
card.style.background = COLORS[index % COLORS.length];
3942

40-
var front = document.createElement('div');
41-
front.className = 'front';
42-
front.style.background = COLORS[index % COLORS.length];
43+
//var front = document.createElement('div');
44+
//front.className = 'front';
45+
//front.style.background = COLORS[index % COLORS.length];
4346

44-
var back = document.createElement('div');
45-
back.className = 'back';
46-
back.style.background = COLORS[index % COLORS.length];
47+
//var back = document.createElement('div');
48+
//back.className = 'back';
49+
//back.style.background = COLORS[index % COLORS.length];
4750

48-
card.appendChild(front);
49-
card.appendChild(back);
51+
//card.appendChild(front);
52+
//card.appendChild(back);
5053
container.appendChild(card);
5154
return card;
5255
}
@@ -198,6 +201,24 @@ function wall_positions() {
198201
return positions;
199202
}
200203

204+
function cylinder_positions() {
205+
var positions = [];
206+
var start_x = WIDTH / 2;
207+
var start_y = 100;
208+
var radius = 100;
209+
for(var i=0;i<CARD_COUNT;++i) {
210+
var angle = ((i % 10) / 10) * 2 * Math.PI;
211+
var x = Math.cos(angle) * radius + start_x;
212+
var z = Math.sin(angle) * radius;
213+
var y = Math.floor(i / 10) * 1.2 * CARD_HEIGHT + start_y;
214+
positions.push({
215+
position: [x, y, z],
216+
rotation: [0, Math.PI/2 + angle, 0],
217+
});
218+
}
219+
return positions;
220+
}
221+
201222
function build_wall() {
202223
set_mode(WALL);
203224
}
@@ -210,6 +231,7 @@ function build_pile() {
210231
set_mode(PILE);
211232
}
212233

234+
213235
function centered_house_positions() {
214236
// TODO: Actually center
215237
return house_positions(5, 200, BOTTOM, -300);
@@ -224,13 +246,15 @@ function init() {
224246
var buttons = {
225247
"pile_button": PILE,
226248
"house_button": HOUSE,
227-
"wall_button": WALL
249+
"wall_button": WALL,
250+
"cylinder_button": CYLINDER
228251
};
229252

230253
var click_handler = function(key) {
231254
document.getElementById('pile_button').className = '';
232255
document.getElementById('house_button').className = '';
233256
document.getElementById('wall_button').className = '';
257+
document.getElementById('cylinder_button').className = '';
234258
document.getElementById(key).className = 'button-primary';
235259
set_mode(buttons[key]);
236260
};

docs/fpsmeter.min.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)