Skip to content

Commit 06f5ae3

Browse files
committed
updated
1 parent ece89ab commit 06f5ae3

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

examples/noise.png

149 KB
Loading

noisy.nimble

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "0.4.4"
1+
version = "0.4.5"
22
author = "Ryan Oldenburg"
33
description = "Nim implementation of various noise types."
44
license = "MIT"

src/noisy.nim

+36-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
import math, nimsimd/sse2, random
22

3+
func m128(a: float32): M128 {.inline.} = mm_set1_ps(a)
4+
5+
func m128i(a: int32): M128i {.inline.} = mm_set1_epi32(a)
6+
7+
func `and`(a, b: M128): M128 {.inline.} = mm_and_ps(a, b)
8+
9+
func `and`(a, b: M128i): M128i {.inline.} = mm_and_si128(a, b)
10+
11+
func `or`(a, b: M128): M128 {.inline.} = mm_or_ps(a, b)
12+
13+
func `xor`(a, b: M128): M128 {.inline.} = mm_xor_ps(a, b)
14+
15+
func `>`(a, b: M128): M128 {.inline.} = mm_cmpgt_ps(a, b)
16+
17+
func `>=`(a, b: M128): M128 {.inline.} = mm_cmpge_ps(a, b)
18+
19+
func `<`(a, b: M128): M128 {.inline.} = mm_cmplt_ps(a, b)
20+
21+
func `+`(a, b: M128): M128 {.inline.} = mm_add_ps(a, b)
22+
23+
func `+=`(a: var M128, b: M128) {.inline.} = a = a + b
24+
25+
func `-`(a, b: M128): M128 {.inline.} = mm_sub_ps(a, b)
26+
27+
func `*`(a, b: M128): M128 {.inline.} = mm_mul_ps(a, b)
28+
29+
func `/`(a, b: M128): M128 {.inline.} = mm_div_ps(a, b)
30+
31+
func `/=`(a: var M128, b: M128) {.inline.} = a = a / b
32+
333
const
434
F2 = (0.5 * (sqrt(3.0) - 1)).float32
535
G2 = ((3 - sqrt(3.0)) / 6).float32
@@ -736,19 +766,20 @@ when defined(release):
736766
when isMainModule:
737767
## Draw an image to see what the noise looks like
738768

739-
import chroma, flippy
769+
import pixie
740770

741771
var s = initSimplex(1988)
742772
s.frequency = 0.1
743-
let img = newImage(480, 480, 3)
744-
let g = s.grid((0, 0), (480, 480))
773+
let
774+
image = newImage(480, 480)
775+
g = s.grid((0, 0), (480, 480))
745776
for x in 0 ..< 480:
746777
for y in 0 ..< 480:
747778
# for z in 0 ..< 1:
748779
let
749780
# v = s.value(x.float32, y.float32)#, z.float32)
750781
v = g[x, y] #, z]
751782
c = (((v + 1) / 2) * 255).uint8
752-
img.putRgba(x, y, rgba(c, c, c, 255))
783+
image[x, y] = rgba(c, c, c, 255)
753784

754-
img.save("examples/noise.png")
785+
image.writeFile("examples/noise.png")

0 commit comments

Comments
 (0)