user: Show practical ways to work with CompositorNodeDefocus(CompositorNode) in a Blender add-on or script – include code.

assistant: # CompositorNodeDefocus(CompositorNode)

base classes — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct"), [`Node`](bpy.types.Node.html#bpy.types.Node "bpy.types.Node"), [`NodeInternal`](bpy.types.NodeInternal.html#bpy.types.NodeInternal "bpy.types.NodeInternal"), [`CompositorNode`](bpy.types.CompositorNode.html#bpy.types.CompositorNode "bpy.types.CompositorNode")

*class* bpy.types.CompositorNodeDefocus(*CompositorNode*)
:   Apply depth of field in 2D, using a Z depth map or mask

    angle
    :   Bokeh shape rotation offset

        Type:
        :   float in [0, 1.5708], default 0.0

    blur_max
    :   Blur limit, maximum CoC radius

        Type:
        :   float in [0, 10000], default 0.0

    bokeh
    :   - `OCTAGON`
          Octagonal – 8 sides.
        - `HEPTAGON`
          Heptagonal – 7 sides.
        - `HEXAGON`
          Hexagonal – 6 sides.
        - `PENTAGON`
          Pentagonal – 5 sides.
        - `SQUARE`
          Square – 4 sides.
        - `TRIANGLE`
          Triangular – 3 sides.
        - `CIRCLE`
          Circular.

        Type:
        :   enum in [`'OCTAGON'`, `'HEPTAGON'`, `'HEXAGON'`, `'PENTAGON'`, `'SQUARE'`, `'TRIANGLE'`, `'CIRCLE'`], default `'CIRCLE'`

    f_stop
    :   Amount of focal blur, 128 (infinity) is perfect focus, half the value doubles the blur radius

        Type:
        :   float in [0, 128], default 0.0

    scene
    :   Scene from which to select the active camera (render scene if undefined)

        Type:
        :   [`Scene`](bpy.types.Scene.html#bpy.types.Scene "bpy.types.Scene")

    use_zbuffer
    :   Disable when using an image as input instead of actual z-buffer (auto enabled if node not image based, eg. time node)

        Type:
        :   boolean, default False

    z_scale
    :   Scale the Z input when not using a z-buffer, controls maximum blur designated by the color white or input value 1

        Type:
        :   float in [0, 1000], default 0.0

    *classmethod* is_registered_node_type()
    :   True if a registered node type

        Returns:
        :   Result

        Return type:
        :   boolean

    *classmethod* input_template(*index*)
    :   Input socket template

        Parameters:
        :   **index** (*int in* *[**0**,* *inf**]*) – Index

        Returns:
        :   result

        Return type:
        :   [`NodeInternalSocketTemplate`](bpy.types.NodeInternalSocketTemplate.html#bpy.types.NodeInternalSocketTemplate "bpy.types.NodeInternalSocketTemplate")

    *classmethod* output_template(*index*)
    :   Output socket template

        Parameters:
        :   **index** (*int in* *[**0**,* *inf**]*) – Index

        Returns:
        :   result

        Return type:
        :   [`NodeInternalSocketTemplate`](bpy.types.NodeInternalSocketTemplate.html#bpy.types.NodeInternalSocketTemplate "bpy.types.NodeInternalSocketTemplate")

    update()

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   type