mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Move string to buffer converting code to utils
This commit is contained in:
parent
5fe9081df1
commit
e647826095
@ -38,12 +38,9 @@
|
||||
var piskelString = this.getPiskel(name);
|
||||
var key = this.getKey_(name);
|
||||
|
||||
var serializedPiskel = new Uint16Array(piskelString.length);
|
||||
for (var i = 0, length = piskelString.length; i < length; i++) {
|
||||
serializedPiskel[i] = piskelString.charCodeAt(i);
|
||||
}
|
||||
var serializedPiskel = pskl.utils.convertStringToBuffer(piskelString);
|
||||
|
||||
pskl.utils.serialization.Deserializer.deserialize(serializedPiskel.buffer, function (piskel, extra) {
|
||||
pskl.utils.serialization.Deserializer.deserialize(serializedPiskel, function (piskel, extra) {
|
||||
pskl.app.piskelController.setPiskel(piskel);
|
||||
pskl.app.previewController.setFPS(extra.fps);
|
||||
});
|
||||
|
@ -275,4 +275,14 @@ if (!Uint32Array.prototype.fill) {
|
||||
return string;
|
||||
};
|
||||
|
||||
ns.convertStringToBuffer = function(inputString) {
|
||||
var uint16 = new Uint16Array(inputString.length);
|
||||
|
||||
for (var i = 0, length = inputString.length; i < length; i++) {
|
||||
uint16[i] = inputString.charCodeAt(i);
|
||||
}
|
||||
|
||||
return uint16.buffer;
|
||||
};
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user