0

`

import numpy as np               
import matplotlib.pyplot as plt
import math
import matplotlib.animation as animation

print("PLease input values in range of 0 to 500")
x0coord = int(input("Enter first x coordinate "))
y0coord = int(input("Enter first y coordinate "))
x1coord = int(input("Enter second x coordinate "))
y1coord = int(input("Enter second y coordinate "))
x2coord = int(input("Enter third x coordinate "))
y2coord = int(input("Enter third y coordinate "))
x3coord = int(input("Enter fourth x coordinate "))
y3coord = int(input("Enter fourth y coordinate "))

img = np.ones((500,500,3))
dot, = ax.plot([], [], 'o', color='red', markersize=10)
def DrawBezier(x0,y0, x1,y1, x2,y2, x3,y3): 
    dot.set_data(100,200)
    x = x0 
    y = y0 
    t = 0 
    ts = 0.001
    while t <= 1.0:   
        B0 = 1*(1-t) * (1-t) 
        B1 = 2* (1-t) * t 
        B2 = 1* t * t 
        x = int(x0*B0 + x1*B1 + x2*B2)
        y = int(y0*B0 + y1*B1 + y2*B2)
        img[y,x] = (1,0,0)
        t=t+ts 
    return







DrawBezier(x0coord, y0coord,     x1coord, y1coord,    x2coord, y2coord,   x3coord, y3coord)
%matplotlib notebook
plt.figure(figsize=(10,8), dpi = 100, facecolor='w')
plt.imshow(img)
plt.show()

` this is how it is supposed to look I need to make control points visible, animation should start at the starting point and flow into the ending point, the control point coordinates have to be entered by user with either text box or mouse, has to be at least 3 control points (including start and end points)

  • See e.g. [Matplotlib animation in real time](https://stackoverflow.com/questions/33509052/matplotlib-animation-in-real-time) – JohanC Dec 21 '22 at 15:01

0 Answers0