If I draw something in Illustrator and extract it with AI2Canvas I want it to be customizable so I wrote this simple program. It adds two variables: one to resize and one to shift the path coordinate.
#include <fstream>
#include <regex>
#include <string>
int main(int argc, char *argv[]) {
std::string path = argv[1];
std::ifstream input(path);
std::size_t found_name = path.find_last_of("/\\");
std::size_t found_extension = path.find_last_of(".");
const int steps = found_extension - found_name - 1;
std::ofstream output(path.substr(found_name + 1, steps) + ".txt");
std::regex pattern("(\\d+(\\.\\d+)?), (\\d+(\\.\\d+)?)");
std::string in;
while (!input.eof()) {
std::getline(input, in);
output << std::regex_replace(in, pattern, "($1 * resize.x) + pos.x, ($3 * resize.y) + pos.y")
<< '\n';
}
return 0;
}
Test file Raw: https://pastebin.com/fDh9qbd8
Test file Resolved: https://pastebin.com/R2gpXD8Q
ctx.translate
andctx.rotate
before the drawing commands. \$\endgroup\$