Animate Circle with SVG

Animate Circle with SVG

In [1]:
from IPython.display import HTML

Create HTML

In [2]:
HTML("""
""")
Out[2]:
In [3]:
HTML("""
    <></>
""")
Out[3]:
<>

Create SVG tag

In [4]:
HTML("""
    <svg></svg>
""")
Out[4]:

Set width and height of SVG

In [5]:
HTML("""
    <svg width="500" height="100">
    
    </svg>
""")
Out[5]:

Create Circle tag

In [6]:
HTML("""
    <svg width="500" height="100">
        <circle></circle>
    </svg>
""")
Out[6]:

Define circle radius

The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0,0).

The r attribute defines the radius of the circle

In [7]:
HTML("""
    <svg width="500" height="100">
        <circle r = "30" fill = "orange"></circle>
    </svg>
""")
Out[7]:

Define position of circle (x coordinate)

In [8]:
HTML("""
    <svg width="500" height="100">
        <circle r = "30" cx="50" fill = "orange"></circle>
    </svg>
""")
Out[8]:

Define position of circle (y coordinate)

Start from here

In [9]:
HTML("""
    <svg width="500" height="100">
        <circle r = "30" cx="50" cy = "50" fill = "orange"></circle>
    </svg>
""")
Out[9]:

Change color, size

In [10]:
HTML("""
    <svg width="500" height="100">
        <circle r = "10" cx="50" cy = "50" fill = "orange"></circle>
    </svg>
""")
Out[10]:
In [11]:
HTML("""
    <svg width="500" height="100">
        <circle r = "10" cx="50" cy = "50" fill = "blue" stroke = "red" stroke-width = "3"></circle>
    </svg>
""")
Out[11]:
In [12]:
HTML("""
    <svg width="500" height="100">
        <circle r = "30" cx="50" cy = "50" fill = "orange" stroke = "red" stroke-width = "2"></circle>
        <circle r = "10" cx="50" cy = "50" fill = "blue" stroke = "red" stroke-width = "3"></circle>
    </svg>
""")
Out[12]:

another cicle on the right side

In [13]:
HTML("""
    <svg width="500" height="100" >
        <circle r = "30" cx="50" cy = "50" fill = "orange"></circle>
        <circle r = "10" cx="50" cy = "50" fill = "blue"></circle>
        <circle r = "10" cx="300" cy = "50" fill = "pink"></circle>
    </svg>
""")
Out[13]:
In [ ]:
 

Animate circle

The SVG "\" element provides a way to animate a single attribute or property over time.

In [14]:
HTML("""
    <svg width="500" height="100">

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

    </svg>
""")
Out[14]:

Ciccle click on click

In [15]:
HTML("""
    <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"
            >

          </animate>
        
      </circle>

    </svg>
""")
Out[15]:

Freeze circle after reaching to end

In [16]:
HTML("""
    <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"
            >

          </animate>
        
      </circle>

    </svg>
""")
Out[16]:

Continuous repeat

In [17]:
HTML("""
    <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"
            repeatCount="indefinite"
            >

          </animate>
        
      </circle>

    </svg>
""")
Out[17]:

Two circles

In [18]:
HTML("""
    <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"
            repeatCount="indefinite"
            >

          </animate>
        
      </circle>

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

          </animate>
        
      </circle>

    </svg>
""")
Out[18]:

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