MCPcopy Create free account
hub / github.com/PyQt5/PyQt / initHeader

Function initHeader

QPropertyAnimation/Data/html/js/demo-1.js:10–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8 addListeners();
9
10 function initHeader() {
11 width = window.innerWidth;
12 height = window.innerHeight;
13 target = {x: width/2, y: height/2};
14
15 largeHeader = document.getElementById('large-header');
16 largeHeader.style.height = height+'px';
17
18 canvas = document.getElementById('demo-canvas');
19 canvas.width = width;
20 canvas.height = height;
21 ctx = canvas.getContext('2d');
22
23 // create points
24 points = [];
25 for(var x = 0; x < width; x = x + width/20) {
26 for(var y = 0; y < height; y = y + height/20) {
27 var px = x + Math.random()*width/20;
28 var py = y + Math.random()*height/20;
29 var p = {x: px, originX: px, y: py, originY: py };
30 points.push(p);
31 }
32 }
33
34 // for each point find the 5 closest points
35 for(var i = 0; i < points.length; i++) {
36 var closest = [];
37 var p1 = points[i];
38 for(var j = 0; j < points.length; j++) {
39 var p2 = points[j]
40 if(!(p1 == p2)) {
41 var placed = false;
42 for(var k = 0; k < 5; k++) {
43 if(!placed) {
44 if(closest[k] == undefined) {
45 closest[k] = p2;
46 placed = true;
47 }
48 }
49 }
50
51 for(var k = 0; k < 5; k++) {
52 if(!placed) {
53 if(getDistance(p1, p2) < getDistance(p1, closest[k])) {
54 closest[k] = p2;
55 placed = true;
56 }
57 }
58 }
59 }
60 }
61 p1.closest = closest;
62 }
63
64 // assign a circle to each point
65 for(var i in points) {
66 var c = new Circle(points[i], 2+Math.random()*2, 'rgba(255,255,255,0.3)');
67 points[i].circle = c;

Callers 1

demo-1.jsFile · 0.85

Calls 1

getDistanceFunction · 0.70

Tested by

no test coverage detected