Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from vtk import *
colors = vtkNamedColors()
colors.SetColor("Bkg", 0.2, 0.3, 0.4)
sphereSource = vtkSphereSource()
sphereSource.SetCenter(0.0, 0.0, 0.0)
sphereSource.SetRadius(4.0)
sphereSource.SetPhiResolution(4)
sphereSource.SetThetaResolution(8)
sphereSource.Update()
mapper = vtkPolyDataMapper()
mapper.SetInputConnection(sphereSource.GetOutputPort())
actor = vtkActor()
actor.SetMapper(mapper)
renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderer.AddActor(actor)
renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
drawing = vtkImageCanvasSource2D()
drawing.SetScalarTypeToUnsignedChar()
drawing.SetNumberOfScalarComponents(3)
drawing.SetExtent(0, 200, 0, 200, 0, 0)
drawing.SetDrawColor(255, 127, 100)
drawing.FillBox(0, 200, 0, 200)
drawing.SetDrawColor(0, 0, 0)
drawing.DrawCircle(100, 100, 50)
drawing.Update()
logoRepresentation = vtkLogoRepresentation()
#logoRepresentation.SetImage(drawing.GetOutput())
logoRepresentation.SetPosition(0, 0)
logoRepresentation.SetPosition2(0.4, 0.4)
logoRepresentation.GetImageProperty().SetOpacity(.7)
logoWidget = vtkLogoWidget()
logoWidget.SetInteractor(renderWindowInteractor)
logoWidget.SetRepresentation(logoRepresentation)
renderWindow.Render()
logoWidget.On()
renderer.SetBackground(colors.GetColor3d("Bkg"))
renderWindow.Render()
renderWindowInteractor.Start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment