Skip to content

Commit

Permalink
0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Parmer authored and Jack Parmer committed Jul 7, 2024
1 parent 8a5b156 commit 84ea5bf
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 69 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file removed dist/voxel_world-0.1.2-py2.py3-none-any.whl
Binary file not shown.
Binary file removed dist/voxel_world-0.1.2.tar.gz
Binary file not shown.
Binary file removed dist/voxel_world-0.1.3.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/voxel_world-0.1.4.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
{name = "JP", email = "[email protected]"}
]
description = "Delicious Voxel worlds in Python"
version = "0.1.3"
version = "0.1.4"
readme = "README.md"
requires-python = ">=3.7"
dependencies = [
Expand Down
108 changes: 42 additions & 66 deletions src/voxel_world.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: voxel_world
Version: 0.1.3
Version: 0.1.4
Summary: Delicious Voxel worlds in Python
Author-email: JP <[email protected]>
Requires-Python: >=3.7
Expand All @@ -17,13 +17,12 @@ Requires-Dist: textwrap
Requires-Dist: webbrowser

# VoxelWorld
Create delicious Voxel worlds in Python

[Live demo on Py.Cafe ☕](https://py.cafe/jackparmer/voxel-worlds)
3d Numpy array in -> Voxel world out

<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/680dcde4-299e-4508-8cb7-1779831b1b98">
[Demo on Py.Cafe ☕](https://py.cafe/jackparmer/voxel-worlds)

<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/917f38ac-dd26-4419-9725-0693ca05aaa1">
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/680dcde4-299e-4508-8cb7-1779831b1b98">

## Install

Expand All @@ -43,44 +42,19 @@ from voxel_world import VoxelWorld

## About

For physics simulation, games, art, and fun

Inspo: https://github.com/wwwtyro/vixel
For physics simulation, computer vision, games, art, whatever

Features!
- Automatic GIF generation
- Numpy 3d ones array in -> Voxel world out
- Fast-ish (as fast as rendering on the CPU can be)
- Portable! Outputs simple image files
- Simple! Numpy 3d ones array in -> Voxel world out
- Portable! Outputs images or standalone HTML files with [Vixel](https://github.com/wwwtyro/vixel)
- Notebooks! Works well in the Jupyter notebook ecosystem
- Eye candy! [Ambient occlusion](https://en.wikipedia.org/wiki/Ambient_occlusion), specularity, etc

Known issues (TODO)
- Speed: Need to migrate to a GPU-based renderer while maintaining portability (suggestions?)
- Illumination: Light source ray tracing is wonky - but you can fake it (see light_source.py example)
- Cut offs: The bottom of some voxel cubes are cut off - I'm not sure why
- Likely much more...
- Eye candy! [Ambient occlusion](https://en.wikipedia.org/wiki/Ambient_occlusion), ray tracing from Vixel, etc

***

# Examples

## Animations

```py
from voxel_world import Volume, Surface, Agent, Sequence

volume = Volume(Volume.purlin_matrix(64));
surf = Surface(volume);
agents = [Agent(surf, mask) for mask in Sequence.snake(grid_size=64, num_steps=1000)];
seq = Sequence(agents);

seq2 = seq.apply_bg(volume)

seq2.save('voxel_animation64_v2.gif')
```
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/blob/main/voxel_animation64.gif?raw=true">

## Surfaces API

```
Expand All @@ -89,60 +63,62 @@ volume = Volume(Volume.purlin_matrix(32)); surf = Surface(volume)
surf.color = (255,0,0)
volume.add(surf).show()
```
![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/30d0d2f8-8f7b-426c-b394-d18ca2c47c93)
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/4a9c5f99-4ff2-441b-9086-fac3c4e7132a">

## Randomly generated worlds
## Random world

[Live demo on Py.Cafe ☕](https://py.cafe/jackparmer/voxel-worlds)
[Demo on Py.Cafe ☕](https://py.cafe/jackparmer/voxel-worlds)

```py
import random; import vnoise
from IPython.display import display, Image as IPImage
import random
from voxel_world import Volume

noise = vnoise.Noise()

# Display in Juypter
display(IPImage(Volume(
np.array([[[1 if noise.noise3(x / 10.0, y / 10.0, z / 10.0) > random.uniform(-0.2, 0.2) else 0 for z in range(16)] for y in range(16)] for x in range(16)], dtype=np.uint8),
Volume(
Volume.purlin_matrix(16),
theme=random.choice(list(Volume.themes.keys())),
resolution=10,
viewing_angle=(random.randint(0, 90), random.randint(0, 90)),
zoom=2.0,
show_light_source=False,
dark_bg=False
).byte_stream().getvalue()))
).render().show()
```
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/80ad3ed5-15f2-427f-9608-72a46b07e932">

![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/25bd612e-b8e9-42ed-91b4-014921173900)
## Ray tracing + WebGL renderer

![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/11d299d1-532a-4ef4-a5a0-6a7bb93c1126)
```py
from voxel_world import Volume, Vixel; vw = Volume(); vix = Vixel(vw); vix.html()
```

![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/9085eab6-4091-4548-8c61-5fe875a19cc2)
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/90826a0c-6d74-4956-acd1-fa230a79c9da">

![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/cc435d8b-e5c0-4bab-88b3-f66de29a48a3)
## Animations

## [examples/color_matrix/sand_world.py](examples/color_matrix/sand_world.py)
```py
from voxel_world import Volume, Surface, Agent, Sequence

![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/f2a61fae-5133-4e2c-8bf9-71e69c1d0948)
volume = Volume(Volume.purlin_matrix(64));
surf = Surface(volume);
agents = [Agent(surf, mask) for mask in Sequence.snake(grid_size=64, num_steps=1000)];
seq = Sequence(agents);

## [examples/lighting/light_source.py](examples/lighting/light_source.py)
seq2 = seq.apply_bg(volume)

![download (1)](https://github.com/jackparmer/VoxelWorld/assets/1865834/d86f3e6a-322a-4273-8260-fc41fb215eaf)
seq2.save('voxel_animation64_v2.gif')
```
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/blob/main/voxel_animation64.gif?raw=true">

## [examples/color_matrix/jill_of_the_jungle.py](examples/color_matrix/jill_of_the_jungle.py)
<img width="500" alt="image" src="https://github.com/jackparmer/VoxelWorld/blob/main/compression_animation.gif?raw=true">

![jill_of_the_jungle](https://github.com/jackparmer/VoxelWorld/assets/1865834/820494a5-452f-4f87-b6c7-bbe4abc3e65e)
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/917f38ac-dd26-4419-9725-0693ca05aaa1">

## [examples/color_matrix/earth_tones.py](examples/color_matrix/earth_tones.py)
## [examples/color_matrix/sand_world.py](examples/color_matrix/sand_world.py)

![earth_tones](https://github.com/jackparmer/VoxelWorld/assets/1865834/1cffc6bf-a07c-4804-86fa-783dae51b3b6)
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/f2a61fae-5133-4e2c-8bf9-71e69c1d0948">

## Mono-color themes
## [examples/lighting/light_source.py](examples/lighting/light_source.py)

```py
from voxel_world import Volume
<img width="800" alt="image" src="https://github.com/jackparmer/VoxelWorld/assets/1865834/d86f3e6a-322a-4273-8260-fc41fb215eaf">

world = Volume.show_themes() # Jupyter notebook only
#### Publishing to pip
```sh
python3 -m build
python3 -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
```
![image](https://github.com/jackparmer/VoxelWorld/assets/1865834/ab7eca82-5b20-4b7e-bbae-a2e8350b4611)
2 changes: 0 additions & 2 deletions src/voxel_world.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ bin/pip
bin/pip3
bin/pip3.11
dist/.DS_Store
dist/voxel_world-0.1.2-py2.py3-none-any.whl
dist/voxel_world-0.1.2.tar.gz
examples/.DS_Store
examples/color_matrix/earth_tones.py
examples/color_matrix/jill_of_the_jungle.py
Expand Down

0 comments on commit 84ea5bf

Please sign in to comment.