forked from Mishcatt/VTF-Editor
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
165 lines (159 loc) · 7.41 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>VTF Spray Converter</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="vtf.css" />
</head>
<body>
<h4>VTF Spray Converter for Team Fortress 2</h4>
<div id = "main">
<br />
<input type="file" id="files" name="files[]" accept="image/*,.tga,video/*" onchange="handleFileSelect(event)" multiple/>
<br /><br />
Works best with same size images (with transparency or not).<br />
Smaller images will be centered.<br />
<p>
To generate a fading spray: enable mipmaps, load a main picture,<br />
and then choose another picture under a mipmap of choice.<br />
</p>
<p>
To generate an animated spray: select multiple images in the file browser.<br />
The frames are displayed in the same order as they appear in the file browser,<br />
and each one lasts for 0.2s. Animated GIFs and video files are also supported.
</p>
To download the final result as a spray, click the "Save as VTF" button.<br /><br />
<div id="resolutionNotice" style="visibility: hidden">Using 1024x1020, no mipmaps</div>
<select class="textInput" value="auto" id="widthSetting" onchange="setResolution()">
<option value=auto>Auto</option>
<option value=1024>1024</option>
<option value=768>768</option>
<option value=720>720</option>
<option value=512>512</option>
<option value=256>256</option>
<option value=128>128</option>
<option value=64>64</option>
<option value=32>32</option>
<option value=16>16</option>
<option value=8>8</option>
<option value=4>4</option>
<option value=custom>Custom</option>
</select>
<input class="textInput" value="1024" id="widthSettingCus" onchange="setResolution()" type="text" style="width:50px; display: none"/>
<!--<input class="textInput" value="1024" id="widthSetting" onchange="setResolution()" type="text" list="resolutionlist" style="width:50px"/>-->
x
<!--<input class="textInput" value="1024" id="heightSetting" onchange="setResolution()" type="text" list="resolutionlist" style="width:50px"/>-->
<select class="textInput" value="auto" id="heightSetting" onchange="setResolution()">
<option value=auto>Auto</option>
<option value=1024>1024</option>
<option value=768>768</option>
<option value=720>720</option>
<option value=512>512</option>
<option value=256>256</option>
<option value=128>128</option>
<option value=64>64</option>
<option value=32>32</option>
<option value=16>16</option>
<option value=8>8</option>
<option value=4>4</option>
<option value=custom>Custom</option>
</select>
<input class="textInput" value="1024" id="heightSettingCus" onchange="setResolution()" type="text" style="width:50px; display: none"/>
<datalist id="resolutionlist">
<option value=1024>1024</option>
<option value=864>864</option>
<option value=720>720</option>
<option value=512>512</option>
<option value=256>256</option>
<option value=128>128</option>
<option value=64>64</option>
<option value=32>32</option>
<option value=16>16</option>
<option value=8>8</option>
<option value=4>4</option>
<option value=custom>custom</option>
</datalist>
<br />
<input type="checkbox" name="mipmaps" id="mipmapsCheck" disabled onclick="mipmapclick = true" onchange="onPropertyChange()">Generate Mipmaps<br />
<input type="checkbox" name="rescale" id="rescaleCheck" onchange="setResolution()" checked>Scale to fit<br />
<input type="checkbox" name="singleFrame" id="singleFrame" onchange="setSingleFrame()">Use single image for animation<br />
<p id="filesizee"></p>
<p>Image Encode settings:</p>
Texture format: <select class="textInput" value=13 id="format" onchange="setOutputType(this)">
<option value=0>RGBA8888</option>
<option value=2>RGB888</option>
<option value=4>RGB565</option>
<option value=21>BGRA5551</option>
<option value=19>BGRA4444</option>
<option value=13 selected>DXT1 (one-bit alpha) (recommended)</option>
<option value=15>DXT5 (eight-bit alpha) (required for images with transparency)</option>
</select><br/>
Sampling method: <select class="textInput" value="0" id="sampling">
<option value=0>Default (recommended)</option>
<option value=1>Point (for pixel arts)</option>
<option value=2>Trilinear</option>
<option value=16>Anisotropic</option>
</select>
<div id = "ditherBlock"><input type="checkbox" name="dither" id="ditherCheck" onchange="onPropertyChange()" checked/>Use dithering</div>
<div id = "dxtSettings" >
<div class="setting">
Compression quality: <select class="textInput" value=2 id="dxtquality" onchange="onPropertyChange()">
<option value=0>Fast</option>
<option value=1>Normal</option>
<option value=2 selected>Slow (recommended)</option>
<option value=3>Very slow</option>
</select><br/>
</div>
</div>
<p id="progress"></p>
<br /><br />
File name (without extension): <input type="text" name="outputFilename" id="outputFilename" value="spray" pattern="[^\\/:\x22*?<>|]+">
<br /><br />
<button id="saveButton" type="button" onclick="createVTF()" disabled>Save as VTF</button>
<button id="saveButtonVMT" type="button" onclick="downloadVMT()" disabled>Save as VMT</button><br />
<br />
Preview:
<div id="contentWrapper">
<canvas id="preview"></canvas>
<canvas id="canvas" style="display: none"></canvas>
<canvas id="tempCanvas"></canvas>
<div id="frames"></div>
</div>
<input type="file" id="files0" name="files[]" accept="image/*,.tga,video/*" onchange="changeMipmap(event,0)" disabled multiple/>
<div id="mipmaps" style="display: none"></div>
<br /><br />
Changelog:<br /><br />
2024-05-05: extra wording changes, added warning about file name extension<br />
2024-04-19: removed Linux transparency warning due to TF2 64-bit + Vulkan update, plus some wording changes<br />
2019-09-30: added video import support and better gif support<br/>
2018-08-19: added animated spray support and new texture formats<br />
2017-01-05: mipmap generation and modification (fading sprays)<br />
2016-11-25: image scaling for disproportionate sprays<br />
2016-11-24: added resolution settings, minor solid color changes<br />
2016-11-22: added conversion settings<br />
2016-11-21: fixed swapped blocks, improved color handling<br />
2016-11-20: fixed color errors with almost-black blocks<br />
<br />
</div>
<div id = "videoImporter" style="display:none">
<H4>Video import settings</H4>
<span id="startTimeLb">Start frame:</span><input class="textInput" value="0" id="startTimeIn" type="number" style="width:50px;"/><br />
<span id="endTimeLb">End frame:</span><input class="textInput" value="0" id="endTimeIn" type="number" style="width:50px;"/><br />
Playback speed:<input class="textInput" value="1" id="fpsIn" type="number" style="width:50px;"/>
<input type="checkbox" name="allFramesIn" id="allFramesIn" onchange="document.getElementById('fpsIn').disabled = this.checked">
<span id="allFramesLb">Import all frames</span></br>
<button id="videoImporterAccept" type="button" onclick="clipImport()">Import</button><br />
<span id="videoImporterNotice">You might need to disable hardware acceleration in your browser if import fails or to improve performance.</span>
<span id="videoImporterProg"></span></br>
</div>
</div>
<script src="tga.js" type="text/javascript"></script>
<script src="libgif.js" type="text/javascript"></script>
<script src="dither.js" type="text/javascript"></script>
<script src="quantize.js" type="text/javascript"></script>
<script src="dxt.js" type="text/javascript"></script>
<script src="vtf.js" type="text/javascript"></script>
</body>
</head>