-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9c1ddc
commit ff0f898
Showing
5 changed files
with
57 additions
and
31 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup lang="ts"> | ||
import noise from '@/assets/noise.png' | ||
import { useMousePosition } from '@/composables/useMousePosition' | ||
import { useUpdatingRandom } from '@/composables/useUpdatingRandom' | ||
const { x: mouseX, y: mouseY } = useMousePosition() | ||
const noiseInterval = 100 | ||
const noiseMax = 10 | ||
const noiseMin = -10 | ||
const noiseX = useUpdatingRandom(noiseInterval, noiseMin, noiseMax) | ||
const noiseY = useUpdatingRandom(noiseInterval, noiseMin, noiseMax) | ||
const radius = 512 | ||
</script> | ||
|
||
<template> | ||
<div | ||
className="fixed inset-0 -z-50 h-full w-screen bg-theme-50 bg-grid-theme-100 dark:bg-theme-900 dark:bg-grid-theme-950" | ||
> | ||
<div | ||
class="absolute inset-[-200%] -z-40 h-[400%] w-[400%] opacity-[0.05]" | ||
:style="{ | ||
transform: `translate(${noiseX}%, ${noiseY}%)`, | ||
background: `url('${noise}')` | ||
}" | ||
/> | ||
<div | ||
className="-z-30 absolute left-0 top-0 rounded-full bg-theme-50 dark:bg-theme-900 blur-[128px]" | ||
:style="{ | ||
height: radius + 'px', | ||
width: radius + 'px', | ||
transform: `translate(calc(-50% + ${mouseX}px), calc(-50% + ${mouseY}px))` | ||
}" | ||
/> | ||
</div> | ||
</template> |
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,17 @@ | ||
// a composable to generate an updating random number | ||
import { ref } from 'vue' | ||
|
||
export function useUpdatingRandom(interval = 1000, min = 0, max = 1) { | ||
const random = ref(Math.random()) | ||
|
||
const getRandomInt = (min: number, max: number) => | ||
Math.floor(Math.random() * (max - min + 1)) + min | ||
|
||
const updateRandom = () => { | ||
random.value = getRandomInt(min, max) | ||
} | ||
|
||
setInterval(updateRandom, interval) | ||
|
||
return random | ||
} |