0

I'm drawing a curve with equation like y=x^2.

How can i plot this curve in pixi.js or H5 canvas?

Now I can simply draw this curve in python.

# Import libraries
import matplotlib.pyplot as plt
import numpy as np
 
# Creating vectors X and Y
x = np.linspace(-2, 2, 100)
y = x ** 2
 
fig = plt.figure(figsize = (10, 5))
# Create the plot
plt.plot(x, y)
 
# Show the plot
plt.show()

I got some clues from following link.

how to draw smooth curve through N points using javascript HTML5 canvas?

do i have more simple solution, or some popular 3rd party js modules help me do this?

Charles Bao
  • 255
  • 1
  • 5
  • 16
  • Smooth curve like a bezier curve, yes? Also are you strictly dealing with 3d (webgl?) or is [2d rendering canvas](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D) ok? – Dom Aug 16 '23 at 03:12
  • maybe to treat some not so smooth curve as well, like y=tanx. I'm starting to develop a math graph calculator in pixi.js. 3d sphere is also in plan, but maybe three.js is better choice? – Charles Bao Aug 16 '23 at 03:19
  • I have limited experience with pixi and three, but they're both great choices. 3D and 2D though are two separate beasts. Really depends on what you're trying to build. Are you dealing with more triangles and 3d space? If so, three might be preferable. – Dom Aug 16 '23 at 04:38

0 Answers0