Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function createImageAppend(padding = 10, width = 200, height = 120) {
- const img = await new Promise(resolve => fabric.Image.fromURL('/pdf-templates/img/image.svg', resolve));
- const text = new fabric.Text('Select image', {
- fontSize: 16, fill: '#8C49F7',
- left: 30, fontFamily: 'Arial'
- });
- // img.set({ left: padding, top: padding });
- // text.set({
- // left: padding + padding + img.width * img.scaleX,
- // top: padding + (img.height) / 4
- // });
- const rect = new fabric.Rect({
- left: 0, top: 0, fill: '#f9f9f9',
- width, height
- });
- const calculateInsert = () => {
- };
- img.top = rect.height / 2 - img.height / 2;
- img.left = (rect.width - (img.width + text.width + padding)) / 2;
- text.set({
- top: rect.height / 2 - text.height / 2,
- left: img.left + img.width + padding
- });
- calculateInsert();
- const group = new fabric.Group([rect, img, text], { left: 100, top: 100 });
- return group;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement