SVG Animation

SVG Animation

In [1]:
from IPython.display import HTML

Draw Circle

In [2]:
HTML("""
    <html>
        <body>
            <h3>Move Circle</h3>

            <svg width="500" height="100">

              <circle r="30" cx="50" cy="50" fill="orange">

              </circle>

            </svg>        
        </body>
    </html>
""")
Out[2]:

Move Circle

Animate Circle

: The SVG element provides a way to animate an attribute of an element over time. attributeName: required - must be valid attribute on the element the animation applies to from: optional - If you will not give, it will start from current position. to: required - The value the attribute should be animated to dur: required - The duration of the anomation begin/end: optional - When the animation should begin or end like on click fill: optional - Specifies what happens when animation completes. freeze means "remains the animation end"
In [3]:
HTML("""
    <html>
        <body>
            <h3>Animate Circle</h3>

            <svg width="500" height="100">

              <circle r="30" cx="50" cy="50" fill="orange">

              <animate 
                 attributeName="cx"
                 from="50"
                 to="450" 
                 dur="1s"
                 begin="click"
                 fill="freeze" />

              </circle>

            </svg>        
        </body>
    </html>
""")
Out[3]:

Animate Circle

Animate circle vertically

In [4]:
HTML("""
    <html>
        <body>
            <h3>Move Circle</h3>

            <svg width="500" height="500">

              <circle r="30" cx="50" cy="50" fill="orange">

              <animate 
                 attributeName="cy"
                 from="50"
                 to="450" 
                 dur="1s"
                 begin="click"
                 fill="freeze" />

              </circle>

            </svg>        
        </body>
    </html>
""")
Out[4]:

Move Circle

In [5]:
HTML("""
    <html>
        <body>
            <h3>Move Circle</h3>

            <svg width="500" height="500">

              <circle r="30" cx="50" cy="50" fill="orange">
              
              <animate 
                 attributeName="cx"
                 from="50"
                 to="450" 
                 dur="1s"
                 begin="click"
                 fill="freeze" />

              </circle>
              <circle r="30" cx="150" cy="150" fill="green">

              <animate 
                 attributeName="cx"
                 from="50"
                 to="450" 
                 dur="1s"
                 begin="click"
                 fill="freeze" />

              </circle>


            </svg>        
        </body>
    </html>
""")
Out[5]:

Move Circle

In [6]:
HTML("""
    <html>
        <body>
            <h3>Move Circle</h3>

            <svg width="500" height="500">

              <circle r="30" cx="50" cy="50" fill="orange">
              
              <animate 
                 attributeName="cx"
                 from="50"
                 to="450" 
                 dur="1s"
                 begin="click"
                 fill="freeze" repeatCount="indefinite" />

              </circle>
              <circle r="30" cx="150" cy="150" fill="green">

              <animate 
                 attributeName="cx"
                 from="50"
                 to="450" 
                 dur="1s"
                 begin="click"
                 fill="freeze"
                 />

              </circle>


            </svg>        
        </body>
    </html>
""")
Out[6]:

Move Circle

In [7]:
HTML("""
    <html>
        <body>
            <h3>Move Circle</h3>

            <svg viewBox="0 0 10 10" width = "200" height = "100">
              <rect width="10" height="10">
                <animate attributeName="rx" values="0;5;0" dur="10s" repeatCount="indefinite" />
              </rect>
            </svg>
        </body>
    </html>
""")
Out[7]:

Move Circle

In [ ]:
 

Animate Circle in circle path

In [8]:
HTML("""
    <html>
        <body>
            
            <svg viewBox="0 0 200 100" width="500" height="200">
              <path id="path1" fill="none" stroke="lightgrey"
                d="M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z" />

              <circle r="5" fill="red">
                <animateMotion dur="10s" repeatCount="indefinite"
                  path="M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z" />
              </circle>
            </svg>
        </body>
    </html>
""")
Out[8]:
In [ ]:
 
In [ ]:
 
In [9]:
HTML("""
    <html>
        <body>
            
            <svg viewBox="0,0 10,10" width="200px" height="200px">
                <path 
                    id="theMotionPath"
                    fill="none"
                    stroke="lightgrey"
                    stroke-width="0.25"
                    d="
                      M 5 5
                      m -4, 0
                      a 4,4 0 1,0  8,0
                      "
                />
            </svg>
        </body>
    </html>
""")
Out[9]:
In [10]:
HTML("""
    <html>
        <body>
            
            <svg viewBox="0,0 10,10" width="200px" height="200px">
                <path 
                    id="theMotionPath"
                    fill="none"
                    stroke="lightgrey"
                    stroke-width="0.25"
                    d="
                      M 5 5
                      m -4, 0
                      a 4,4 0 1,0  8,0
                      a 4,4 0 1,0 -8,0
                      "
                />
            </svg>
        </body>
    </html>
""")
Out[10]:
In [11]:
HTML("""
    <html>
        <body>
            <h3>Draw polygon</h3>
                <svg viewBox="0,0 10,10" width="200px" height="200px">
  
                  <path 
                    id="theMotionPath"
                    fill="none"
                    stroke="lightgrey"
                    stroke-width="0.25"
                    d="
                      M 5 5
                      m -4, 0
                      a 4,4 0 1,0  8,0
                      a 4,4 0 1,0 -8,0
                      "
                  />

                  <circle r="1" fill="red">
                  </circle>

                </svg>
        </body>
    </html>
""")
Out[11]:

Draw polygon

The SVG element let define how an element moves along a motion path.

In [12]:
HTML("""
    <html>
        <body>
            <h3>Draw polygon</h3>
                <svg viewBox="0,0 10,10" width="200px" height="200px">
  
                  <path 
                    id="theMotionPath"
                    fill="none"
                    stroke="lightgrey"
                    stroke-width="0.25"
                    d="
                      M 5 5
                      m -4, 0
                      a 4,4 0 1,0  8,0
                      a 4,4 0 1,0 -8,0
                      "
                  />

                  <circle r="1" fill="red">
                    <animateMotion dur="5s" repeatCount="indefinite">
                    </animateMotion>
                  </circle>

                </svg>
        </body>
    </html>
""")
Out[12]:

Draw polygon

In [13]:
HTML("""
    <html>
        <body>
            <h3>Draw polygon</h3>
                <svg viewBox="0,0 10,10" width="200px" height="200px">
  
                  <path 
                    id="theMotionPath"
                    fill="none"
                    stroke="lightgrey"
                    stroke-width="0.25"
                    d="
                      M 5 5
                      m -4, 0
                      a 4,4 0 1,0  8,0
                      a 4,4 0 1,0 -8,0
                      "
                  />

                  <circle r="1" fill="red">
                    <animateMotion dur="5s" repeatCount="indefinite">
                       <mpath xlink:href="#theMotionPath" />
                    </animateMotion>
                  </circle>

                </svg>
        </body>
    </html>
""")
Out[13]:

Draw polygon

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing