-
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
d0f4ced
commit 056df06
Showing
10 changed files
with
681 additions
and
5 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
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,18 @@ | ||
// nextjs | ||
import Script from 'next/script'; | ||
|
||
export default function Home() { | ||
return ( | ||
<div> | ||
<Script src='/mandelbrot/wasm_exec.js' strategy='beforeInteractive'></Script> | ||
<Script strategy='beforeInteractive'> | ||
{` | ||
const go = new Go(); | ||
WebAssembly.instantiateStreaming(fetch("/mandelbrot/wasm.wasm"), go.importObject).then((result) => { | ||
go.run(result.instance); | ||
}); | ||
`} | ||
</Script> | ||
</div> | ||
) | ||
} |
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,16 @@ | ||
export const metadata = { | ||
title: 'Next.js', | ||
description: 'Generated by Next.js', | ||
} | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
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,6 @@ | ||
#bil { | ||
position: fixed; | ||
left: 0; | ||
top: 0; | ||
z-index: -1; | ||
} |
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 @@ | ||
'use client'; | ||
|
||
import styles from './page.module.css'; | ||
|
||
export default function Home() { | ||
let korBil = () => { | ||
let bil = document.getElementById(styles.bil); | ||
|
||
let count = 0; | ||
|
||
let animate = () => { | ||
bil!.style.left = count + "px"; | ||
count++; | ||
requestAnimationFrame(animate); | ||
} | ||
|
||
animate(); | ||
} | ||
return ( | ||
<div> | ||
<p>Love bil</p> | ||
<button onClick={korBil}>KÖR BARA KÖR</button> | ||
<img id={styles.bil} src="/bil.png" alt="bil" /> | ||
</div> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,53 @@ | ||
//go:build js && wasm | ||
|
||
package main | ||
|
||
import ( | ||
"math/cmplx" | ||
"syscall/js" | ||
) | ||
|
||
func main() { | ||
js.Global().Set("greet", js.FuncOf(func(this js.Value, args []js.Value) interface{} { | ||
if len(args) == 0 { | ||
return "Hello, World!" | ||
} | ||
|
||
return []interface{}{1, 2} | ||
})) | ||
|
||
select {} | ||
} | ||
|
||
//export mandelbrot | ||
func mandelbrot(pixels [][]*int, xStart, xEnd, yStart, yEnd float64, resX, resY, iterations int) { | ||
deltaX := complex((xEnd-xStart)/float64(resX), 0) | ||
deltaY := complex(0, (yEnd-yStart)/float64(resY)) | ||
|
||
coord := complex(xStart, yStart) | ||
|
||
for x := 0; x < resX; x++ { | ||
coord = complex(0, imag(coord)) | ||
for y := 0; y < resY; y++ { | ||
*pixels[x][y] = testPoint(coord, iterations) | ||
coord += deltaY | ||
} | ||
|
||
coord += deltaX | ||
} | ||
} | ||
|
||
func testPoint(c complex128, iterations int) int { | ||
z := complex(0, 0) | ||
i := 0 | ||
|
||
for ; i < iterations; i++ { | ||
z = z*z + c | ||
|
||
if cmplx.Abs(z) > 2 { | ||
break | ||
} | ||
} | ||
|
||
return i | ||
} |
Binary file not shown.
Oops, something went wrong.