CGO Shapes
Jump to navigation
Jump to search
In PyMOL, a Compiled Graphics Object, or CGO, is a Python list of floating point numbers, which is compiled by PyMOL into a CGO object and associated with a given state. CGOs can be created in the PyMOL scene with the Load_CGO command.
CGO Commands
Based on an old version of the User Manual:
Lowercase names below should be replaced with floating-point numbers. Generally, the TRIANGLE primitive should only be used only as a last restore since it is much less effective to render than using a series of vertices with a BEGIN/END group. BEGIN, { POINTS | LINES | LINE_LOOP | LINE_STRIP | TRIANGLES | TRIANGLE_STRIP | TRIANGLE_FAN }, VERTEX, x, y, z, COLOR, red, green, blue, NORMAL, normal-x, normal-y, normal-z, END, LINEWIDTH, line-width, WIDTHSCALE, width-scale, # for ray-tracing SPHERE, x, y, z, radius # uses the current color [[Category:CGO]] CYLINDER, x1, y1, z1, x2, y2, z2, radius, red1, green1, blue1, red2, green2, blue2, TRIANGLE, x1, y1, z1, x2, y2, z2, x3, y3, z3, normal-x1, normal-y1, normal-z1, normal-x2, normal-y2, normal-z2, normal-x3, normal-y3, normal-z3, red1, green1, blue1, red2, green2, blue2, red3, green3, blue3, CONE, x1, y1, z1, x2, y2, z2, r1, r2, red1, green1, blue1, red2, green2, blue2, cap1, cap2 # should the ends be solid (1) or open (0)?
EXAMPLES
from pymol import cgo
# Unit sphere at the origin
plain_sphere = [cgo.SPHERE, 0, 0, 0, 1]
cmd.load_cgo(plain_sphere, "plain_sphere")
# Red unit sphere at (3, 4, 5)
red_sphere = [cgo.COLOR, 1, 0, 0, cgo.SPHERE, 3, 4, 5, 1]
cmd.load_cgo(red_sphere, "red_sphere")
# Narrow yellow cylinder
pos0 = [-1, -1, -1]
pos1 = [-1, -1, 1]
r = 0.1
yellow = [1, 1, 0]
yellow_cyl = [cgo.CYLINDER, *pos0, *pos1, r, *yellow, *yellow]
cmd.load_cgo(yellow_cyl, "yellow_cylinder")
# Magenta and green cone, open on one endray
pos0 = [2, 2, 2]
pos1 = [3, 3, 3]
radii = [1, 0.5]
color0 = [1, 0, 1]
color1 = [0, 1, 0]
caps = [0, 1]
cone = [CONE] + pos0 + pos1 + radii + color0 + color1 + caps
cmd.load_cgo(cone, "cone")
# adjust the camera position
set_view (\
0.022470249, 0.398223877, -0.917012811,\
0.188309744, 0.899140060, 0.395077318,\
0.981853366, -0.181560174, -0.054785311,\
0.000002960, -0.000002829, -28.313688278,\
1.387665749, 1.797374249, 2.392468214,\
21.653684616, 34.973686218, -20.000000000 )
# force a black background and save a PNG image
set ray_opaque_background, 1
png cgo_examples.png, ray=1