Skip to content

Instantly share code, notes, and snippets.

@tigarmo
Created February 22, 2019 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tigarmo/8c24c5c8a541e7ae3c54492c62e8a41b to your computer and use it in GitHub Desktop.
Save tigarmo/8c24c5c8a541e7ae3c54492c62e8a41b to your computer and use it in GitHub Desktop.
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