OMC::DrawingVectorStroke Class Reference

Detailed Description

A object providing a reference to a stroke in a OMC::DrawingVectorLayer*.

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.

Detail from a Stroke

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"]
if line_art:
for layer in line_art:
if layer.type == "Vector":
print( "Vector Layer" )
strokes = layer.strokes
for stroke in strokes:
bezierpath = stroke.bezier_path
print( " Bezier Path: %s"%(bezierpath.bezier_count) )
bounding_box = stroke.bounding_box
print( " Stroke Bounds: %s,%s (x,y) -- %s,%s (width,height)"%(bounding_box.x, bounding_box.y, bounding_box.width, bounding_box.height) )
if stroke.colour_left:
print( " Colour Left: %s"%(stroke.colour_left.colour_id) )
if stroke.colour_right:
print( " Colour Right: %s"%(stroke.colour_right.colour_id) )

Public Member Functions

OMC::DrawingVectorArtLayer * drawing () const
 Returns the OMC::DrawingVectorArtLayer* object that owns this stroke. More...
 
OMC::DrawingVectorLayer * layer () const
 Returns the OMC::DrawingVectorLayer* object that owns this stroke. More...
 
QList< OMC::DrawingVectorStroke * > strokes_shared () const
 Provides a list of all strokes that share the bezier path. More...
 
QList< OMC::DrawingVectorStroke * > strokes_shared_thickness () const
 Provides a list of all strokes that share the thickness binder. More...
 
bool continuous (OMC::DrawingVectorStroke *stroke)
 Identifies if a stroke is continuous with this stroke. More...
 
bool thickness_sharing (OMC::DrawingVectorStroke *stroke)
 Identifies if the stroke shares its thickness with another. More...
 

Public Attributes

OMC::BezierPath bezier_path
 
OMC::AllocatedRect2d * bounding_box
 The bounding-box of the stroke.
 
OMC::AllocatedRect2d * bounding_box_visible
 The bounding-box of the drawing's visible content.
 
OMC::AllocatedRect2d * bounding_box_inner
 The bounding-box of the drawing's inner content.
 
OMC::DrawingVectorColour * colour_left
 The color of the stroke on the left side. More...
 
OMC::DrawingVectorColour * colour_right
 The color of the stroke on the right side. More...
 
OMC::DrawingVectorContour * contour_left
 The contour of the stroke on the left side. More...
 
OMC::DrawingVectorContour * contour_right
 The contour of the stroke on the right side. More...
 
OMC::Point2d * tail
 The tail position of the stroke, as a OMC::Point2d object.
 
bool tail_cut
 True if the tail is cut.
 
OMC::Vector2d tail_tangent
 The tail tangent as a OMC::Vector2d.
 
double left_thickness_tangent_from
 The left thickness tangent on the "from" direction.
 
double left_thickness_tangent_to
 The left thickness tangent on the "to" direction.
 
OMC::Point2d * head
 The head position of the stroke, as a OMC::Point2d object.
 
QString tip_type_from
 The tip type of the 'from' portion of the stroke. More...
 
QString tip_type_to
 The tip type of the 'to' portion of the stroke. More...
 
OMC::Vector2d head_tangent
 The head tangent as a OMC::Vector2d.
 
double right_thickness_tangent_from
 The right thickness tangent on the "from" direction.
 
double right_thickness_tangent_to
 The right thickness tangent on the "to" direction.
 
int64_t unique_id
 The unique ID of the stroke.
 
OMC::DrawingVectorLineStyle * line_style
 
OMC::DrawingVectorThickness * thickness
 The OMC::DrawingVectorThickness* object that defines the thickness of the stroke. More...
 
double thickness_max_visible
 
bool degenerate
 True if the stroke is degenerate; all points lie on the same line.
 
bool thickness_valid
 True if the stroke has a valid thickness.
 

Member Function Documentation

◆ continuous()

bool OMC::DrawingVectorStroke::continuous ( OMC::DrawingVectorStroke *  stroke)

Identifies if a stroke is continuous with this stroke.

A stroke is continuous if the following is true: -this.tail == stroke.head -this.lineType == stroke.lineType -this.thicknessBinder.isContinuous(stroke.thicknessBinder)

Returns
True if the the provided stroke is continuous with this stroke.

◆ drawing()

OMC::DrawingVectorArtLayer* OMC::DrawingVectorStroke::drawing ( ) const

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

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

◆ layer()

OMC::DrawingVectorLayer* OMC::DrawingVectorStroke::layer ( ) const

Returns the OMC::DrawingVectorLayer* object that owns this stroke.

Returns
The OMC::DrawingVectorLayer* object that owns the stroke.

◆ strokes_shared()

QList<OMC::DrawingVectorStroke*> OMC::DrawingVectorStroke::strokes_shared ( ) const

Provides a list of all strokes that share the bezier path.

Returns
A list of all strokes that share the given bezier path.

◆ strokes_shared_thickness()

QList<OMC::DrawingVectorStroke*> OMC::DrawingVectorStroke::strokes_shared_thickness ( ) const

Provides a list of all strokes that share the thickness binder.

Returns
A list of all strokes that share the given thickness binder.

◆ thickness_sharing()

