Skip to content

Commit

Permalink
30 31
Browse files Browse the repository at this point in the history
  • Loading branch information
villares committed Feb 1, 2025
1 parent dd33565 commit 79bb837
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
Binary file added 2025/sketch_2025_01_30/sketch_2025_01_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions 2025/sketch_2025_01_30/sketch_2025_01_30.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import py5
import numpy as np

noise_increment = 0.003

def setup():
global mesh_x, mesh_y, rgba_map, rgbb_map
py5.size(500, 500)
py5.color_mode(py5.HSB)
csa = [py5.color(255) if i % 8 else py5.color(i % 255, 200, 200)
for i in range(512)]

# csb = [py5.color(i % 255, 200, 200)
# for i in range(512)]

rgba_map = colors_to_colorarray(csa)
# rgbb_map = colors_to_colorarray(csb)

mesh_x, mesh_y = np.meshgrid(
np.arange(0, py5.width * noise_increment, noise_increment),
np.arange(0, py5.height * noise_increment, noise_increment)
)

def draw():
py5.rect(0, 0, 500, 500)
osna = py5.os_noise(mesh_x + py5.mouse_x * noise_increment,
mesh_y + py5.mouse_y * noise_increment,
py5.frame_count * noise_increment)
# osnb = py5.os_noise(1000 + mesh_x + py5.mouse_x * noise_increment,
# 1000 + mesh_y + py5.mouse_y * noise_increment,
# 1000 + py5.frame_count * noise_increment)
# color_indices = py5.remap(osnb, -1, 1, 0, len(osnb) - 1).astype(np.uint8)
# npb = rgbb_map[color_indices]
# py5.set_np_pixels(npb, bands="RGBA")

color_indices = py5.remap(osna, -1, 1, 0, len(osna) - 1).astype(np.uint8)
npa = rgba_map[color_indices]
py5.set_np_pixels(npa, bands="RGBA")
py5.window_title(str(round(py5.get_frame_rate(), 1)))


def colors_to_colorarray(color_list):
return np.dstack((
[c >> 16 & 0xFF for c in color_list],
[c >> 8 & 0xFF for c in color_list],
[c & 0xFF for c in color_list],
[0 if c == 255 else 255 for c in color_list], # note 255 is not a color...
))[0] # it serves as a sentinel value for

def key_pressed():
py5.save('out.png')

py5.run_sketch(block=False)
Binary file added 2025/sketch_2025_01_31/sketch_2025_01_31.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions 2025/sketch_2025_01_31/sketch_2025_01_31.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import py5
import numpy as np

noise_increment = 0.003

def setup():
global mesh_x, mesh_y, rgba_map, rgbb_map
py5.size(500, 500)
py5.color_mode(py5.HSB)
csa = [#py5.color(255) if i % 8 else
py5.color(i % 255, 200, 200)
for i in range(512)]

# csb = [py5.color(i % 255, 200, 200)
# for i in range(512)]

rgba_map = colors_to_colorarray(csa)
# rgbb_map = colors_to_colorarray(csb)

mesh_x, mesh_y = np.meshgrid(
np.arange(0, py5.width * noise_increment, noise_increment),
np.arange(0, py5.height * noise_increment, noise_increment)
)

def draw():
py5.rect(0, 0, 500, 500)
osna = py5.os_noise(mesh_x + py5.mouse_x * noise_increment,
mesh_y + py5.mouse_y * noise_increment,
py5.frame_count * noise_increment)
# osnb = py5.os_noise(1000 + mesh_x + py5.mouse_x * noise_increment,
# 1000 + mesh_y + py5.mouse_y * noise_increment,
# 1000 + py5.frame_count * noise_increment)
# color_indices = py5.remap(osnb, -1, 1, 0, len(osnb) - 1).astype(np.uint8)
# npb = rgbb_map[color_indices]
# py5.set_np_pixels(npb, bands="RGBA")

color_indices = py5.remap(osna, -1, 1, 0, len(osna) - 1).astype(np.uint8)
npa = rgba_map[color_indices]
sa = np.sort(npa, axis=0)
py5.set_np_pixels(sa, bands="RGBA")
py5.window_title(str(round(py5.get_frame_rate(), 1)))


def colors_to_colorarray(color_list):
return np.dstack((
[c >> 16 & 0xFF for c in color_list],
[c >> 8 & 0xFF for c in color_list],
[c & 0xFF for c in color_list],
[0 if c == 255 else 255 for c in color_list], # note 255 is not a color...
))[0] # it serves as a sentinel value for

def key_pressed():
py5.save_frame('out###.png')

py5.run_sketch(block=False)
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ If you appreciate what I have been doing, you may also support my artistic work,
2025 \| [<b>2024</b>](2024.md) \| [<b>2023</b>](2023.md) \| [<b>2022</b>](2022.md) \| [<b>2021</b>](2021.md) \| [<b>2020</b>](2020.md) \| [<b>2019</b>](2019.md) \| [<b>2018</b>](2018.md)


---

### sketch_2025_01_31

![sketch_2025_01_31](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_01_31/sketch_2025_01_31.gif)

[sketch_2025_01_31](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_01_31) [[py5](https://py5coding.org/)]

Using #numpy.sort on a variation of the previous sketch, animating a few frames, but the color compression is brutal :(

---

### sketch_2025_01_30

![sketch_2025_01_30](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_01_30/sketch_2025_01_30.png)

[sketch_2025_01_30](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_01_30) [[py5](https://py5coding.org/)]



---

### sketch_2025_01_29
Expand Down

0 comments on commit 79bb837

Please sign in to comment.