Skip to content
Snippets Groups Projects
Commit 7d28ff6f authored by ftomi's avatar ftomi
Browse files

Import animation done

parent 1ef10a7a
No related branches found
No related tags found
No related merge requests found
......@@ -13,10 +13,15 @@ void Animation::openFile(const QString filepath)
{
frames.clear();
frameId = 0;
QTextStream in(&file);
while (!file.atEnd()) {
QString line = file.readLine();
frames.push_back(MxFrame(line));
QString filestr = file.readAll();
int start = 0;
while (1) {
int begin = filestr.indexOf("frame(", start);
int end = filestr.indexOf(")", begin) + 1;
if (begin == -1 || end == -1)
break;
start = end;
frames.push_back(MxFrame(filestr.mid(begin, end - begin)));
}
file.close();
}
......
......@@ -16,7 +16,10 @@ int main(int argc, char *argv[])
return -1;
Alma alma;
Browser browser("/");
Animation anim;
anim.openFile("../asdasd.qp4");
Browser browser("../");
return app.exec();
}
......
#include "mxframe.h"
QVector<QString> explode(const QString& s, const char& c)
{
QString buff{""};
QVector<QString> v;
for(auto n:s)
{
if(n != c) buff+=n; else
if(n == c && buff != "") { v.push_back(buff); buff = ""; }
}
if(buff != "") v.push_back(buff);
return v;
}
QColor MxFrame::qp4strToColor(const QString& str)
{
uint32_t col;
if (str.startsWith("0x"))
{
bool ok = false;
col = str.mid(2).toUInt(&ok, 16);
}
else {
bool ok = false;
col = str.toUInt(&ok);
}
uint8_t blue = (col >> 0) & 0xFF;
uint8_t green = (col >> 8) & 0xFF;
uint8_t red = (col >> 16) & 0xFF;
uint8_t alpha = (col >> 24) & 0xFF;
return QColor(red, green, blue, alpha);
}
MxFrame::MxFrame()
{
}
// frame({pix1, pix2, ...},1000)
MxFrame::MxFrame(const QString &import)
{
//TODO
int posBegin = import.indexOf('{');
int posEnd = import.indexOf('}');
QString line = import.mid(posBegin+1, posEnd - posBegin-1);
line = line.remove(' ');
line = line.remove('\r');
line = line.remove('\n');
line = line.remove('\t');
QStringList data = line.split(',');
for(int i = 0; i < data.size() && i < 26*32; i++)
{
int y = i / 32;
int x = i % 32;
pixels[y][x] = qp4strToColor(data.at(i));
}
int lastcomma = import.lastIndexOf(',');
int lastbracket = import.lastIndexOf(')');
QString alma = import.mid(lastcomma+1,lastbracket-lastcomma-1);
this->length = import.mid(lastcomma+1,lastbracket-lastcomma-1).toUInt();
}
#ifndef MXFRAME_H
#define MXFRAME_H
#include <QVector>
#include <QColor>
#include <QString>
class MxFrame
{
private:
QColor qp4strToColor(const QString& str);
public:
MxFrame();
MxFrame(const QString& import);
......
-- __animeditor__
meta({
audio="",
team="",
title="",
year=2019})
beginclip(32,26,"main")
frame({
0xff00ff00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xffff00ff,
0xffff0000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xffffffff,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0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