SmokeSim

Smoke Generation

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 :)

Disclaimer

I am no expert in JS and this project uses modified version of following two projects:

Huuuuuuuuuuge credit goes to original authors.

Demo

JavaScript Version

What to do?

  1. Clone this.
  2. Start a localhost server (on this dir) to avoid CORS Errors. I am using server.py taken from here.
  3. Open http://localhost:8003/js_demo/index.html and see it for yourself.

PyGame Version

What to do?

Using this for Image Augmentation

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()

Using this With Video

To do