Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vignette
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engélibert
vignette
Commits
9812da81
Commit
9812da81
authored
4 years ago
by
matograine
Browse files
Options
Downloads
Patches
Plain Diff
add the choice to display a Ğ1 logo.
parent
f6c4fe05
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.html
+20
-4
20 additions, 4 deletions
index.html
with
20 additions
and
4 deletions
index.html
+
20
−
4
View file @
9812da81
...
...
@@ -43,6 +43,8 @@
<textarea
type=
"textarea"
rows=
"10"
cols=
"29"
id=
"infos"
name=
"infos"
></textarea></br>
<label
title=
"Image JPG ou PNG. Le logo Ğ est utilisé par défaut."
for=
"image"
>
Image
</label>
<input
type=
"file"
id=
"image"
name=
"image"
accept=
".JPG, .JPEG, .jpg, .jpeg, .png, .PNG"
></input></br>
<label
title=
"Ajouter un logo Ğ"
for=
"logo"
>
Logo Ğ1
</label>
<input
type=
"checkbox"
id=
"logo"
name=
"is_logo"
></input></br>
<input
class=
"submit_button"
type=
"submit"
value=
"Générer !"
></input>
</fieldset></form>
</section>
...
...
@@ -52,6 +54,7 @@
<!-- invisible assets for canvas generation-->
<div
id=
"vignetteQrCode"
style=
"display: none"
>
</div>
<img
src=
"none"
id=
"temp_image"
style=
"display: none"
></img>
<img
src=
"./img/logo_g.png"
id=
"logo_g_png"
style=
"display: none"
></img>
<!-- buttons -->
<div
id=
"vignette_buttons"
>
<a
id=
"download"
download=
"vignette.png"
><button
class=
"download"
type=
"button"
onClick=
"download()"
>
Télécharger l'image
</button></a>
...
...
@@ -82,6 +85,7 @@ const MARGIN_CANVAS = 50;
const
QR_WIDTH_AND_HEIGHT
=
200
;
const
IMAGE_WIDTH_AND_HEIGHT
=
300
;
const
LOGO_WIDTH_AND_HEIGHT
=
150
;
const
IMAGE_PLACEHOLDER
=
"
./img/logo_g.png
"
const
TITLE_FONT
=
"
45px serif
"
;
...
...
@@ -111,6 +115,9 @@ function createVignette(event) {
let
infos
=
document
.
forms
[
"
formulaire
"
][
"
infos
"
].
value
;
let
pubkey
=
document
.
forms
[
"
formulaire
"
][
"
pubkey
"
].
value
;
let
image
=
document
.
forms
[
"
formulaire
"
][
"
image
"
].
files
[
0
];
let
isLogo
=
document
.
forms
[
"
formulaire
"
][
"
logo
"
].
checked
;
console
.
log
(
isLogo
);
if
(
!
checkValues
(
title
,
infos
,
pubkey
,
image
))
{
return
;
...
...
@@ -143,7 +150,7 @@ function createVignette(event) {
reader
.
onload
=
function
()
{
let
tempImage
=
document
.
getElementById
(
"
temp_image
"
)
tempImage
.
onload
=
function
()
{
vignetteCanvas
=
createVignetteCanvas
(
qrCode
,
title
,
pubkey
,
infos
,
tempImage
);
vignetteCanvas
=
createVignetteCanvas
(
qrCode
,
title
,
pubkey
,
infos
,
tempImage
,
isLogo
);
}
tempImage
.
src
=
reader
.
result
}
...
...
@@ -153,7 +160,7 @@ function createVignette(event) {
let
tempImage
=
document
.
getElementById
(
"
temp_image
"
)
tempImage
.
src
=
IMAGE_PLACEHOLDER
;
tempImage
.
onload
=
function
()
{
vignetteCanvas
=
createVignetteCanvas
(
qrCode
,
title
,
pubkey
,
infos
,
tempImage
);
vignetteCanvas
=
createVignetteCanvas
(
qrCode
,
title
,
pubkey
,
infos
,
tempImage
,
isLogo
);
}
}
...
...
@@ -231,7 +238,7 @@ function verifyFormat (pubkeyAndChecksum) {
return
true
;
}
function
createVignetteCanvas
(
qrCode
,
title
,
pubkey
,
infos
,
givenImage
){
function
createVignetteCanvas
(
qrCode
,
title
,
pubkey
,
infos
,
givenImage
,
isLogo
){
let
canvas
=
document
.
getElementById
(
"
vignette_canvas
"
);
if
(
canvas
.
getContext
)
{
...
...
@@ -270,6 +277,15 @@ function createVignetteCanvas (qrCode, title, pubkey, infos, givenImage){
yPosQr
=
parseInt
(
MARGIN_CANVAS
+
IMAGE_WIDTH_AND_HEIGHT
+
((
CANVAS_HEIGHT
-
(
2
*
MARGIN_CANVAS
+
IMAGE_WIDTH_AND_HEIGHT
))
/
2
-
QR_WIDTH_AND_HEIGHT
/
2
)
)
ctx
.
drawImage
(
imageQrCode
,
xPosQr
,
yPosQr
);
// logo
if
(
isLogo
===
true
){
console
.
log
(
"
coucou
"
);
logo
=
document
.
getElementById
(
"
logo_g_png
"
);
xLogo
=
alignTextOn
-
LOGO_WIDTH_AND_HEIGHT
-
MARGIN_CANVAS
/
2
yLogo
=
parseInt
(
MARGIN_CANVAS
+
IMAGE_WIDTH_AND_HEIGHT
-
(
LOGO_WIDTH_AND_HEIGHT
+
MARGIN_CANVAS
)
/
2
)
ctx
.
drawImage
(
logo
,
xLogo
,
yLogo
,
LOGO_WIDTH_AND_HEIGHT
,
LOGO_WIDTH_AND_HEIGHT
);
}
// background
ctx
.
globalCompositeOperation
=
"
destination-over
"
;
ctx
.
fillStyle
=
"
#FFFFFF
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment