-
Notifications
You must be signed in to change notification settings - Fork 0
/
animateconversion.html
251 lines (237 loc) · 13.3 KB
/
animateconversion.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html>
<html lang="en" style="background-color:rgb(17, 5, 29) ;">
<head>
<title>Adobe Animate to Incredibox Converter Fullbody - BOOGO x SEAL</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Boogo and Seal make Incredibox Mods and Tools.">
<link rel="apple-touch-icon" sizes="180x180" href="../icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../icons/favicon-16x16.png">
<link rel="manifest" href="../icons/site.webmanifest">
<link rel="shortcut icon" href="../icons/favicon.ico">
<meta name="msapplication-TileColor" content="#603cba">
<meta name="msapplication-config" content="../icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<meta charset="UTF-8">
<meta property="og:type" content="website">
<meta property="og:site_name" content="BOOGO x SEAL">
<meta property="og:title" content="Adobe Animate to Incredibox Converter Fullbody" />
<meta property="og:image" content="https://boogoxseal.xyz/assets/banner.png" />
<meta property="twitter:image:src" content="https://boogoxseal.xyz/assets/banner.png" />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="Boogo and Seal make Incredibox Mods and Tools.">
<meta name="og:image:alt" content="Boogo and Seal make Incredibox Mods and Tools.">
<meta name="og:description" content="Boogo and Seal make Incredibox Mods and Tools.">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/css/bootstrap.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/6.0.1/mdb.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="../css/topnav.css">
<link rel="stylesheet" href="../css/required.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js" integrity="sha512-XMVd28F1oH/O71fzwBnV7HucLxVwtxf26XV8P4wPk26EDxuGZ91N8bsOttmnomcCD3CS5ZMRL50H0GgOHvegtg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="../js/general-functions.js"></script>
<style>
td{text-align:center}.th-custom{overflow:auto;font-weight:200;text-align:center;padding-left:5px;padding-right:5px;font-size:28px;margin:10px}body{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#fff;overflow:auto;font-family:monospace;font-weight:500;margin-top:15vh}
</style>
</head>
<body style="background-color:rgb(17, 5, 29) ;">
<div class="topnav">
<a href="../">Home</a>
<a class="active" href="./">Tools</a>
<a href="../mods">Mods</a>
<a href="../about">About Us</a>
<a href="https://sealldeveloper.github.io/incredibox-downloads-index/">Mod Index</a>
<a href='https://ko-fi.com/K3K3LWCC7' target='_blank'><img height='24' style='border:0px;height:24px;' src='https://storage.ko-fi.com/cdn/kofi3.png?v=3' alt='Buy Me a Coffee at ko-fi.com' /></a>
</div>
<div class="container mt-3" style="background-color:rgb(29, 8, 49) ; overflow:hidden; padding-bottom:40px;height:100%;" >
<h1 class="m-4 mt-3">Adobe Animate to Incredibox Converter - Fullbody</h1>
<small class="m-4" style="color:#fac769">WARNING: This tool was designed to work on <b>Firefox</b> so errors on Chromium based browsers are expected.</small>
<div id="form">
<h3 class="m-3">Options</h3>
<div class="form-group required col-md-5 m-4">
<label for="spritesheet">Spritesheet</label>
<input class="form-control" type="file" id="spritesheet" required="true" accept="image/PNG"></input>
</div>
<div class="form-group required col-md-5 m-4">
<label for="json">JSON</label>
<input class="form-control" type="file" id="json" required="true" accept="application/json"></input>
</div>
<div class="form-group required col-md-5 m-4">
<label for="res">HD/Non-HD</label>
<select id="res" class="form-control form-select" required="true">
<optgroup>
<option value="hd">HD</option>
<option value="non-hd" selected="">Non-HD</option>
</optgroup>
</select>
</div>
<div class="form-group required col-md-5 m-4">
<label for="rowcount">Amount of heads per row (optional)</label><br>
<small style="color:#999999">Only use this if you want to modify how many heads there are per row, for aesthetic purposes.</small>
<input class="form-control" type="number" id="rowcount" placeholder="5"></input>
</div>
<div class="form-group m-4 mt-4" id="submit">
<small style="color:lightskyblue">NOTE: This will automatically resize the width of your polo to fit, so if incorrectly sized the polo may come out taller/shorter than expected to fix centering.</small>
<br>
<input class="btn btn-primary" type="submit" value="Submit" id="submission"></input>
</div>
<br>
<hr class="hr hr-blurry" />
<br>
<div class="m-4">
<h3>How to export to Spritesheet and JSON from Adobe Animate?</h3>
<span>
1. After you've finished your symbol, right click on it and select the 'Generate Sprite Sheet...' button.<br><br>
2. A menu will appear, the follow settings should be set:<br>
- Image Dimensions: Auto size<br>
- Image format: PNG 32 bit<br>
- Background Color: Transparent<br>
- Algorithm: Basic<br>
- Data format: JSON<br>
- Rotate: Disabled<br>
- Trim: Disabled<br>
- Stack frames: Enabled<br>
- Border padding: 0px<br>
- Shape padding: 0px<br><br>
3. Press 'Export' ion the bottom right corner of the menu, a PNG and a JSON should be outputted to the output directory. <br>These are the files that should be used
</span>
</div>
<canvas id="spritesheetcanvas" class="visually-hidden"></canvas>
<canvas id="fixedspritesheetcanvas" class="visually-hidden"></canvas>
<div id="jsoncontent" class="visually-hidden"></div>
<div id="spritesheetcontent" class="visually-hidden"></div>
</div>
</div>
<script>
seperate_count=0
function download(uri, name) {
var link = document.createElement("a");
link.download = name;
link.href = uri;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
delete link;
}
function LoadImageFromDisk(input, callback) {
try{
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.readAsDataURL(input.files[0]);
reader.onload = function (e) {
callback(reader.result)
};
} else {
callback(undefined)
}
} catch (e) {
console.log(e)
}
}
function submit() {
if ( ! window.FileReader ) {
return alert( 'FileReader API is not supported by your browser.' );
}
jsondata=""
error_log=""
$( '#jsoncontent' ).empty()
$( '#spritesheetcontent' ).empty()
var jsoninput = $('#json')[0];
var imginput = $('#spritesheet')[0];
LoadJSONFromDisk(jsoninput, (text) => {
if (text === undefined) error_log += "No JSON Selected!\n"
jsondata=JSON.parse(text)
})
LoadImageFromDisk(imginput, (imgdata) => {
if (imgdata === undefined) error_log += "No Spritesheet Selected!\n"
frame0width = jsondata.frames[Object.keys(jsondata.frames)[0]].sourceSize.w
frame0height = jsondata.frames[Object.keys(jsondata.frames)[0]].sourceSize.h
canvas=$('#spritesheetcanvas')[0]
ctx= canvas.getContext('2d')
var img = new Image;
img.onload = function(){
ctx.canvas.width = this.width
ctx.canvas.height = this.height
ctx.drawImage(this,0,0);
};
img.src = imgdata;
newframes=[]
headcoords=[]
heads=[]
prev=[]
headcount=0
isHd=($('#res').find(':selected').val()=="hd") ? true : false
widthfix = (isHd?164*2:164)/frame0width
frame0height = frame0height*widthfix
frame0width=(isHd?164*2:164)
for (i in Object.keys(jsondata.frames)) {
frame=jsondata.frames[Object.keys(jsondata.frames)[i]].frame
if (!prev.includes(JSON.stringify(frame))) {
headcount++
prev.push(JSON.stringify(frame))
temphead = canvas.getContext('2d').getImageData(frame.x,frame.y,frame0width,frame0height)
headcoords.push({"x":frame.x,"y":frame.y})
heads.push(temphead)
}
newframes.push({"prop":`${frame.x},${frame.y},0,0`})
}
count=0
newcanvas=$('#fixedspritesheetcanvas')[0]
newctx = newcanvas.getContext('2d')
rowcount = (Number($('#rowcount').val()) === 0) ? 5 : Number($('#rowcount').val())
newctx.canvas.width = frame0width*rowcount
newctx.canvas.height = frame0height*(Math.ceil(headcount/rowcount)+1)
// Default
drawLabelledBox(newctx,"red",0,0,frame0width,frame0height,isHd?58*2:58,frame0height/2,"Default",isHd?15*2:15)
// Headless
drawLabelledBox(newctx,"lime",frame0width,0,frame0width,frame0height,isHd?(55*2)+frame0width:55+frame0width,frame0height/2,"Headless",isHd?15*2:15)
// Siloette
drawLabelledBox(newctx,"#348af9",frame0width*2,0,frame0width,frame0height,isHd?(48*2)+(frame0width*2):48+frame0width*2,frame0height/2,"Silhouette",isHd?15*2:15)
// "Watermark"
newctx.font = `${isHd?13*2:13}px CozetteVector`;
newctx.fillText(`sealldeveloper\'s Animate Converter - Heads`,0,isHd?12*2:12)
currentx=0
currenty=frame0height
modified_indexes=[]
for (i in range(headcount)) {
i=Number(i)
count++
x = headcoords[i].x
y = headcoords[i].y
temphead = heads[i]
newcanvas.getContext('2d').putImageData(temphead,currentx,currenty)
fc = 0
for (f in newframes) {
f=newframes[f]
if (f.prop == `${x},${y},0,0` && !modified_indexes.includes(fc)) {
modified_indexes.push(fc)
newframes[fc].prop = `${isHd?Math.round(currentx/2):Math.round(currenty)},${isHd?Math.round(currentx/2):Math.round(currenty)},0,0`
}
fc++
}
currenty = (count%rowcount === 0) ? currenty+frame0height : currenty
currentx = (count%rowcount === 0) ? 0 : currentx+frame0width
}
if (seperate_count == 2){
newjsondata={"_generated-by-boogoxseal.xyz-tools":"thanks-for-using-them","percentageMax":"0.2","totalFrame":`${newframes.length}`,"width":`${frame0width}`,"height":`${frame0height}`,"headHeight":`${frame0height}`,"arrayFrame":newframes}
var zip = new JSZip();
zip.file(`generated.json`,JSON.stringify(newjsondata))
zip.file(`generated-sprite.png`, zipImg('fixedspritesheetcanvas'), {base64:true})
zip.generateAsync({type:"base64"}).then(function (base64) {
window.open("data:application/zip;base64," + base64);
});
}
seperate_count++
})
if (error_log !== "") alert("Error Log:\n"+error_log)
}
$('#submission').on('click', async function(){
seperate_count=1
await submit()
await waitFor(_ => seperate_count === 2);
await submit()
})
</script>
<h3 style="padding-bottom:5px"></h3>
<h3 style="text-align:center;font-size:10px">Made by <a style="font-size:10px"target="_blank" rel="noopener noreferrer" class="enter">seal</a></h3>
</body>
</html>