8000 Add a visualization with NumPy and canvas by mattpap · Pull Request #26 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

Add a visualization with NumPy and canvas #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2022

Conversation

mattpap
Copy link
Contributor
@mattpap mattpap commented Apr 16, 2022

A combination of NumPy ndarray manipulation and HTML5 canvas (intentionally not using mpl, ...) to produce fractal images:

image

Could be made into an interactive visualization by allowing setting initial conditions, palette, etc.

@mattpap mattpap requested a review from fpliger April 16, 2022 13:21
- /palettes.py
- /fractals.py
</py-env>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could support <py-script src="./palettes.py">` as well (or alternatively).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested module structure would be nice to have as well. Currently any attempts failed with various errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattpap it does support src. Check out the todo example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that part. However, I wanted to achieve was to include a script and then import from it. I ended up using <py-env>.

import numpy as np

from palettes import Magma256
from fractals import mandelbrot, julia
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if those were relative imports, assuming it's possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not sure. I'll merge and we can try it and change later.

Copy link
Contributor
@fpliger fpliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Will hold to merge a little in case you have a feedback or want to move the code to a source file, per comments.

- /palettes.py
- /fractals.py
</py-env>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattpap it does support src. Check out the todo example.

@fpliger fpliger merged commit 556feda into main Apr 19, 2022
@fpliger fpliger deleted the mattpap/numpy_canvas_example branch April 19, 2022 16:08
@mattpap
Copy link
Contributor Author
mattpap commented Apr 19, 2022

Will hold to merge a little in case you have a feedback or want to move the code to a source file, per comments.

I think I'm good with the current state of this PR. I will submit a follow-up to address Peter's suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0