Example #1
0
 def shade(self, stroke):
     if stroke.stroke_vertices_size() <= 3:
         return
     predTVertex = pyVertexNatureUP0D(Nature.T_VERTEX)
     it = stroke.stroke_vertices_begin()
     itlast = stroke.stroke_vertices_end()
     itlast.decrement()
     if predTVertex(it):
         stroke.remove_vertex(it.object)
     if predTVertex(itlast):
         stroke.remove_vertex(itlast.object)
     stroke.update_length()
Example #2
0
 def shade(self, stroke):
     if stroke.stroke_vertices_size() <= 3:
         return
     predTVertex = pyVertexNatureUP0D(Nature.T_VERTEX)
     it = stroke.stroke_vertices_begin()
     itlast = stroke.stroke_vertices_end()
     itlast.decrement()
     if predTVertex(it):
         stroke.remove_vertex(it.object)
     if predTVertex(itlast):
         stroke.remove_vertex(itlast.object)
     stroke.update_length()
Example #3
0
 def shade(self, stroke):
     it = stroke.stroke_vertices_begin()
     predTVertex = pyVertexNatureUP0D(Nature.T_VERTEX)
     while not it.is_end:
         if predTVertex(it) == 1:
             it2 = StrokeVertexIterator(it)
             it2.increment()
             if not (it.is_begin or it2.is_end):
                 it.increment()
                 continue
             n = self._n
             a = self._a
             if it.is_begin:
                 it3 = StrokeVertexIterator(it)
                 count = 0
                 while (not it3.is_end) and count < n:
                     att = it3.object.attribute
                     (tr, tl) = att.thickness
                     r = (a - 1.0) / float(n - 1) * (
                         float(n) / float(count + 1) - 1) + 1
                     #r = (1.0-a)/float(n-1)*count + a
                     att.thickness = (r * tr, r * tl)
                     it3.increment()
                     count = count + 1
             if it2.is_end:
                 it4 = StrokeVertexIterator(it)
                 count = 0
                 while (not it4.is_begin) and count < n:
                     att = it4.object.attribute
                     (tr, tl) = att.thickness
                     r = (a - 1.0) / float(n - 1) * (
                         float(n) / float(count + 1) - 1) + 1
                     #r = (1.0-a)/float(n-1)*count + a
                     att.thickness = (r * tr, r * tl)
                     it4.decrement()
                     count = count + 1
                 if it4.is_begin:
                     att = it4.object.attribute
                     (tr, tl) = att.thickness
                     r = (a - 1.0) / float(n - 1) * (
                         float(n) / float(count + 1) - 1) + 1
                     #r = (1.0-a)/float(n-1)*count + a
                     att.thickness = (r * tr, r * tl)
         it.increment()
Example #4
0
 def shade(self, stroke):
     it = stroke.stroke_vertices_begin()
     predTVertex = pyVertexNatureUP0D(Nature.T_VERTEX)
     while not it.is_end:
         if predTVertex(it) == 1:
             it2 = StrokeVertexIterator(it)
             it2.increment()
             if not (it.is_begin or it2.is_end):
                 it.increment()
                 continue
             n = self._n
             a = self._a
             if it.is_begin:
                 it3 = StrokeVertexIterator(it)
                 count = 0
                 while (not it3.is_end) and count < n:
                     att = it3.object.attribute
                     (tr, tl) = att.thickness
                     r = (a-1.0)/float(n-1)*(float(n)/float(count+1) - 1) + 1
                     #r = (1.0-a)/float(n-1)*count + a
                     att.thickness = (r*tr, r*tl)
                     it3.increment()
                     count = count + 1
             if it2.is_end:
                 it4 = StrokeVertexIterator(it)
                 count = 0
                 while (not it4.is_begin) and count < n:
                     att = it4.object.attribute
                     (tr, tl) = att.thickness
                     r = (a-1.0)/float(n-1)*(float(n)/float(count+1) - 1) + 1
                     #r = (1.0-a)/float(n-1)*count + a
                     att.thickness = (r*tr, r*tl)
                     it4.decrement()
                     count = count + 1
                 if it4.is_begin:
                     att = it4.object.attribute
                     (tr, tl) = att.thickness
                     r = (a-1.0)/float(n-1)*(float(n)/float(count+1) - 1) + 1
                     #r = (1.0-a)/float(n-1)*count + a
                     att.thickness = (r*tr, r*tl)
         it.increment()
#             the stopping extremities for strokes

from freestyle.chainingiterators import ChainSilhouetteIterator
from freestyle.predicates import (
    NotUP1D,
    QuantitativeInvisibilityUP1D,
    TrueUP1D,
    pyBackTVertexUP0D,
    pyVertexNatureUP0D,
)
from freestyle.shaders import (
    ConstantColorShader,
    IncreasingThicknessShader,
    SpatialNoiseShader,
)
from freestyle.types import Nature, Operators

upred = QuantitativeInvisibilityUP1D(0)
Operators.select(upred)
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(upred))
# starting and stopping predicates:
start = pyVertexNatureUP0D(Nature.NON_T_VERTEX)
stop = pyBackTVertexUP0D()
Operators.sequential_split(start, stop, 10)
shaders_list = [
    SpatialNoiseShader(7, 120, 2, True, True),
    IncreasingThicknessShader(5, 8),
    ConstantColorShader(0.2, 0.2, 0.2, 1),
]
Operators.create(TrueUP1D(), shaders_list)
Example #6
0
#  Filename : split_at_tvertices.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Draws strokes that starts and stops at Tvertices (visible or not)

from freestyle.chainingiterators import ChainSilhouetteIterator
from freestyle.predicates import (
    NotUP1D,
    QuantitativeInvisibilityUP1D,
    TrueUP1D,
    pyVertexNatureUP0D,
    )
from freestyle.shaders import (
    ConstantThicknessShader,
    IncreasingColorShader,
    )
from freestyle.types import Nature, Operators


Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectional_chain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0)))
start = pyVertexNatureUP0D(Nature.T_VERTEX)
## use the same predicate to decide where to start and where to stop
## the strokes:
Operators.sequential_split(start, start, 10)
shaders_list = [
    ConstantThicknessShader(5),
    IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1),
    ]
Operators.create(TrueUP1D(), shaders_list)