Skip to content
Snippets Groups Projects
Commit 46de5086 authored by Alexa Valentová's avatar Alexa Valentová
Browse files

add more templates

parent 5394d4b2
Branches
No related tags found
No related merge requests found
Pipeline #20918 passed
2.18.0 2.19.0
frontend/src/assets/template/back_in_full_force_tour_social_wide/background.png

478 KiB | W: | H:

frontend/src/assets/template/back_in_full_force_tour_social_wide/background.png

467 KiB | W: | H:

frontend/src/assets/template/back_in_full_force_tour_social_wide/background.png
frontend/src/assets/template/back_in_full_force_tour_social_wide/background.png
frontend/src/assets/template/back_in_full_force_tour_social_wide/background.png
frontend/src/assets/template/back_in_full_force_tour_social_wide/background.png
  • 2-up
  • Swipe
  • Onion skin
frontend/src/assets/template/make_a_wish_banner/background.png

24.3 KiB | W: | H:

frontend/src/assets/template/make_a_wish_banner/background.png

27.9 KiB | W: | H:

frontend/src/assets/template/make_a_wish_banner/background.png
frontend/src/assets/template/make_a_wish_banner/background.png
frontend/src/assets/template/make_a_wish_banner/background.png
frontend/src/assets/template/make_a_wish_banner/background.png
  • 2-up
  • Swipe
  • Onion skin
frontend/src/assets/template/make_a_wish_banner/background_inverted.png

26.6 KiB | W: | H:

frontend/src/assets/template/make_a_wish_banner/background_inverted.png

27 KiB | W: | H:

frontend/src/assets/template/make_a_wish_banner/background_inverted.png
frontend/src/assets/template/make_a_wish_banner/background_inverted.png
frontend/src/assets/template/make_a_wish_banner/background_inverted.png
frontend/src/assets/template/make_a_wish_banner/background_inverted.png
  • 2-up
  • Swipe
  • Onion skin
frontend/src/assets/template/make_a_wish_banner/line.png

153 B

