Added polkadots
This commit is contained in:
parent
8d67d68f26
commit
18bcecf7b3
|
@ -1,7 +1,7 @@
|
||||||
import math
|
import math
|
||||||
from pixel import Pixel
|
from pixel import Pixel
|
||||||
|
|
||||||
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float):
|
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float): # https://www.shadertoy.com/view/lsyyz3
|
||||||
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
|
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
|
||||||
|
|
||||||
h = math.sin(uv[0] * math.pi + uv[1] * 10.0 + time + math.cos(uv[0] * uv[1] + uv[1] * 7.1823) * math.sin(uv[0] * 14.2))
|
h = math.sin(uv[0] * math.pi + uv[1] * 10.0 + time + math.cos(uv[0] * uv[1] + uv[1] * 7.1823) * math.sin(uv[0] * 14.2))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import math
|
import math
|
||||||
from pixel import Pixel
|
from pixel import Pixel
|
||||||
|
|
||||||
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float):
|
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float): # default shader when creating a new shader on shadertoy
|
||||||
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
|
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
|
||||||
|
|
||||||
pixel.background_color.set(
|
pixel.background_color.set(
|
||||||
|
|
37
shaders/polkadots.py
Normal file
37
shaders/polkadots.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import math
|
||||||
|
from pixel import Pixel
|
||||||
|
|
||||||
|
COLOR_A = (0.0, 0.7, 0.8)
|
||||||
|
COLOR_B = (0.8, 0.0, 0.7)
|
||||||
|
|
||||||
|
HEIGHT = 6.0
|
||||||
|
RADIUS = 1.
|
||||||
|
|
||||||
|
def distance(a: tuple, b: tuple) -> float:
|
||||||
|
if len(a) != len(b):
|
||||||
|
raise TypeError("Mismatching dimentional vector passed")
|
||||||
|
|
||||||
|
dist = 0
|
||||||
|
for i in range(len(a)):
|
||||||
|
d = b[i] - a[i]
|
||||||
|
dist += d * d
|
||||||
|
|
||||||
|
return dist ** 0.5
|
||||||
|
|
||||||
|
def get_col(uv: tuple) -> tuple:
|
||||||
|
uv = tuple(math.floor(x) for x in uv)
|
||||||
|
return COLOR_A if ((uv[0] + uv[1]) % 2) == 0.0 else COLOR_B
|
||||||
|
|
||||||
|
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float): # https://www.shadertoy.com/view/lsyyDK
|
||||||
|
uv = [ x * HEIGHT for x in (frag_coord[0] / resolution[1], frag_coord[1] / resolution[1]) ]
|
||||||
|
|
||||||
|
direction = int(time) % 2
|
||||||
|
shift = math.floor(uv[1 - direction])
|
||||||
|
shift = 2.0 * (shift % 2) - 1.0
|
||||||
|
uv[direction] += shift * time
|
||||||
|
|
||||||
|
dist = 1.0 - distance((0.0, 0.0), tuple((x % 1.0) - 0.5 for x in uv)) / RADIUS
|
||||||
|
|
||||||
|
col = tuple(x * dist for x in get_col(uv))
|
||||||
|
|
||||||
|
pixel.background_color.set( *col )
|
|
@ -1,7 +1,7 @@
|
||||||
import math
|
import math
|
||||||
from pixel import Pixel
|
from pixel import Pixel
|
||||||
|
|
||||||
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float):
|
def main(pixel: Pixel, resolution: tuple, frag_coord: tuple, time: float): # https://www.shadertoy.com/view/Wd23W3
|
||||||
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
|
uv = (frag_coord[0] / resolution[0], frag_coord[1] / resolution[1])
|
||||||
|
|
||||||
def hsv2rgb(h, s, v) -> tuple:
|
def hsv2rgb(h, s, v) -> tuple:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user