Display an ellipse shape using P1D data points
Source code name: "shapes_ellipse1.py"
Programming language: Python
Topic: Graphics/2D
DMelt Version 1. Last modified: 05/09/2015. License: Pro
https://datamelt.org/code/cache/shapes_ellipse1_4595.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from java.awt import *
from jhplot import * 
from jhplot.shapes  import *
from math import *

c1 =HPlot("Canvas",600,600)
c1.setGTitle("Drawing shapes")
c1.setAntiAlias(1)
c1.setNameX("X")
c1.setNameY("Y")
c1.setRange(-5.0, 5.0, -5, 5.0)
c1.visible(1)

p1=P1D("Ellipse data")
# a, b are the radius on the x and y axes respectively
a=3  # major
b=2  # minor
xshift=1  # (X,Y) position
yshift=2
step=0.05 # step 
ra=[v*step for v in range(0,int(2*3.2/step))] # generate points (3.2 instead of 2*pi!) to close the object
for t in ra:  
      x = a*cos(t)+xshift
      y = b*sin(t)+yshift
      p1.add(x, y)
c1.draw(p1)

# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png");


You see the box below because you did not login.