Just some experiments while I am learning about smoke generation and simulating things. Demo: pages/index.html. Just move cursor on Right canvas to see smoke effect. Video might not play on demo server. But smoke does :)
I am no expert in JS and this project uses modified version of following two projects:
Huuuuuuuuuuge credit goes to original authors.
particle.py
and TADAAAAAAAAAA!smokesim/examples/image_augmentation.py
.from smokesim.augmentation import Augmentation
import numpy as np
from pathlib import Path
if __name__ == "__main__":
np.random.seed(100)
WIDTH, HEIGHT = 700, 500
augmentation = Augmentation(image_path=None, screen_dim=(WIDTH, HEIGHT))
smoke_machine = augmentation.smoke_machine
augmentation.add_smoke(dict(particle_count=15, sprite_size=25, origin=(250, 500)))
augmentation.add_smoke(dict(particle_count=15, sprite_size=25, origin=(450, 500)))
augmentation.augment(steps=90,history_path=Path('media/smoke_history.mp4'))
for i in range(5):
augmentation.add_smoke(
dict(
color=smoke_machine.color,
particle_count=1,
origin=(np.random.randint(100, WIDTH), np.random.randint(100, HEIGHT)),
lifetime=200,
particle_args={
"min_lifetime": 200,
"max_lifetime": 500,
"min_scale": 10,
"max_scale": 50,
"fade_speed": 50,
"scale": 50,
"smoke_sprite_size": 50,
"color": smoke_machine.color,
},
)
)
augmentation.augment(steps=1)
augmentation.save_as('assets/augmented_smoke_image.jpg')
augmentation.end()
augment
method also accepts image where we want to put smoke. It should be NumPy array. And returns same image after augmenting it. And we can store the smoke history as well.smokesim/examples/video_augmentation.py
contains a cool project with MediaPipe. Where smoke is generated on the forefinger’s position.