1. add two word template

2. add new background
This commit is contained in:
shouchih_chen 2022-03-25 22:30:29 +08:00
parent 4fa3d9dc1c
commit 793446dcd2
14 changed files with 74 additions and 47 deletions

View File

@ -5,5 +5,16 @@
<file>resource/background_g.jpg</file> <file>resource/background_g.jpg</file>
<file>resource/background_r.jpg</file> <file>resource/background_r.jpg</file>
<file>resource/background_y.jpg</file> <file>resource/background_y.jpg</file>
<file>resource/two_word_sample.jpg</file>
<file>resource/background_1.jpg</file>
<file>resource/background_2.jpg</file>
<file>resource/background_3.jpg</file>
<file>resource/background_4.jpg</file>
<file>resource/background_5.jpg</file>
<file>resource/background_6.jpg</file>
<file>resource/background_7.jpg</file>
<file>resource/background_8.jpg</file>
<file>resource/background_9.jpg</file>
<file>resource/background_10.jpg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -1,28 +1,13 @@
name_1,bg_type name_1,bg_type
<EFBFBD>,r ¦ã¤p¨F,r
<EFBFBD>,g ®L¤p,g
<EFBFBD>衱郝,b §dÐw,b
<EFBFBD>,y ¤¨¤p,y
<EFBFBD>,r ¦ã¤p,r
<EFBFBD>,g ®L¤p,g
<EFBFBD>衱郝,b §dÐw,b
<EFBFBD>,y ¤¨¤p,y
<EFBFBD>,r ¦ã¤p,r
<EFBFBD>,g ®L¤p,g
<EFBFBD>,y ¦ã¤p,2
<EFBFBD>,b ®L¤p,1
<EFBFBD>,b
<EFBFBD>,b
<EFBFBD>衱郝,b
<EFBFBD>,y
<EFBFBD>,b
<EFBFBD>,g
<EFBFBD>衱郝,g
<EFBFBD>,r
<EFBFBD>,r
<EFBFBD>,r
<EFBFBD>,y
<EFBFBD>,y
<EFBFBD>,r
<EFBFBD>,g
<EFBFBD>,b

1 name_1 bg_type
2 ︺�诧 ¦ã¤p¨F r
3 甃�和 ®L¤p g
4 �衱郝 §dÐw b
5 え�丹 ¤¨¤p y
6 ︺�诧 ¦ã¤p r
7 甃�和 ®L¤p g
8 �衱郝 §dÐw b
9 え�丹 ¤¨¤p y
10 ︺�诧 ¦ã¤p r
11 甃�和 ®L¤p g
12 ︺�诧 ¦ã¤p y 2
13 甃�和 ®L¤p b 1
︺�诧 b
甃�和 b
�衱郝 b
え�丹 y
︺�诧 b
甃�和 g
�衱郝 g
え�丹 r
︺�诧 r
甃�和 r
︺�诧 y
甃�和 y
甃�和 r
︺�诧 g
甃�和 b

View File