bool OMC::DrawingVectorStroke::thickness_sharing ( OMC::DrawingVectorStroke *  stroke)

Identifies if the stroke shares its thickness with another.

Identifies if the stroke shares the thickness with the provided stroke.

Returns
True if the provided stroke and this stroke share a thickness.

Member Data Documentation

◆ bezier_path

OMC::DrawingVectorStroke::bezier_path

Get the bezier path that defines the stroke. This path is a value object and changes to it must be reingested into the drawing.

Detail from a Stroke's Bezier Path

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"]
if line_art:
for layer in line_art:
if layer.type == "Vector":
print( "Vector Layer" )
strokes = layer.strokes
for stroke in strokes:
bezierpath = stroke.bezier_path
print( " Bezier Path: %s"%(bezierpath.bezier_count) )
#Iterate on each Bezier in the Bezier Path, print the results.
for n in range( bezierpath.bezier_count ):
print( "" )
bez = bezierpath.bezier( n )
if bez:
for n in range( bez.degree+1 ):
print( " %s, %s"%(bez[n].x, bez[n].y) )



Modify a Stroke's Bezier Path

import math
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"]
if line_art:
drawingAccess = harmony.DrawingAccess()
drawingAccess.vector_begin_operations( line_art )
for layer in line_art:
if layer.type == "Vector":
print( "Vector Layer" )
strokes = layer.strokes
for stroke in strokes:
bezierpath = stroke.bezier_path
#The bezier path is a copy of the path attached to the stroke.
#it will not change the stroke if modified, until its reassigned to that
#stroke.
for n,point in enumerate(bezierpath):
#Modulate the stroke based on its X position.
modulate = math.sin( (point.x/1875.0)*10 )*200
point.y = point.y + modulate
bezierpath[n] = point
stroke.bezier_path = bezierpath
drawingAccess.vector_end_operations()
Returns
A OMC::BezierPath object defining the bezier path used the stroke.

◆ colour_left

OMC::DrawingVectorStroke::colour_left

The color of the stroke on the left side.

Provides the color of the stroke on the given side as a DrawingVectorColor*.

Returns
Provides the OMC::DrawingVectorColour* of the stroke's side.

◆ colour_right

OMC::DrawingVectorStroke::colour_right

The color of the stroke on the right side.

Provides the color of the stroke on the given side as a DrawingVectorColor*.

Returns
Provides the OMC::DrawingVectorColour* of the stroke's side.

◆ contour_left

OMC::DrawingVectorStroke::contour_left

The contour of the stroke on the left side.

Provides the contour of the stroke on the given side as a DrawingVectorContour*.

Returns
Provides the OMC::DrawingVectorContour* of the stroke's side.

◆ contour_right

OMC::DrawingVectorStroke::contour_right

The contour of the stroke on the right side.

Provides the contour of the stroke on the given side as a DrawingVectorContour*.

Returns
Provides the OMC::DrawingVectorContour* of the stroke's side.

◆ line_style

OMC::DrawingVectorStroke::line_style

Provides the OMC::DrawingVectorLineStyle* object that defines the style of the stroke.

◆ thickness

OMC::DrawingVectorStroke::thickness

The OMC::DrawingVectorThickness* object that defines the thickness of the stroke.



Enlarge all lines

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:
drawingAccess = harmony.DrawingAccess()
proj.history.begin("Enlarging lines")
for art_layer in vector_drawing:
drawingAccess.vector_begin_operations( art_layer )
for layer in art_layer:
if layer.type == "Vector":
for stroke in layer.strokes:
if stroke.line_style.visible:
thickness = stroke.thickness
path = thickness.path
if path:
#Scaling the thickness path by 10.
path.transform( 10 )
stroke.thickness = path
drawingAccess.vector_end_operations()
proj.history.end()


Apply a a custom line weight

import math
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:
drawingAccess = harmony.DrawingAccess()
proj.history.begin("Modifying lines")
for art_layer in vector_drawing:
drawingAccess.vector_begin_operations( art_layer )
for layer in art_layer:
if layer.type == "Vector":
for stroke in layer.strokes:
if stroke.line_style.visible:
path = harmony.DrawingVectorThicknessPath()
for n in range( 100 ):
perc = float(n)/100.0
path.insert( harmony.DrawingVectorThicknessPathPoint( perc, abs( math.sin(perc*3.14*50.0)*10 )+10 ) )
stroke.thickness = path
drawingAccess.vector_end_operations()
proj.history.end()

◆ thickness_max_visible

double OMC::DrawingVectorStroke::thickness_max_visible
read

Provides the max thickness of the stroke.

◆ tip_type_from

QString OMC::DrawingVectorStroke::tip_type_from
read

The tip type of the 'from' portion of the stroke.

Valid types are as follows:

  • Round
  • Flat
  • Bevel
  • Undefined

◆ tip_type_to

QString OMC::DrawingVectorStroke::tip_type_to
read

The tip type of the 'to' portion of the stroke.

Valid types are as follows:

  • Round
  • Flat
  • Bevel
  • Undefined
Inheritance diagram for OMC::DrawingVectorStroke:
Collaboration diagram for OMC::DrawingVectorStroke: