-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from nomandhoni-cs/master
Releasing Blink Eye `v1.7.0` with auto run on startup and sound on reminder
- Loading branch information
Showing
16 changed files
with
507 additions
and
338 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
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
Binary file not shown.
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
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,130 @@ | ||
import React, { useEffect, useRef } from "react"; | ||
|
||
const StarryBackground: React.FC = () => { | ||
const canvasRef = useRef<HTMLCanvasElement | null>(null); | ||
|
||
useEffect(() => { | ||
const canvas = canvasRef.current; | ||
if (!canvas) return; | ||
|
||
const c = canvas.getContext("2d"); | ||
if (!c) return; | ||
|
||
const n_stars = 150; | ||
const colors = [ | ||
"#ffffff", | ||
"#ffd700", | ||
"#00d4b4", | ||
"#a1c4fd", | ||
"#ff74d0", | ||
...Array(98).fill("#fff"), | ||
]; // Stars visible in light and dark | ||
|
||
const randomInt = (max: number, min: number) => | ||
Math.floor(Math.random() * (max - min) + min); | ||
|
||
class Star { | ||
x: number; | ||
y: number; | ||
radius: number; | ||
color: string; | ||
dy: number; | ||
|
||
constructor( | ||
x: number = randomInt(0, canvas?.width ?? window.innerWidth), | ||
y: number = randomInt(0, canvas?.height ?? window.innerHeight), | ||
radius: number = Math.random() * 1.1, | ||
color: string = colors[randomInt(0, colors.length)] | ||
) { | ||
this.x = x; | ||
this.y = y; | ||
this.radius = radius; | ||
this.color = color; | ||
this.dy = -Math.random() * 0.3; | ||
} | ||
|
||
draw() { | ||
// Assert that 'c' is not null | ||
const context = c as CanvasRenderingContext2D; | ||
context.beginPath(); | ||
context.arc(this.x, this.y, this.radius, 0, Math.PI * 2); | ||
context.shadowBlur = randomInt(3, 15); | ||
context.shadowColor = this.color; | ||
context.strokeStyle = this.color; | ||
context.fillStyle = "rgba(255, 255, 255, .5)"; | ||
context.fill(); | ||
context.stroke(); | ||
context.closePath(); | ||
} | ||
|
||
update(arrayStars: Star[]) { | ||
if (this.y - this.radius < 0) this.createNewStar(arrayStars); | ||
this.y += this.dy; | ||
this.draw(); | ||
} | ||
|
||
createNewStar(arrayStars: Star[]) { | ||
const i = arrayStars.indexOf(this); | ||
arrayStars.splice(i, 1); | ||
arrayStars.push(new Star()); | ||
} | ||
} | ||
|
||
let stars: Star[] = []; | ||
const init = () => { | ||
for (let i = 0; i < n_stars; i++) { | ||
stars.push(new Star()); | ||
} | ||
}; | ||
init(); | ||
|
||
const animate = () => { | ||
requestAnimationFrame(animate); | ||
c.clearRect(0, 0, canvas.width, canvas.height); | ||
stars.forEach((s) => s.update(stars)); | ||
}; | ||
|
||
animate(); | ||
|
||
const handleResize = () => { | ||
if (!canvas) return; | ||
const width = window.innerWidth; | ||
const height = window.innerHeight; | ||
const dpr = window.devicePixelRatio || 1; | ||
|
||
// Set canvas size with device pixel ratio to avoid blurriness | ||
canvas.width = width * dpr; | ||
canvas.height = height * dpr; | ||
canvas.style.width = `${width}px`; | ||
canvas.style.height = `${height}px`; | ||
|
||
// Scale the context for retina displays | ||
c.scale(dpr, dpr); | ||
|
||
stars = []; | ||
init(); | ||
}; | ||
|
||
window.addEventListener("resize", handleResize); | ||
|
||
// Initial resize call | ||
handleResize(); | ||
|
||
return () => { | ||
window.removeEventListener("resize", handleResize); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<canvas | ||
ref={canvasRef} | ||
className="w-full h-full fixed inset-0 -z-10 overflow-hidden" | ||
style={{ | ||
background: | ||
"linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.6))", | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default StarryBackground; |
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,26 @@ | ||
import * as React from "react"; | ||
import * as SliderPrimitive from "@radix-ui/react-slider"; | ||
|
||
import { cn } from "../../lib/utils"; | ||
|
||
const Slider = React.forwardRef< | ||
React.ElementRef<typeof SliderPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<SliderPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"relative flex w-full touch-none select-none items-center", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary"> | ||
<SliderPrimitive.Range className="absolute h-full bg-primary" /> | ||
</SliderPrimitive.Track> | ||
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" /> | ||
</SliderPrimitive.Root> | ||
)); | ||
Slider.displayName = SliderPrimitive.Root.displayName; | ||
|
||
export { Slider }; |
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,27 @@ | ||
import * as React from "react"; | ||
import * as SwitchPrimitives from "@radix-ui/react-switch"; | ||
|
||
import { cn } from "../../lib/utils"; | ||
|
||
const Switch = React.forwardRef< | ||
React.ElementRef<typeof SwitchPrimitives.Root>, | ||
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<SwitchPrimitives.Root | ||
className={cn( | ||
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input", | ||
className | ||
)} | ||
{...props} | ||
ref={ref} | ||
> | ||
<SwitchPrimitives.Thumb | ||
className={cn( | ||
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0" | ||
)} | ||
/> | ||
</SwitchPrimitives.Root> | ||
)); | ||
Switch.displayName = SwitchPrimitives.Root.displayName; | ||
|
||
export { Switch }; |
Oops, something went wrong.