OMC::DrawingVectorLayer Class Reference

Detailed Description

Represents a vector layer in a vector drawing.

Provided as a layer from a vector drawing layer (OMC::DrawingVectorArtLayer*), this layer represents a vector layer within the drawing – composed of a number of strokes. The strokes can be filled and can be treated with a custom linestyle. Some modifications can be made to the layer with methods defined here, more detailed modifications can be made with the OMC::DrawingAccess* object.

Inspect the Vector Layers

import traceback
from ToonBoom import harmony
sess = harmony.session()
proj = sess.project
scene = proj.scene
#Drawing Node to modify.
drawing_node = scene.nodes["Top/Drawing"]
at_frame = 1
vector_drawing = False
#Using the drawing attribute to get the current vector drawing.
try:
drawing_attr = drawing_node.attributes["DRAWING"]
element = drawing_attr.element
element_drawing = element.drawings[ drawing_attr.drawing.value(at_frame) ]
vector_drawing = element_drawing.drawing
except:
traceback.print_exc()
if vector_drawing:
line_art = vector_drawing["line"]
#The Art Layer
if line_art:
print( "Found Art Layer" )
for n,layer in enumerate( line_art ):
if layer.type == "Vector":
print( "Layer : %03d"%(n) )
print( " Strokes: %s"%( len(layer.strokes) ) )
print( " Contours: %s"%( len(layer.contours) ) )
print( " Joints: %s"%( len(layer.joints) ) )
bounding_box = layer.bounding_box
print( " Bounds : %s,%s (x,y) -- %s,%s (width,height)"%( bounding_box.x, bounding_box.y, bounding_box.width, bounding_box.height ) )
else:
print( "Not a Vector Art layer." )

Public Member Functions

void transform (const OMC::Matrix *matrix)
 Transform the layer. More...
 
void translate (const OMC::Vector2d *offset)
 Translates the text layer. More...
 
OMC::DrawingVectorArtLayerdrawing () const
 Returns the OMC::DrawingVectorArtLayer* object that owns this layer. More...
 

Public Attributes

OMC::DrawingVectorContourListcontours
 The contour list for this vector drawing layer. More...
 
OMC::DrawingVectorStrokeListstrokes
 The stroke list for this vector drawing layer. More...
 
OMC::DrawingVectorJointListjoints
 The joint list for this vector drawing layer. More...
 
OMC::AllocatedRect2d * bounding_box
 The bounding box of the layer. More...
 
OMC::AllocatedRect2d * bounding_box_visible
 The visible bounding box. More...
 
OMC::AllocatedRect2d * bounding_box_linestyle
 The bounding box with linestyle. More...
 
QString type
 The type of the drawing layer. More...
 

Member Function Documentation

◆ drawing()

OMC::DrawingVectorArtLayer* OMC::DrawingLayer::drawing ( ) const
inherited

Returns the OMC::DrawingVectorArtLayer* object that owns this layer.

Returns
The OMC::DrawingVectorArtLayer* object that owns the layer.

◆ transform()

void OMC::DrawingVectorLayer::transform ( const OMC::Matrix matrix)

Transform the layer.

Transform the vector layer with the provided matrix. Only the 2d components of the matrix are considered.

Randomly transforming each layer

import random
import traceback
from ToonBoom import harmony
sess = harmony.session()
proj = sess.project
scene = proj.scene
#Drawing Node to modify.
drawing_node = scene.nodes["Top/Drawing"]
at_frame = 1
vector_drawing = False
#Using the drawing attribute to get the current vector drawing.
try:
drawing_attr = drawing_node.attributes["DRAWING"]
element = drawing_attr.element
element_drawing = element.drawings[ drawing_attr.drawing.value(at_frame) ]
vector_drawing = element_drawing.drawing
except:
traceback.print_exc()
if vector_drawing:
proj.history.begin( "Randomizing Drawing" )
for artLayer in vector_drawing:
for n,layer in enumerate( artLayer ):
if layer.type == "Vector":
matrix = harmony.Matrix()
matrix.scale( random.uniform(0.5, 1.5), random.uniform(0.5, 1.5), 1.0 )
layer.transform( matrix )
proj.history.end()

◆ translate()

void OMC::DrawingVectorLayer::translate ( const OMC::Vector2d offset)

Translates the text layer.

Translates the vector layer with the provided vector.

Randomly translating each layer

import random
import traceback
from ToonBoom import harmony
sess = harmony.session()
proj = sess.project
scene = proj.scene
#Drawing Node to modify.
drawing_node = scene.nodes["Top/Drawing"]
at_frame = 1
vector_drawing = False
#Using the drawing attribute to get the current vector drawing.
try:
drawing_attr = drawing_node.attributes["DRAWING"]
element = drawing_attr.element
element_drawing = element.drawings[ drawing_attr.drawing.value(at_frame) ]
vector_drawing = element_drawing.drawing
except:
traceback.print_exc()
if vector_drawing:
proj.history.begin( "Randomizing Drawing" )
for artLayer in vector_drawing:
for n,layer in enumerate( artLayer ):
if layer.type == "Vector":
vector = harmony.Vector2d()
vector.translate( [random.uniform(-500, 500), random.uniform(-500, 500), 1.0] )
layer.translate( vector )
proj.history.end()

Member Data Documentation

◆ bounding_box

OMC::DrawingLayer::bounding_box
inherited

The bounding box of the layer.

Get the world bounding-box of the drawing.

◆ bounding_box_linestyle

OMC::DrawingLayer::bounding_box_linestyle
inherited

The bounding box with linestyle.

Get the bounding-box of the drawing's visible content, with the linestyle considered.

◆ bounding_box_visible

OMC::DrawingLayer::bounding_box_visible
inherited

The visible bounding box.

Get the world bounding-box of the drawing's visible content.

◆ contours

OMC::DrawingVectorLayer::contours

The contour list for this vector drawing layer.

Contours are derived regions formed by the strokes. These regions can be filled on the left or right side of the stroke, in relation to the direction in which the stroke is formed.

◆ joints

OMC::DrawingVectorLayer::joints

The joint list for this vector drawing layer.

Joints are the points at which strokes are connected to each other, or at the extremities of the stroke. Joints have positions and a list of strokes that are ordered counter-clockwise.

◆ strokes

OMC::DrawingVectorLayer::strokes

The stroke list for this vector drawing layer.

A stroke defines a bezier path in a drawing that can be have a linestyle or fill applied. The strokes form contours that can be filled and joints at intersections.

◆ type

QString OMC::DrawingLayer::type
readinherited

The type of the drawing layer.

A string representing the type of layer – the following types are supported:

  • Vector
Inheritance diagram for OMC::DrawingVectorLayer:
Collaboration diagram for OMC::DrawingVectorLayer: