Skip to content
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

Some other improvements for the user experience #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 8 additions & 40 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,19 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/png" href="favicon.png"/>
<style>
body {
padding: 0;
margin: 0;
background-color: #333;
color: #ccc;
font-family: sans-serif;
}
#container {
margin: 0;
padding: 2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
canvas {
max-width: 100%;
height: auto !important;
}
p, a {
font-size: 1rem;
color: #ccc;
text-align: center;
}

@media (min-width: 1280px) {
canvas {
max-width: 80vw;
}
}
</style>
<link rel="stylesheet" href="style.css">
<script src="wallpaper.js"></script>
</head>
<body>
<div id="container">
<canvas width="3840" height="2160"></canvas>
<p>
<!-- Empty size is set in JS -->
<canvas class="rounded" width="3840" height="2160"></canvas>
<div id="actions">
<!-- Empty links are set in JS -->
<a download="wallpaper.png" href="" id="download">Save this wallpaper</a>
<span>|</span>
<a href="" id="share">Grab the link to share it</a>
<span>|</span>
<a href="https://tanck.nl/wallpaper" id="new">Generate a new wallpaper</a>
</p>
<a class="button rounded" download="wallpaper.png" href="" id="download">Save this wallpaper</a>
<a class="button rounded" href="" id="share">Grab the link to share it</a>
<a class="button rounded" href="" id="new">Generate a new wallpaper</a>
</div>
</div>
</body>
</html>
58 changes: 58 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
body {
padding: 0;
margin: 0;
background-color: #333;
color: #ccc;
font-family: sans-serif;
min-height: 100vh;
}
canvas {
max-height: 70vh;
max-width: 80vw;
width: auto !important;
height: auto !important;
}
p, a {
font-size: 1rem;
color: #ccc;
text-align: center;
}

#container {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 1rem;
gap: 1rem;
}
#actions {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 1rem;
}

.rounded {
border-radius: 1rem;
}
.button {
padding: 0.6rem 0.5rem 0.4rem;
border: 2px solid #ccc;
text-decoration: none;
}

@media (min-width: 1280px) {
canvas {
max-height: 80vh;
}
#container {
padding: 2rem;
gap: 2rem;
}
#actions {
gap: 2rem;
}
}
8 changes: 6 additions & 2 deletions wallpaper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ function generateValues( width ){
hueIncrement: 20 - ( 40 * ( Math.random() ) ),
ampl: ( 0.1 * wl ) + ( 0.9 * wl ) * Math.random(),
offset: width * Math.random(),
offsetIncrement: width/20 + (width/10) * Math.random(),
offsetIncrement: width / 20 + ( width / 10 ) * Math.random(),
sat: 10 + ( 30 * Math.random() ),
light: 15 + ( 45 * Math.random() ),
lightIncrement: ( Math.random() < 0.5 ) ? ( 2 + ( 4 * Math.random() ) ) : -( 2 + ( 4 * Math.random() ) )
lightIncrement: ( Math.random() < 0.5 ) ? ( 2 + ( 4 * Math.random() ) ) : - ( 2 + ( 4 * Math.random() ) )
};
}

Expand Down Expand Up @@ -104,6 +104,10 @@ function draw(){
// We could push the query parameter automatically with "window.history.pushState"
const shareLink = document.querySelector( 'a#share' );
shareLink.href = "?share=" + encodedValues;
// Allows to refresh the page, no matter where the website is hosted (dev,
// prod, new domain name, etc.)
const newLink = document.querySelector( 'a#new' );
newLink.href = window.location.pathname;
}

/**
Expand Down