Code Monkey home page Code Monkey logo

Comments (4)

martinRenou avatar martinRenou commented on May 13, 2024 1

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.

Dommsko avatar Dommsko commented on May 13, 2024

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.

martinRenou avatar martinRenou commented on May 13, 2024

There was an issue in the code I provided, I just updated it :)

from ipycanvas.

martinRenou avatar martinRenou commented on May 13, 2024

Closing as solved, but don't hesitate to ask more questions here.

from ipycanvas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.