-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremiereTiling.js
86 lines (63 loc) · 2.76 KB
/
premiereTiling.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function calcPremiereTiles(elementID) {
var urlParams = new URLSearchParams(window.location.search)
if (urlParams.has("framex") && urlParams.has("framey")
&& urlParams.has("sourcex") && urlParams.has("sourcey")
&& urlParams.has("tilesx") && urlParams.has("tilesy")) {
var framex = parseInt(urlParams.get("framex"));
var framey = parseInt(urlParams.get("framey"));
var sourcex = parseInt(urlParams.get("sourcex"));
var sourcey = parseInt(urlParams.get("sourcey"));
var tilesx = parseInt(urlParams.get("tilesx"));
var tilesy = parseInt(urlParams.get("tilesy"))
var scale = parseInt(urlParams.get("scale"));
var hoff = parseInt(urlParams.get("hoffset"));
var voff = parseInt(urlParams.get("voffset"));
var tiles=[];
var index=0;
var tileWidth=framex/tilesx;
var scaledWidth=sourcex*scale/100;
var cropWidthPercent=(1-tileWidth/scaledWidth)*0.5*100;
var tileHeight=framey/tilesy;
var scaledHeight=sourcey*scale/100;
var cropHeightPercent=(1-tileHeight/scaledHeight)*0.5*100;
var left=(cropWidthPercent+hoff).toFixed(2);
var top=(cropHeightPercent-voff).toFixed(2);
var right=(cropWidthPercent-hoff).toFixed(2);
var bottom=(cropHeightPercent+voff).toFixed(2);
console.log(cropWidthPercent,cropHeightPercent);
var positions=[];
var rowItems=[];
for (var i=0; i<tilesx*tilesy; i++){
column=i%tilesx;
row=Math.floor(i/tilesx);
console.log(column,row);
x=Math.round((framex/tilesx)*column+(0.5*framex/tilesx)+hoff*scaledWidth/100);
y=Math.round((framey/tilesy)*row+(0.5*framey/tilesy)+voff*scaledHeight/100);
strItem="";
strItem+="x:"
strItem+=x.toString()
strItem+=" y:"
strItem+=y.toString()
rowItems.push(strItem)
// console.log(x,y);
if (column==tilesx-1 && i!=0){
positions.push(rowItems.join(" | "))
rowItems=[];
}
}
// hHex = hRes.toString(16).padStart(4, "0")
// hHex = hHex.slice(2, 4).concat(" ", hHex.slice(0, 2)).toUpperCase()
// vHex = vRes.toString(16).padStart(4, "0")
// vHex = vHex.slice(2, 4).concat(" ", vHex.slice(0, 2)).toUpperCase()
console.log(positions)
strOut=positions.join("<br>")
strOut=[
["Left: ",left,"%"].join(""),
["Top: ",top,"%"].join(""),
["Right: ",right,"%"].join(""),
["Bottom: ",bottom,"%"].join("")
].join("<br>")+"<br><br>"+strOut
console.log(strOut)
document.getElementById(elementID).innerHTML = strOut
}
}