# Circle

VTKExamples/Python/GeometricObjects/Circle

### Description¶

A circle is simply the limiting case of a regular polygon. In this example vtkRegularPolygonSource is used with a large number of Sides to approximate a circle. A disk is in fact generated here, to generate a circle, uncomment the line: polygonSource.GeneratePolygonOff()

Other Languages

See (Cxx), (Java)

Question

If you have a simple question about this example contact us at VTKExamplesProject If your question is more complex and may require extended discussion, please use the VTK Discourse Forum

### Code¶

Circle.py

#!/usr/bin/env python
import vtk

def main():
colors = vtk.vtkNamedColors()

# Create a circle
polygonSource = vtk.vtkRegularPolygonSource()
# Comment this line to generate a disk instead of a circle.
polygonSource.GeneratePolygonOff()
polygonSource.SetNumberOfSides(50)
polygonSource.SetCenter(0.0, 0.0, 0.0)

#  Visualize
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(polygonSource.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(colors.GetColor3d('Cornsilk'))

renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.SetWindowName("Circle")