AldoBaldo (Member)
Guru
Messaggi: 700
Iscritto: 08/01/2015
|
Ciao a te che leggi...
In questi giorni di "pausa natalizia" ho ripreso in mano un programmino che avevo abbozzato qualche tempo fa. L'intenzione è mettere insieme un "attrezzo" che legga un file in formato SVG e ne estragga i dati dei percorsi identificati dai tag <path>.
Al momento, il programma è nel mio "stile", cioè pasticciato, però pare funzionare e genera file con un aspetto di questo tipo...
Codice sorgente - presumibilmente C/C++ |
// PERCORSO #1 (id: "4_4gs"; punti: 92) ========================================
const size_t kQPtCoo_4_4gs_1 = 92;
// coordinate dei punti
REAL coo_4_4gs_1[2*kQPtCoo_4_4gs_1] = {
4.700, -2.959,
3.235, -2.939, 2.089, -2.674, 1.263, -2.165,
0.436, -1.655, 0.016, -1.020, 0.001, -0.260,
-0.015, 0.494, 0.327, 1.136, 1.026, 1.667,
1.724, 2.198, 2.876, 2.475, 4.480, 2.499,
6.233, 2.479, 7.461, 2.209, 8.164, 1.690,
8.867, 1.170, 9.205, 0.520, 9.179, -0.260,
9.161, -0.778, 8.924, -1.240, 8.467, -1.645,
8.010, -2.049, 7.441, -2.368, 6.760, -2.602,
6.078, -2.835, 5.392, -2.954, 4.700, -2.959,
2.419, -1.601,
2.553, -1.961, 2.785, -2.197, 3.114, -2.309,
3.444, -2.421, 3.785, -2.472, 4.140, -2.461,
4.639, -2.450, 5.090, -2.295, 5.493, -1.997,
5.896, -1.700, 6.217, -1.329, 6.455, -0.884,
6.694, -0.440, 6.816, 0.009, 6.821, 0.460,
6.821, 0.531, 6.817, 0.600, 6.809, 0.668,
6.801, 0.736, 6.792, 0.800, 6.781, 0.861,
6.731, 1.132, 6.626, 1.359, 6.466, 1.541,
6.306, 1.723, 6.091, 1.849, 5.821, 1.921,
5.711, 1.951, 5.601, 1.972, 5.491, 1.984,
5.380, 1.996, 5.270, 2.002, 5.160, 2.001,
5.061, 2.002, 4.964, 1.996, 4.870, 1.984,
4.776, 1.972, 4.679, 1.951, 4.580, 1.921,
4.399, 1.861, 4.221, 1.782, 4.047, 1.684,
3.873, 1.586, 3.711, 1.471, 3.559, 1.341,
3.479, 1.271, 3.400, 1.196, 3.322, 1.116,
3.244, 1.036, 3.170, 0.951, 3.099, 0.861,
2.884, 0.604, 2.704, 0.307, 2.561, -0.032,
2.418, -0.371, 2.344, -0.714, 2.339, -1.060,
2.338, -1.151, 2.344, -1.241, 2.356, -1.331,
2.368, -1.421, 2.389, -1.511, 2.419, -1.601
}; // fine REAL coo_4_4gs_1[]
// tipologie dei punti
BYTE ppt_4_4gs_1[kQPtCoo_4_4gs_1] = {
PathPointTypeStart,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeStart,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier
}; // fine BYTE ppt_4_4gs_1[]
// fine percorso #1 (id: "4_4gs"; punti: 92)
// PERCORSO #2 (id: "2_4gs"; punti: 83) ========================================
const size_t kQPtCoo_2_4gs_2 = 83;
// coordinate dei punti
REAL coo_2_4gs_2[2*kQPtCoo_2_4gs_2] = {
2.239, 2.899,
3.493, 2.866, 4.452, 2.590, 5.116, 2.072,
5.781, 1.553, 6.234, 0.992, 6.476, 0.387,
6.718, -0.218, 6.833, -0.667, 6.819, -0.961,
6.819, -17.499,
6.221, -17.499,
6.221, -2.360,
6.020, -2.531, 5.777, -2.663, 5.493, -2.757,
5.210, -2.850, 4.892, -2.898, 4.541, -2.899,
3.395, -2.873, 2.490, -2.627, 1.825, -2.160,
1.161, -1.693, 0.689, -1.159, 0.409, -0.559,
0.129, 0.042, -0.007, 0.555, 0.001, 0.981,
0.016, 1.594, 0.231, 2.067, 0.648, 2.397,
1.064, 2.728, 1.595, 2.895, 2.239, 2.899,
2.780, -1.041,
3.346, -1.367, 3.819, -1.600, 4.198, -1.739,
4.577, -1.877, 4.884, -1.945, 5.121, -1.941,
5.338, -1.939, 5.513, -1.894, 5.646, -1.806,
5.779, -1.719, 5.884, -1.604, 5.961, -1.461,
6.002, -1.391, 6.035, -1.320, 6.061, -1.248,
6.087, -1.176, 6.100, -1.100, 6.101, -1.021,
6.115, -0.799, 5.967, -0.527, 5.659, -0.205,
5.350, 0.117, 4.797, 0.539, 4.000, 1.061,
3.482, 1.406, 3.038, 1.651, 2.667, 1.794,
2.297, 1.937, 1.987, 2.006, 1.739, 2.001,
1.501, 1.997, 1.307, 1.945, 1.159, 1.846,
1.011, 1.747, 0.897, 1.625, 0.819, 1.481,
0.778, 1.410, 0.745, 1.336, 0.719, 1.258,
0.693, 1.180, 0.680, 1.101, 0.679, 1.021,
0.666, 0.773, 0.816, 0.482, 1.129, 0.148,
1.442, -0.187, 1.992, -0.583, 2.780, -1.041
}; // fine REAL coo_2_4gs_2[]
// tipologie dei punti
BYTE ppt_2_4gs_2[kQPtCoo_2_4gs_2] = {
PathPointTypeStart,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeLine,
PathPointTypeLine,
PathPointTypeLine,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeStart,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier,
PathPointTypeBezier, PathPointTypeBezier, PathPointTypeBezier
}; // fine BYTE ppt_2_4gs_2[]
// fine percorso #2 (id: "2_4gs"; punti: 83)
|
Gli array possono essere usati direttamente per creare con C++ in Gdi+ degli oggetti di classe GraphicsPath che riproducono i profili descritti dai <path> SVG.
Se qualche anima buona volesse darmi qualche suggerimento, sarei più che lieto di scambiare quattro chiacchiere.
A presto, spero!
P.S. il codice del programma è reperibile qui:
https://dopiest-curtains.000webhostapp.com/
Ultima modifica effettuata da AldoBaldo il 28/12/2017 alle 22:50
ATTENZIONE! Sono un hobbista e l'affidabilità delle mie conoscenze informatiche è molto limitata. Non prendere come esempio il codice che scrivo, perché non ho alcuna formazione accademica e rischieresti di apprendere pratiche controproducenti. |