...@@ -17,6 +17,92 @@ const clearObjects = (clearableItems, canvas) => { ...@@ -17,6 +17,92 @@ const clearObjects = (clearableItems, canvas) => {
} }
}; };
const getSingleLineTextBoxWidth = (text, fontSize, fontFamily) => {
text = text.replace(/[^\S\r\n]+/g, " ");
text = text.replace(/\r\n/g, "\n");
let positionWithinString = -1;
const splitWords = text.split(" ");
let wordIndexes = {};
const spaceText = new fabric.Text(" ", {
fontFamily: fontFamily,
fontSize: fontSize,
});
// I stole this from another function and this breaks its line width checking system
// so that I don't have to modify the way it works because i remember none of this
// hacky browser font shit anymore.
const maxWidth = 999999999999999;
let currentWidth = 0;
for (let wordPosition = 0; wordPosition < splitWords.length; wordPosition++) {
let currentWord = splitWords[wordPosition];
let skipNewLineGeneration = false;
if (currentWord.includes("\n")) {
skipNewLineGeneration = true;
const breakSplitWord = currentWord.split("\n");
const firstLineWord = breakSplitWord[0];
const secondLineWord = breakSplitWord[1];
// Word + \n
positionWithinString += firstLineWord.length + 1;
currentWord = secondLineWord;
}
const wordIsLast = wordPosition === splitWords.length - 1;
positionWithinString += currentWord.length + (!wordIsLast ? 1 : 0);
const wordText = new fabric.Text(currentWord, {
fontFamily: fontFamily,
fontSize: fontSize,
});
// This is really ugly, I have no idea why Chromium thinks the text is shorter than it really is.
// (Or why Firefox thinks it's longer.)
// But, it works.
currentWidth += wordText.width * (Boolean(window.chrome) ? 1.183 : 1);
if (!skipNewLineGeneration && currentWidth > maxWidth) {
if (
["a", "i", "o", "u", "s", "se", "v", "z"].includes(
splitWords[
wordPosition !== 0 ? wordPosition - 1 : wordPosition
].replace("*", ""),
)
) {
// Previous word is not a, i, o, u, s, ...
const lineBreakPosition =
positionWithinString -
(!wordIsLast ? 1 : 0) -
currentWord.length -
1 -
splitWords[wordPosition !== 0 ? wordPosition - 1 : wordPosition]
.length;
text = setCharAt(text, lineBreakPosition, "\n");
} else {
text = setCharAt(
text,
positionWithinString - (!wordIsLast ? 1 : 0) - currentWord.length,
"\n",
);
}
currentWidth = wordText.width;
} else if (!wordIsLast) {
currentWidth += spaceText.width;
}
}
return currentWidth;
}
const sortObjects = (canvas) => { const sortObjects = (canvas) => {
canvas._objects.sort((a, b) => (a.zIndex > b.zIndex ? 1 : -1)); canvas._objects.sort((a, b) => (a.zIndex > b.zIndex ? 1 : -1));
canvas.renderAll(); canvas.renderAll();
...@@ -284,5 +370,6 @@ export { ...@@ -284,5 +370,6 @@ export {
sortObjects, sortObjects,
transformHighlightedText, transformHighlightedText,
transformTextLineBreaks, transformTextLineBreaks,
getSingleLineTextBoxWidth,
checkTextBoxHeight, checkTextBoxHeight,
}; };
...@@ -61,26 +61,26 @@ const redraw = async (canvas, options) => { ...@@ -61,26 +61,26 @@ const redraw = async (canvas, options) => {
canvas.preserveObjectStacking = true; canvas.preserveObjectStacking = true;
const textMarginLeft = Math.ceil(canvas.width * 0.1); const textMarginLeft = Math.ceil(canvas.width * 0.1);
const textMarginRight = Math.ceil(canvas.width * 0.078); const textMarginRight = Math.ceil(canvas.width * 0.04);
let mainTextMarginBottom = Math.ceil(canvas.height * 0.3) + Math.ceil(canvas.height * 0.13); let mainTextMarginBottom = Math.ceil(canvas.height * 0.47) + Math.ceil(canvas.height * 0.02);
const dateTextMarginBottom = Math.ceil(canvas.height * 0.605) + Math.ceil(canvas.height * 0.305); const dateTextMarginBottom = Math.ceil(canvas.height * 0.8) + Math.ceil(canvas.height * 0.069);
const timeTextBoxMarginBottom = Math.ceil(canvas.height * 0.535) + Math.ceil(canvas.height * 0.312); const timeTextBoxMarginBottom = Math.ceil(canvas.height * 0.715) + Math.ceil(canvas.height * 0.075);
const locationTextBoxMarginBottom = Math.ceil(canvas.height * 0.27) + Math.ceil(canvas.height * 0.12); const locationTextBoxMarginBottom = Math.ceil(canvas.height * 0.43) + Math.ceil(canvas.height * 0.02);
const attendeesTextBoxMarginBottom = Math.ceil(canvas.height * 0.09) + Math.ceil(canvas.height * 0.065); const attendeesTextBoxMarginBottom = Math.ceil(canvas.height * 0.11) + Math.ceil(canvas.height * 0.12);
const mainTextSize = Math.ceil(canvas.height * 0.175); const mainTextSize = Math.ceil(canvas.height * 0.210);
const mainTextLineHeight = 1; const mainTextLineHeight = 1;
const dateTextSize = Math.ceil(canvas.height * 0.046); const dateTextSize = Math.ceil(canvas.height * 0.062);
const timeTextSize = Math.ceil(canvas.height * 0.04); const timeTextSize = Math.ceil(canvas.height * 0.062);
const attendeesTextSize = Math.ceil(canvas.height * 0.027); const attendeesTextSize = Math.ceil(canvas.height * 0.035);
const attendeesTextLineHeight = 1; const attendeesTextLineHeight = 1;
const locationTextSize = Math.ceil(canvas.height * 0.044); const locationTextSize = Math.ceil(canvas.height * 0.055);
const locationTextLineHeight = 1; const locationTextLineHeight = 1;
const contractedByTextSize = Math.ceil(canvas.height * 0.015); const contractedByTextSize = Math.ceil(canvas.height * 0.02);
const contractedByTextMaxWidth = Math.ceil(canvas.width * 0.9); const contractedByTextMaxWidth = Math.ceil(canvas.width * 0.9);
const contractedByTextSidesMargin = Math.ceil(canvas.width * 0.03); const contractedByTextSidesMargin = Math.ceil(canvas.width * 0.03);
......
...@@ -4,10 +4,14 @@ import { ...@@ -4,10 +4,14 @@ import {
sortObjects, sortObjects,
transformHighlightedText, transformHighlightedText,
checkTextBoxHeight, checkTextBoxHeight,
getSingleLineTextBoxWidth,
} from "../../components/canvas/utils"; } from "../../components/canvas/utils";
import { PaddedHighlightingTextbox } from "../../components/canvas/textbox"; import { PaddedHighlightingTextbox } from "../../components/canvas/textbox";
import backgroundURL from "../../assets/template/make_a_wish_banner/background.png"; import backgroundURL from "../../assets/template/make_a_wish_banner/background.png";
import backgroundURLInverted from "../../assets/template/make_a_wish_banner/background_inverted.png"; import backgroundURLInverted from "../../assets/template/make_a_wish_banner/background_inverted.png";
import lineURL from "../../assets/template/make_a_wish_banner/line.png";
import COLORS from "../../colors"; import COLORS from "../../colors";
let mainTextBox = null; let mainTextBox = null;
...@@ -16,6 +20,7 @@ let personNameText = null; ...@@ -16,6 +20,7 @@ let personNameText = null;
let personPositionText = null; let personPositionText = null;
let mainImage = null; let mainImage = null;
let lineImage = null;
let backgroundImage = null; let backgroundImage = null;
let previousBackgroundImageColor = null; let previousBackgroundImageColor = null;
...@@ -26,6 +31,7 @@ let mainImageSource = null; ...@@ -26,6 +31,7 @@ let mainImageSource = null;
const redraw = async (canvas, options) => { const redraw = async (canvas, options) => {
clearObjects( clearObjects(
[ [
lineImage,
mainTextBox, mainTextBox,
personNameText, personNameText,
personPositionText, personPositionText,
...@@ -34,6 +40,8 @@ const redraw = async (canvas, options) => { ...@@ -34,6 +40,8 @@ const redraw = async (canvas, options) => {
canvas, canvas,
); );
lineImage = null;
canvas.preserveObjectStacking = true; canvas.preserveObjectStacking = true;
const textMarginLeft = Math.ceil(canvas.width * 0.24); const textMarginLeft = Math.ceil(canvas.width * 0.24);
...@@ -43,7 +51,7 @@ const redraw = async (canvas, options) => { ...@@ -43,7 +51,7 @@ const redraw = async (canvas, options) => {
const mainTextBackgroundMarginTop = Math.ceil(canvas.height * 0.14); const mainTextBackgroundMarginTop = Math.ceil(canvas.height * 0.14);
const mainTextSize = Math.ceil(canvas.height * 0.07); const mainTextSize = Math.ceil(canvas.height * 0.07);
const mainTextHeightLimit = Math.ceil(mainTextSize * 3.3); const mainTextHeightLimit = Math.ceil(mainTextSize * 3.3);
const mainTextLineHeight = 1; const mainTextLineHeight = 0.85;
const bottomTextSize = Math.ceil(canvas.height * 0.035); const bottomTextSize = Math.ceil(canvas.height * 0.035);
const positionTextSize = Math.ceil(canvas.height * 0.025); const positionTextSize = Math.ceil(canvas.height * 0.025);
...@@ -112,7 +120,7 @@ const redraw = async (canvas, options) => { ...@@ -112,7 +120,7 @@ const redraw = async (canvas, options) => {
personNameText = new fabric.Textbox(options.personName, { personNameText = new fabric.Textbox(options.personName, {
left: nameTextMarginLeft, left: nameTextMarginLeft,
top: canvas.height - bottomTextSize - nameTextMarginBottom, top: canvas.height - bottomTextSize - nameTextMarginBottom,
width: nameTextMaxWidth, width: canvas.width,
fontFamily: "Bebas Neue", fontFamily: "Bebas Neue",
fontSize: bottomTextSize, fontSize: bottomTextSize,
styles: styles, styles: styles,
...@@ -127,7 +135,7 @@ const redraw = async (canvas, options) => { ...@@ -127,7 +135,7 @@ const redraw = async (canvas, options) => {
personPositionText = new fabric.Textbox(options.personPosition, { personPositionText = new fabric.Textbox(options.personPosition, {
left: positionTextSideGap, left: positionTextSideGap,
top: canvas.height - bottomTextSize - positionTextMarginBottom, top: canvas.height - bottomTextSize - positionTextMarginBottom,
width: positionTextMaxWidth, width: canvas.width,
fontFamily: "Roboto Condensed", fontFamily: "Roboto Condensed",
fontSize: positionTextSize, fontSize: positionTextSize,
fill: options.colors.baseText.value, fill: options.colors.baseText.value,
...@@ -160,6 +168,14 @@ const redraw = async (canvas, options) => { ...@@ -160,6 +168,14 @@ const redraw = async (canvas, options) => {
/* BEGIN Main text render */ /* BEGIN Main text render */
const mainTextWidth = canvas.width - textMarginLeft - textMarginRight; const mainTextWidth = canvas.width - textMarginLeft - textMarginRight;
let mainTextLeft = textMarginLeft;
if (personNameText !== null) {
mainTextLeft = Math.max(
personNameText.left + getSingleLineTextBoxWidth(options.personName, bottomTextSize, "Roboto Condensed") + 150,
mainTextLeft
);
}
const highlightedData = transformHighlightedText( const highlightedData = transformHighlightedText(
options.mainText, options.mainText,
...@@ -173,7 +189,7 @@ const redraw = async (canvas, options) => { ...@@ -173,7 +189,7 @@ const redraw = async (canvas, options) => {
mainTextBox = new PaddedHighlightingTextbox(highlightedData.text, { mainTextBox = new PaddedHighlightingTextbox(highlightedData.text, {
width: canvas.width, width: canvas.width,
left: textMarginLeft, left: mainTextLeft,
textAlign: "left", textAlign: "left",
fontFamily: "Bebas Neue", fontFamily: "Bebas Neue",
fontSize: mainTextSize, fontSize: mainTextSize,
...@@ -185,18 +201,50 @@ const redraw = async (canvas, options) => { ...@@ -185,18 +201,50 @@ const redraw = async (canvas, options) => {
zIndex: 20, zIndex: 20,
}); });
checkTextBoxHeight(mainTextBox, 1); checkTextBoxHeight(mainTextBox, 2);
canvas.add(mainTextBox); canvas.add(mainTextBox);
const mainTextBoxTop = const mainTextBoxTop =
canvas.height - mainTextBox.height - mainTextMarginBottom; canvas.height - mainTextBox.height - mainTextMarginBottom + (mainTextSize * (mainTextBox._textLines.length - 1) * 0.5 * mainTextLineHeight);
mainTextBox.top = mainTextBoxTop - highlightedData.paddingBottom; mainTextBox.top = mainTextBoxTop - highlightedData.paddingBottom;
canvas.renderAll(); canvas.renderAll();
/* END Main text render */ /* END Main text render */
/* BEGIN Line render */
if (lineImage === null || options.colors.background.value != previousBackgroundImageColor.value) {
lineImage = new Image();
await new Promise((resolve) => {
lineImage.onload = () => {
resolve();
};
if (options.colors.background.value == COLORS.black.value) {
lineImage.src = lineURL;
} else {
lineImage.src = lineURLInverted;
}
});
lineImage = new fabric.Image(lineImage, {
top: 1690,
left: mainTextBox.left - 40,
zIndex: 10,
selectable: false,
});
lineImage.scaleToHeight(mainTextLineHeight * mainTextSize * 2);
console.log(lineImage);
canvas.add(lineImage);
}
/* END Line render */
} }
/* BEGIN Contracted by render */ /* BEGIN Contracted by render */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment