-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/verse on image #399
Draft
Caleb-Parks
wants to merge
35
commits into
sillsdev:main
Choose a base branch
from
Caleb-Parks:feature/verse-on-image
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
eb7d499
Roughing out verseOnImage divs
Caleb-Parks f8af754
Fixed modal size (made fullscreen) and un-rounded corners
Caleb-Parks 6d5f963
Reimplemented verse on image as a route rather than modal
Caleb-Parks bf71b3c
Renamed verse-on-image route to "image"
Caleb-Parks dbfa47d
Implemented scroll-snap functionality for editors.
Caleb-Parks e79b11e
Implemented render function, stylized, moved share button to navbar
Caleb-Parks 372b998
Fixed uses of cnv_text and verses vars.
Caleb-Parks 4df632e
Got text roughly working. Look into html-to-canvas next
Caleb-Parks 20e98be
Imported html-to-image's toPng function to use in shareCanvas()
Caleb-Parks dfb65f0
Working on making voi text draggable. Fix bounds of draggable border …
Caleb-Parks fb00635
Implementing voi still. Fix textSize slider allowing too large of tex…
Caleb-Parks eb6e7f7
Editor 0 roughed in, 1 and 2 nearly finished. Modified slider.
Caleb-Parks 37029ef
Fixed height and width values of various aspects of editor panes and …
Caleb-Parks 2d7faaf
Fixed draggability of editor panes and renamed voi_textBox's dragging…
Caleb-Parks ce3f5c0
Cleaned up editorTabs div's scroll features, still not scrolling when…
Caleb-Parks b6dd208
Apply proper theme colors for voi
Caleb-Parks fd49749
Modify default, max, and min values of voi font size and line height …
Caleb-Parks a5b6a13
Add voi_textBoxHeight and make it track the height of the textbox.
Caleb-Parks 1f409dd
Modify default, max, and min values of voi_textBoxWidth to match andr…
Caleb-Parks 14e3bb1
Add scrollability for image picker pane, add shadow editor pane, add …
Caleb-Parks d097519
Finish brightness, contrast, saturation, and blur sliders. Replace si…
Caleb-Parks 28575e0
Add editor tab and empty editor pane for font selector.
Caleb-Parks e85f7b6
ColorPicker working
Caleb-Parks 4b53d62
Added more fonts and rebuilt
Caleb-Parks 786a162
Fix voi color selector pane. Fix font selector implementation and fon…
Caleb-Parks 9760837
Initialize initial and max font sizes; center text
chrisvire 5dc2121
Fix icon for reference tab
chrisvire cc1a094
Merge pull request #1 from chrisvire/feature/verse-on-image
Caleb-Parks 50d495f
Merge pull request #2 from chrisvire/fix/verse-on-image-reference-icon
Caleb-Parks de456ab
Start to implement choose image from camera roll feature.
Caleb-Parks ee9b15d
Continue working on image from camera roll feature.
Caleb-Parks f536807
Start on image cropping.
Caleb-Parks 8dd1f4c
Continue working on image cropping.
Caleb-Parks bec6f06
10/5 1:08pm
Caleb-Parks 04a5be5
End of call 10/5
Caleb-Parks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
<svelte:options accessors={true} /> | ||
|
||
<!-- | ||
@component | ||
The navbar component. We have sliders that update reactively to both font size and line height. | ||
3 buttons to change the style from normal, sepia and dark. | ||
--> | ||
<script> | ||
import Modal from './Modal.svelte'; | ||
import { modal, MODAL_FONT, s, t } from '$lib/data/stores'; | ||
import { onMount } from 'svelte'; | ||
import config from '$lib/data/config'; | ||
|
||
let modalId = 'imageCropper'; | ||
let modalThis; | ||
export function showModal() { | ||
modalThis.showModal(); | ||
} | ||
|
||
export let data = { | ||
applyCrop: undefined, | ||
cnv: undefined, | ||
selectedSrc: undefined | ||
}; | ||
$: applyCrop = data.applyCrop; | ||
$: main_canvas = data.cnv; | ||
$: src = data.selectedSrc; | ||
|
||
$: showD8ta(data); | ||
|
||
function showD8ta(d8ta) { | ||
console.log('D8=', d8ta); | ||
} | ||
|
||
let temp_img; | ||
let temp_canvas; | ||
let ctx; | ||
|
||
// export let sourceX; | ||
// export let sourceY; | ||
// export let sourceWidth; | ||
// export let sourceHeight; | ||
// export let destX; | ||
// export let destY; | ||
// export let destWidth; | ||
// export let destHeight; | ||
|
||
$: render(src); | ||
|
||
function render(i_src) { | ||
/*DEBUG*/ console.log('Crop render called.'); | ||
if (!temp_canvas) return; | ||
/*DEBUG*/ console.log('Crop temp_canvas == true.'); | ||
temp_img = new Image(); | ||
temp_img.src = i_src; | ||
// Make sure the image is loaded first otherwise nothing will draw. | ||
temp_img.onload = function () { | ||
ctx = temp_canvas.getContext('2d'); | ||
|
||
ctx.drawImage(temp_img, 0, 0, main_canvas.width, temp_img.height); //TODO: make width canvas.width and height auto | ||
/*DEBUG*/ console.log('Crop ctx=', ctx); | ||
/*DEBUG*/ console.log('Crop w&h=', main_canvas.width, main_canvas.height); | ||
/*DEBUG*/ console.log('Crop img=', temp_img); | ||
}; | ||
} | ||
|
||
//Chat-GPT: | ||
|
||
let isDragging = false; | ||
let dragStartX, dragStartY; | ||
export let cropTop = 0; | ||
export let cropLeft = 0; | ||
export let cropWidth = 100; // Initial width of the square | ||
export let cropHeight = 100; // Initial height of the square | ||
|
||
function startDragging(event) { | ||
isDragging = true; | ||
const touch = event.touches[0]; | ||
dragStartX = touch.clientX; | ||
dragStartY = touch.clientY; | ||
} | ||
|
||
function drag(event) { | ||
if (isDragging) { | ||
const touch = event.touches[0]; | ||
const deltaX = touch.clientX - dragStartX; | ||
const deltaY = touch.clientY - dragStartY; | ||
|
||
cropLeft += deltaX; | ||
cropTop += deltaY; | ||
|
||
dragStartX = touch.clientX; | ||
dragStartY = touch.clientY; | ||
} | ||
} | ||
|
||
function stopDragging() { | ||
isDragging = false; | ||
} | ||
|
||
function pinch(event) { | ||
if (event.touches.length >= 2) { | ||
const touch1 = event.touches[0]; | ||
const touch2 = event.touches[1]; | ||
|
||
const distance = Math.sqrt( | ||
(touch2.clientX - touch1.clientX) ** 2 + (touch2.clientY - touch1.clientY) ** 2 | ||
); | ||
|
||
cropWidth = cropHeight = distance; | ||
} | ||
} | ||
|
||
function cropImage() { | ||
/*DBEUG*/ console.log('Crop triggered'); | ||
const ctx = temp_canvas.getContext('2d'); | ||
ctx.clearRect(0, 0, main_canvas.width, main_canvas.height); | ||
ctx.drawImage( | ||
temp_img, | ||
cropLeft, | ||
cropTop, | ||
cropWidth, | ||
cropHeight, | ||
0, | ||
0, | ||
main_canvas.width, | ||
main_canvas.height | ||
); | ||
const cropped_image = ctx.getImageData(0, 0, main_canvas.width, main_canvas.height); | ||
/*DEBUG*/ console.log('Crop result = ', cropped_image); | ||
createImageBitmap(cropped_image).then((croppedBitmap) => applyCrop(croppedBitmap)); | ||
} | ||
</script> | ||
|
||
<!-- Image Cropper --> | ||
<Modal | ||
bind:this={modalThis} | ||
id={modalId} | ||
useLabel={false} | ||
addCSS="width: 100vw; padding: 0px;" | ||
on:close={() => { | ||
console.log('Crop modal closed.'); | ||
}} | ||
><!--addCSS is a prop for injecting CSS into the modal--> | ||
<svelte:fragment slot="content"> | ||
<div | ||
id="crop_temp_canvas_container" | ||
style="width: 100vw; height: 80vh; border: 5px soild green; background-color: yellow;" | ||
> | ||
<canvas | ||
bind:this={temp_canvas} | ||
width={main_canvas ? main_canvas.width : undefined} | ||
height={main_canvas ? main_canvas.height : undefined} | ||
style="background-color: grey;" | ||
/> | ||
|
||
<div | ||
class="crop-box" | ||
style=" | ||
position: absolute; | ||
top: {cropTop}px; | ||
left: {cropLeft}px; | ||
width: {cropWidth}px; | ||
height: {cropHeight}px; | ||
border: 5px solid white; | ||
" | ||
on:touchstart={startDragging} | ||
on:touchmove={isDragging ? drag : pinch} | ||
on:touchend={stopDragging} | ||
/> | ||
</div> | ||
<div class="w-full flex mt-4 justify-between"> | ||
<button | ||
on:click={() => { | ||
console.log('Crop cancel clicked.'); | ||
}} | ||
class="dy-btn dy-btn-sm dy-btn-ghost">{$t['Button_Cancel']}</button | ||
> | ||
<button on:click={cropImage} class="dy-btn dy-btn-sm dy-btn-ghost" | ||
>{$t['Button_OK']}</button | ||
> | ||
</div> | ||
</svelte:fragment> | ||
</Modal> | ||
|
||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are using this, it should be in devDependencies.