Comments (4)
Hey!
Can you share your code? So that I can help you improve it if I can :)
I already tried to create my own "animation engine" but only got choppy results so far
Use hold_canvas
as much as possible, that should improve the performances in your animation.
Is this natively possible and I just didn't figure it out yet? Or would I have to go through the whole JavaScript custom widget tutorial?
No need to write a single line of JavaScript :) You should be able to do something like:
from ipywidgets import IntSlider
from ipycanvas import Canvas, hold_canvas
# Create your canvas
# my_canvas = ...
angle_slider = IntSlider(min=0, max=90)
def update_line_angle(change):
with hold_canvas(my_canvas):
my_canvas.clear()
new_angle = change['new']
# Draw here the line given the new angle (new value of the slider)
# Observe the slider value and call update_line_angle whenever it changes
angle_slider.observe(update_line_angle, 'value')
from ipycanvas.
Hi,
thanks for your fast reply! I knew there had to be some trick ;) I already discarded my own animation attempts, but I will now try to implement it using your approach.
Regards,
Domme
from ipycanvas.
There was an issue in the code I provided, I just updated it :)
from ipycanvas.
Closing as solved, but don't hesitate to ask more questions here.
from ipycanvas.
Related Issues (20)
- voila fails to load ipycanvas.js from localhost HOT 2
- how to drag an image around on the canvas? HOT 2
- bundle text and shape into one object HOT 4
- ipycanvas does not work with JupyterLab 4 HOT 4
- debug_output only works if calling display(canvas) HOT 1
- ipycanvas 0.13.1 does not work with google colab. 0.13 works. HOT 1
- Take a screenshot of a drawing/canvas and save it? HOT 2
- current canvas out of sync after page reload
- Commands JSON content mangled HOT 3
- Error displaying widget: model not found HOT 1
- is there no call to remove a shape? HOT 1
- bug on canvas.clear() HOT 1
- any way to pause animation? HOT 2
- feature request for mouse drag HOT 2
- Using Path2D for stroke
- Error with fresh jupyterlab 3 install - "Failed to load model class" / "Error: No version of module ipycanvas is registered" HOT 3
- The docs link to github needs updating HOT 5
- Canvas not rendering shapes in Voila HOT 1
- Failed to load model class 'CanvasModel' from module 'ipycanvas' in Binder
- Supporting grayscale images from numpy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipycanvas.