MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / drawLoop

Function drawLoop

docs/js/video_comparison.js:35–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35 function drawLoop() {
36 mergeContext.drawImage(vid, 0, 0, vidWidth, vidHeight, 0, 0, vidWidth, vidHeight);
37 var colStart = (vidWidth * position).clamp(0.0, vidWidth);
38 var colWidth = (vidWidth - (vidWidth * position)).clamp(0.0, vidWidth);
39 mergeContext.drawImage(vid, colStart+vidWidth, 0, colWidth, vidHeight, colStart, 0, colWidth, vidHeight);
40 requestAnimationFrame(drawLoop);
41
42
43 var arrowLength = 0.09 * vidHeight;
44 var arrowheadWidth = 0.025 * vidHeight;
45 var arrowheadLength = 0.04 * vidHeight;
46 var arrowPosY = vidHeight / 10;
47 var arrowWidth = 0.007 * vidHeight;
48 var currX = vidWidth * position;
49
50 // Draw circle
51 mergeContext.arc(currX, arrowPosY, arrowLength*0.7, 0, Math.PI * 2, false);
52 mergeContext.fillStyle = "#FFD79340";
53 mergeContext.fill()
54 //mergeContext.strokeStyle = "#444444";
55 //mergeContext.stroke()
56
57 // Draw border
58 mergeContext.beginPath();
59 mergeContext.moveTo(vidWidth*position, 0);
60 mergeContext.lineTo(vidWidth*position, vidHeight);
61 mergeContext.closePath()
62 mergeContext.strokeStyle = "#AAAAAA";
63 mergeContext.lineWidth = 5;
64 mergeContext.stroke();
65
66 // Draw arrow
67 mergeContext.beginPath();
68 mergeContext.moveTo(currX, arrowPosY - arrowWidth/2);
69
70 // Move right until meeting arrow head
71 mergeContext.lineTo(currX + arrowLength/2 - arrowheadLength/2, arrowPosY - arrowWidth/2);
72
73 // Draw right arrow head
74 mergeContext.lineTo(currX + arrowLength/2 - arrowheadLength/2, arrowPosY - arrowheadWidth/2);
75 mergeContext.lineTo(currX + arrowLength/2, arrowPosY);
76 mergeContext.lineTo(currX + arrowLength/2 - arrowheadLength/2, arrowPosY + arrowheadWidth/2);
77 mergeContext.lineTo(currX + arrowLength/2 - arrowheadLength/2, arrowPosY + arrowWidth/2);
78
79 // Go back to the left until meeting left arrow head
80 mergeContext.lineTo(currX - arrowLength/2 + arrowheadLength/2, arrowPosY + arrowWidth/2);
81
82 // Draw left arrow head
83 mergeContext.lineTo(currX - arrowLength/2 + arrowheadLength/2, arrowPosY + arrowheadWidth/2);
84 mergeContext.lineTo(currX - arrowLength/2, arrowPosY);
85 mergeContext.lineTo(currX - arrowLength/2 + arrowheadLength/2, arrowPosY - arrowheadWidth/2);
86 mergeContext.lineTo(currX - arrowLength/2 + arrowheadLength/2, arrowPosY);
87
88 mergeContext.lineTo(currX - arrowLength/2 + arrowheadLength/2, arrowPosY - arrowWidth/2);
89 mergeContext.lineTo(currX, arrowPosY - arrowWidth/2);
90
91 mergeContext.closePath();
92

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected