PakEntry * XApp::findFileInPak(wstring filename) { string name = w2s(filename); auto gotit = pak_content.find(name); if (gotit == pak_content.end()) { return nullptr; } return &gotit->second; //if (pak_content.count(name) == 0) { // return nullptr; //} //PakEntry *pe = &pak_content[name]; //return pe; }
// Exports this point Curve as a 2D svg path. void PointCurve::export_svg_path(std::ostream& file, Matrix4x4 &P, size_t w, size_t h) { /* <path d="M 100 100 L 300 100 L 200 300 z" fill="red" stroke="blue" stroke-width="3" /> */ // Paths are given as a list of commands (M, L, B) // and coordinate locations. (100, 100) // M means move, with pen up. // L means straight line to, pen down. // H x+ means horizontal line. // V y+ means vertical line. // B // Z means 'close the path' // capitlization matters: // -- CAPITAL means absolute coordinates, // -- lowercase means relative coordinates. // Start of the path element. int len = points.size(); if(len < 2) { cout << "PointCurve: " << "PATH's must contain at least 2 points, it is not long enough." << endl; return; } file << "<path d=\""; // -- Start the curve. Vector2D p0 = w2s(points[0], P, w, h); Vector2D p1 = w2s(points[1], P, w, h); // Positive tangent offset control point from p0. Vector2D c0 = p0;// + Vector4D(tangents[0]); // Negative tangent offset control point from p1. Vector2D c1 = p1 ;//- Vector4D(tangents[1]); file << "M" << p0.x <<","<< p0.y << " "; file << "C" << c0.x <<","<< c0.y << " "; file << c1.x <<","<< c1.y << " "; file << p1.x <<","<< p1.y << " "; for(int i = 2; i < len; i++) { Vector2D pos = w2s(points[i], P, w, h); Vector2D ctrl = pos;// - Vector4D(tangents[i]); file << "S" << ctrl.x <<","<< ctrl.y << " "; file << " " << pos.x <<","<< pos.y << " "; } // Draw the connecting Bezier curve. if(closed) { Vector2D pos = w2s(points[0], P, w, h); Vector2D ctrl = pos;// - Vector4D(tangents[0]); file << "S" << ctrl.x <<","<< ctrl.y << " "; file << " " << pos.x <<","<< pos.y << " "; // file << " z"; // Close with line. } // End of the path element. file << "\"/>" << endl; }