Skip to content

Commit 786a162

Browse files
committed
Fix voi color selector pane. Fix font selector implementation and fontSize slider next.
1 parent 4b53d62 commit 786a162

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

src/lib/components/VerseOnImage.svelte

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ The verse on image component.
1717
selectedVerses,
1818
windowSize,
1919
direction,
20+
fontChoices,
21+
currentFont,
2022
s
2123
} from '$lib/data/stores';
2224
import { shareImage } from '$lib/data/share';
@@ -57,11 +59,11 @@ The verse on image component.
5759
let voi_fontSize = 13;
5860
let voi_fontSizeMin = 10;
5961
let voi_fontSizeMax = 60;
60-
let voi_font = '';
62+
let voi_font = $currentFont;
6163
let voi_refBold = '';
6264
let voi_refItalic = $s['ui.text-on-image']['font-style'] == 'italic';
6365
let voi_refFontPercent = 80;
64-
let voi_fontColor = $s['ui.text-on-image']['color'];
66+
let voi_fontColor = standardize_color(String($s['ui.text-on-image']['color']));
6567
let voi_letterSpacing = 0;
6668
let voi_lineHeight_x100 = 0;
6769
$: voi_lineHeight = 1 + voi_lineHeight_x100 / 100;
@@ -82,7 +84,7 @@ The verse on image component.
8284
(voi_fontSize * voi_textShadow_value) / 100 +
8385
'px ' +
8486
(voi_fontSize * voi_textShadow_value) / 100
85-
: '0 0 ' + ((voi_fontSize * voi_textShadow_value) / 100) * 2) + 'px black'; //DEBUG: from Android: Shadow size goes 0 to 0.2.
87+
: '0 0 ' + ((voi_fontSize * voi_textShadow_value) / 100) * 2) + 'px black';
8688
let voi_imageBrightness = 100;
8789
let voi_imageContrast = 100;
8890
let voi_imageSaturation = 100;
@@ -119,9 +121,10 @@ The verse on image component.
119121
/*DEBUG*/ console.log('voi_textBoxHeight=', voi_textBoxHeight);
120122
}
121123
122-
$: colorPrint(voi_fontColor);
123-
function colorPrint(clr) {
124-
console.log('clr=', clr);
124+
function standardize_color(str) {
125+
var ctx = document.createElement('canvas').getContext('2d');
126+
ctx.fillStyle = str;
127+
return ctx.fillStyle;
125128
}
126129
127130
$: render(
@@ -158,10 +161,17 @@ The verse on image component.
158161
voi_fontSize = voi_fontSize + 1;
159162
}
160163
/*DEBUG*/ console.log(
161-
`tbH=${voi_textBox.clientHeight} voiH=${voi_height} fontSize=${voi_fontSize}`
164+
`tbH=${voi_textBox.clientHeight} voiHx${percentOfHeight}%=${
165+
cnv.clientHeight * (percentOfHeight / 100)
166+
} fontSize=${voi_fontSize}`
162167
);
163168
}
164169
170+
function handleFontChange(f) {
171+
voi_font = f;
172+
/*DEBUG*/ console.log('font=', f);
173+
}
174+
165175
// Share button feature:
166176
export function shareCanvas() {
167177
var node = document.getElementById('verseOnImgPreview');
@@ -170,8 +180,6 @@ The verse on image component.
170180
fetch(dataUrl)
171181
.then((response) => response.blob())
172182
.then((blob) => {
173-
// Now you have the Blob and can use it as needed
174-
/*DEBUG*/ console.log(blob);
175183
shareImage(reference, verses, reference + '.png', blob);
176184
})
177185
.catch((error) => {
@@ -271,7 +279,7 @@ The verse on image component.
271279
id="verseOnImgPreview"
272280
bind:this={voi_parentDiv}
273281
class="flex flex-col"
274-
style="border: 0px solid cyan; width:{voi_width}px; height:{voi_height}px;"
282+
style="width:{voi_width}px; height:{voi_height}px;"
275283
>
276284
<!-- Preview display of the image and text -->
277285

@@ -287,7 +295,6 @@ The verse on image component.
287295
<p
288296
id="verseOnImageTextDiv"
289297
style="
290-
border: 3px solid lightgreen;
291298
position: absolute;
292299
z-index: 2;
293300
width: {voi_textBoxWidth}px;
@@ -307,6 +314,7 @@ The verse on image component.
307314
overflow: hidden;
308315
user-drag: none;
309316
transform: translate({voi_textPosX}px, {voi_textPosY}px);
317+
border: 3px solid lightgreen;
310318
"
311319
class="flex flex-col"
312320
bind:this={voi_textBox}
@@ -459,7 +467,6 @@ The verse on image component.
459467
height: auto;
460468
--imgWidth: {voi_width / 4}px;
461469
overflow-y: auto;
462-
border: 0px solid blue;
463470
"
464471
>
465472
<div class="grid grid-cols-4" style="height: fit-content;">
@@ -470,7 +477,9 @@ The verse on image component.
470477
>
471478
<button
472479
class="dy-btn-sm dy-btn-ghost"
473-
on:click={() => console.log('Open camera roll')}
480+
on:click={() => {
481+
/*DEBUG*/ console.log('Open camera roll');
482+
}}
474483
>
475484
<ImagesIcon color={$monoIconColor} />
476485
</button>
@@ -489,16 +498,13 @@ The verse on image component.
489498

490499
<!-- Font Selector Pane -->
491500
<div class="dy-carousel-item items-center editorPane">
492-
<FontList />
493-
<h1 style="width:100%;">Font selector EditorPane</h1>
494-
<button
495-
class="dy-btn-sm dy-btn-ghost"
496-
on:click={() => {
497-
setInitialFontSize(80);
501+
<FontList
502+
bind:selectedFont={voi_font}
503+
on:menuaction={(font) => {
504+
/*DEBUG*/ console.log('fDump=', font.detail.font);
505+
handleFontChange(font.detail.font);
498506
}}
499-
>
500-
<ImagesIcon color="purple" />
501-
</button>
507+
/>
502508
</div>
503509

504510
<!-- Font Editor Pane -->
@@ -634,7 +640,7 @@ The verse on image component.
634640
</div>
635641

636642
<!-- Font Color Pane -->
637-
<div class="dy-carousel-item editorPane">
643+
<div class="dy-carousel-item editorPane" style="padding-top: 1rem;">
638644
<!-- Color Picker -->
639645
<ColorPicker
640646
toRight={false}
@@ -779,7 +785,6 @@ The verse on image component.
779785
class="dy-btn-sm dy-btn-ghost editorPane_button"
780786
on:click={() => {
781787
voi_refBold = !voi_refBold;
782-
console.log('voi_refBold=', voi_refBold);
783788
}}
784789
>
785790
<ImageIcon.FormatBold color={voi_refBold ? progressColor : unselectedColor} />
@@ -790,7 +795,6 @@ The verse on image component.
790795
class="dy-btn-sm dy-btn-ghost editorPane_button"
791796
on:click={() => {
792797
voi_refItalic = !voi_refItalic;
793-
console.log('voi_refItalic=', voi_refItalic);
794798
}}
795799
>
796800
<ImageIcon.FormatItalic

0 commit comments

Comments
 (0)