@ -13,7 +13,8 @@
#include <QFontDatabase> #include <QFontDatabase>
#define BG_SAMPLE_PATH ":/NameCreater/resource/background_sample.jpg" //#define BG_SAMPLE_PATH ":/NameCreater/resource/background_sample.jpg"
#define BG_SAMPLE_PATH ":/NameCreater/resource/two_word_sample.jpg"
#define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg" #define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg"
#define FONT_NAME "DFYuanStd-W8.otf" #define FONT_NAME "DFYuanStd-W8.otf"
#define FONT_SIZE 120 #define FONT_SIZE 120
@ -54,6 +55,21 @@ static QPointF NAME_POS[] = {
QPointF(1268, 2334), QPointF(2240, 2202), QPointF(1268, 2334), QPointF(2240, 2202),
}; };
static QPointF NAME_POS_TWO_WORD[] = {
QPointF(240, 510), QPointF(372, 1402),
QPointF(564, 430), QPointF(694, 1402),
QPointF(883, 430), QPointF(1014, 1402),
QPointF(1205, 430), QPointF(1337, 1402),
QPointF(1532, 430), QPointF(1663, 1402),
QPointF(1854, 430), QPointF(1987, 1402),
QPointF(2176, 430), QPointF(2309, 1402),
QPointF(2498, 430), QPointF(2629, 1402),
QPointF(2821, 430), QPointF(2952, 1402),
QPointF(3145, 430), QPointF(3276, 1402),
QPointF(1268, 2012), QPointF(2240, 1880),
QPointF(1268, 2334), QPointF(2240, 2202),
};
static int NAME_POS_COUNT = sizeof(NAME_POS) / sizeof(NAME_POS[0]); static int NAME_POS_COUNT = sizeof(NAME_POS) / sizeof(NAME_POS[0]);
@ -217,14 +233,25 @@ int main(int argc, char* argv[])
msgBox.exec(); msgBox.exec();
} }
QString name = name_info.name1; QString name = name_info.name1;
int name_len = name.length();
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
int pos_idx = idx * 2 + j; int pos_idx = idx * 2 + j;
int xscale, yscale; int xscale, yscale;
xscale = yscale = (j == 1) ? -1 : 1; xscale = yscale = (j == 1) ? -1 : 1;
QPointF pos = NAME_POS[pos_idx]; QPointF pos = NAME_POS[pos_idx];
int y_offset[2] = {0};
if (name_len == 2) {
if (!rot) {
pos.setY(pos.y() + 82 * xscale);
}
else {
pos.setX(pos.x() + 82 * xscale);
}
y_offset[0] = 25;
}
QGraphicsTextItem* textItem1 = new QGraphicsTextItem(name.mid(0, 1)); QGraphicsTextItem* textItem1 = new QGraphicsTextItem(name.mid(0, 1));
textItem1->setFont(font); textItem1->setFont(font);
@ -240,7 +267,6 @@ int main(int argc, char* argv[])
} }
scene.addItem(textItem1); scene.addItem(textItem1);
QGraphicsTextItem* textItem2 = new QGraphicsTextItem(name.mid(1, 1)); QGraphicsTextItem* textItem2 = new QGraphicsTextItem(name.mid(1, 1));
@ -248,31 +274,34 @@ int main(int argc, char* argv[])
textItem2->setDefaultTextColor(font_color); textItem2->setDefaultTextColor(font_color);
if (!rot) { if (!rot) {
textItem2->setPos(pos.x(), pos.y() + 145 * xscale); textItem2->setPos(pos.x(), pos.y() + (145 + y_offset[0]) * xscale);
textItem2->setTransform(QTransform::fromScale(xscale, yscale)); textItem2->setTransform(QTransform::fromScale(xscale, yscale));
} }
else { else {
textItem2->setPos(pos.x() + 145 * xscale, pos.y()); textItem2->setPos(pos.x() + (145 + y_offset[0]) * xscale, pos.y());
textItem2->setRotation(-90); textItem2->setRotation(-90);
textItem2->setTransform(QTransform::fromScale(xscale, yscale)); textItem2->setTransform(QTransform::fromScale(xscale, yscale));
} }
scene.addItem(textItem2); scene.addItem(textItem2);
QGraphicsTextItem* textItem3 = new QGraphicsTextItem(name.mid(2, 1)); if (name_len > 2) {
textItem3->setFont(font); QGraphicsTextItem* textItem3 = new QGraphicsTextItem(name.mid(2, 1));
textItem3->setDefaultTextColor(font_color); textItem3->setFont(font);
if (!rot) { textItem3->setDefaultTextColor(font_color);
textItem3->setPos(pos.x(), pos.y() + 290 * xscale); if (!rot) {
textItem3->setTransform(QTransform::fromScale(xscale, yscale)); textItem3->setPos(pos.x(), pos.y() + 290 * xscale);
} textItem3->setTransform(QTransform::fromScale(xscale, yscale));
else { }
textItem3->setPos(pos.x() + 290 * xscale, pos.y()); else {
textItem3->setRotation(-90); textItem3->setPos(pos.x() + 290 * xscale, pos.y());
textItem3->setTransform(QTransform::fromScale(xscale, yscale)); textItem3->setRotation(-90);
} textItem3->setTransform(QTransform::fromScale(xscale, yscale));
}
scene.addItem(textItem3); scene.addItem(textItem3);
}
} }
bool is_export_page = ((idx + 1) % BG_POS_COUNT == 0); bool is_export_page = ((idx + 1) % BG_POS_COUNT == 0);
@ -280,7 +309,9 @@ int main(int argc, char* argv[])
QString file_name = QString("%1_.jpg").arg(QString::number(export_times + 1)); QString file_name = QString("%1_.jpg").arg(QString::number(export_times + 1));
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); view.show();
break;
//scene.clear();
} }
} }
@ -293,5 +324,5 @@ int main(int argc, char* argv[])
font_res.close(); font_res.close();
return 0; return a.exec();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB