mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-27 13:34:19 -04:00
AZTEC: fix bit-stuffing; AZTECRUNE: fix >= 128; DATAMATRIX: eod shift -> 0 pad; Qt6
This commit is contained in:
parent
90012ab23f
commit
943ba79866
53 changed files with 2324 additions and 913 deletions
|
@ -41,7 +41,7 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
void pick_colour(int colour, char colour_code[]) {
|
||||
static void pick_colour(int colour, char colour_code[]) {
|
||||
switch(colour) {
|
||||
case 1: // Cyan
|
||||
strcpy(colour_code, "00ffff");
|
||||
|
@ -119,12 +119,14 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
int error_number = 0;
|
||||
const char *locale = NULL;
|
||||
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
|
||||
float radius;
|
||||
float previous_diameter;
|
||||
float radius, half_radius, half_sqrt3_radius;
|
||||
int i;
|
||||
char fgcolour_string[7];
|
||||
char bgcolour_string[7];
|
||||
int bg_alpha = 0xff;
|
||||
int fg_alpha = 0xff;
|
||||
float fg_alpha_opacity = 0.0f, bg_alpha_opacity = 0.0f;
|
||||
const char *font_family = "Helvetica, sans-serif";
|
||||
int bold;
|
||||
|
||||
|
@ -149,9 +151,15 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
|
||||
if (strlen(symbol->fgcolour) > 6) {
|
||||
fg_alpha = (16 * ctoi(symbol->fgcolour[6])) + ctoi(symbol->fgcolour[7]);
|
||||
if (fg_alpha != 0xff) {
|
||||
fg_alpha_opacity = (float) (fg_alpha / 255.0);
|
||||
}
|
||||
}
|
||||
if (strlen(symbol->bgcolour) > 6) {
|
||||
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
|
||||
if (bg_alpha != 0xff) {
|
||||
bg_alpha_opacity = (float) (bg_alpha / 255.0);
|
||||
}
|
||||
}
|
||||
|
||||
html_len = strlen((char *)symbol->text) + 1;
|
||||
|
@ -204,7 +212,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
if (bg_alpha != 0) {
|
||||
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\"", (int) ceil(symbol->vector->width), (int) ceil(symbol->vector->height), bgcolour_string);
|
||||
if (bg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) bg_alpha / 255.0);
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity);
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
}
|
||||
|
@ -217,63 +225,74 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
fprintf(fsvg, " fill=\"#%s\"", colour_code);
|
||||
}
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
rect = rect->next;
|
||||
}
|
||||
|
||||
previous_diameter = radius = half_radius = half_sqrt3_radius = 0.0f;
|
||||
hex = symbol->vector->hexagons;
|
||||
while (hex) {
|
||||
radius = hex->diameter / 2.0;
|
||||
if (previous_diameter != hex->diameter) {
|
||||
previous_diameter = hex->diameter;
|
||||
radius = (float) (0.5 * previous_diameter);
|
||||
half_radius = (float) (0.25 * previous_diameter);
|
||||
half_sqrt3_radius = (float) (0.43301270189221932338 * previous_diameter);
|
||||
}
|
||||
if ((hex->rotation == 0) || (hex->rotation == 180)) {
|
||||
ay = hex->y + (1.0 * radius);
|
||||
by = hex->y + (0.5 * radius);
|
||||
cy = hex->y - (0.5 * radius);
|
||||
dy = hex->y - (1.0 * radius);
|
||||
ey = hex->y - (0.5 * radius);
|
||||
fy = hex->y + (0.5 * radius);
|
||||
ay = hex->y + radius;
|
||||
by = hex->y + half_radius;
|
||||
cy = hex->y - half_radius;
|
||||
dy = hex->y - radius;
|
||||
ey = hex->y - half_radius;
|
||||
fy = hex->y + half_radius;
|
||||
ax = hex->x;
|
||||
bx = hex->x + (0.86 * radius);
|
||||
cx = hex->x + (0.86 * radius);
|
||||
bx = hex->x + half_sqrt3_radius;
|
||||
cx = hex->x + half_sqrt3_radius;
|
||||
dx = hex->x;
|
||||
ex = hex->x - (0.86 * radius);
|
||||
fx = hex->x - (0.86 * radius);
|
||||
ex = hex->x - half_sqrt3_radius;
|
||||
fx = hex->x - half_sqrt3_radius;
|
||||
} else {
|
||||
ay = hex->y;
|
||||
by = hex->y + (0.86 * radius);
|
||||
cy = hex->y + (0.86 * radius);
|
||||
by = hex->y + half_sqrt3_radius;
|
||||
cy = hex->y + half_sqrt3_radius;
|
||||
dy = hex->y;
|
||||
ey = hex->y - (0.86 * radius);
|
||||
fy = hex->y - (0.86 * radius);
|
||||
ax = hex->x - (1.0 * radius);
|
||||
bx = hex->x - (0.5 * radius);
|
||||
cx = hex->x + (0.5 * radius);
|
||||
dx = hex->x + (1.0 * radius);
|
||||
ex = hex->x + (0.5 * radius);
|
||||
fx = hex->x - (0.5 * radius);
|
||||
ey = hex->y - half_sqrt3_radius;
|
||||
fy = hex->y - half_sqrt3_radius;
|
||||
ax = hex->x - radius;
|
||||
bx = hex->x - half_radius;
|
||||
cx = hex->x + half_radius;
|
||||
dx = hex->x + radius;
|
||||
ex = hex->x + half_radius;
|
||||
fx = hex->x - half_radius;
|
||||
}
|
||||
fprintf(fsvg, " <path d=\"M %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f L %.2f %.2f Z\"", ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy);
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
hex = hex->next;
|
||||
}
|
||||
|
||||
previous_diameter = radius = 0.0f;
|
||||
circle = symbol->vector->circles;
|
||||
while (circle) {
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\"", circle->x, circle->y, circle->diameter / 2.0);
|
||||
if (previous_diameter != circle->diameter) {
|
||||
previous_diameter = circle->diameter;
|
||||
radius = (float) (0.5 * previous_diameter);
|
||||
}
|
||||
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\"", circle->x, circle->y, radius);
|
||||
|
||||
if (circle->colour) {
|
||||
fprintf(fsvg, " fill=\"#%s\"", bgcolour_string);
|
||||
if (bg_alpha != 0xff) {
|
||||
// This doesn't work how the user is likely to expect - more work needed!
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) bg_alpha / 255.0);
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", bg_alpha_opacity);
|
||||
}
|
||||
} else {
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
|
||||
}
|
||||
}
|
||||
fprintf(fsvg, " />\n");
|
||||
|
@ -290,7 +309,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
|
|||
fprintf(fsvg, " font-weight=\"bold\"");
|
||||
}
|
||||
if (fg_alpha != 0xff) {
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", (float) fg_alpha / 255.0);
|
||||
fprintf(fsvg, " opacity=\"%.3f\"", fg_alpha_opacity);
|
||||
}
|
||||
if (string->rotation != 0) {
|
||||
fprintf(fsvg, " transform=\"rotate(%d,%.2f,%.2f)\"", string->rotation, string->x, string->y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue