|
1 | | -// Setup the canvas |
2 | | -var type = /(canvas|webgl)/.test(url.type) ? url.type : 'svg'; |
3 | | -var two = new Two({ |
4 | | - type: Two.Types[type], |
5 | | - fullscreen: true, |
6 | | - autostart: true |
7 | | -}).appendTo(document.body); |
8 | | -// document.body.style.background = 'black'; |
| 1 | +var shapes; |
| 2 | +window.onresize = function() { |
| 3 | + setup(); |
| 4 | +} |
9 | 5 |
|
| 6 | +$(function() { |
| 7 | + setup(); |
| 8 | +}); |
10 | 9 |
|
11 | | -var radius = 0, rows = 0, cols = 0, size; |
12 | | -var isMobile = window.matchMedia("only screen and (max-width: 850px)").matches || |
13 | | - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); |
14 | | -var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches; |
15 | | -if(isMobile && !isOtherMediaQuery) { |
16 | | - size = 200; |
17 | | -} else { |
18 | | - size = 150; |
19 | | -} |
20 | | -rows = Math.floor(two.height / size); |
21 | | -cols = Math.floor(two.width / size); |
22 | | -radius = Math.floor(Math.max(two.width, two.height) / Math.max(rows, cols)) / 2; |
23 | | -var flowers = []; |
24 | | -var shapes = makeFlowers(); |
| 10 | +function setup() { |
| 11 | + var height = $('body').height(); |
| 12 | + var width = $('body').width(); |
| 13 | + var size = 150; |
| 14 | + var padding = 50; |
25 | 15 |
|
| 16 | + var isMobile = window.matchMedia("only screen and (max-width: 450px)").matches || |
| 17 | + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); |
| 18 | + var isOtherMediaQuery = window.matchMedia("only screen and (min-width:1080px)").matches; |
| 19 | + if(isMobile && !isOtherMediaQuery) { |
| 20 | + size = 250; |
| 21 | + padding = 250; |
| 22 | + } |
| 23 | + var rows = Math.floor(height / size); |
| 24 | + var cols = Math.floor(width / size); |
| 25 | + var radius = Math.floor(Math.max(width, height) / Math.max(rows - 1, cols - 1)) / 2; |
26 | 26 |
|
27 | 27 | for (var r = 0; r < rows; r++) { |
28 | 28 | // even rows have an offset of 0.5 |
|
0 commit comments