Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

#  Filename : sequentialsplit_sketchy.py
#  Author   : Stephane Grabli
#  Date     : 04/08/2005
#  Purpose  : Use the sequential split with two different
#             predicates to specify respectively the starting and
#             the stopping extremities for strokes

from freestyle import ChainSilhouetteIterator, ConstantColorShader, IncreasingThicknessShader, Nature, \
    Operators, QuantitativeInvisibilityUP1D, SpatialNoiseShader, TextureAssignerShader, TrueUP1D
from PredicatesU0D import pyBackTVertexUP0D, pyVertexNatureUP0D
from logical_operators import NotUP1D

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),
    TextureAssignerShader(4),
]
Operators.create(TrueUP1D(), shaders_list)
Ejemplo n.º 6
0
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

#  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 import ChainSilhouetteIterator, ConstantThicknessShader, IncreasingColorShader, \
    Nature, Operators, QuantitativeInvisibilityUP1D, TextureAssignerShader, TrueUP1D
from PredicatesU0D import pyVertexNatureUP0D
from logical_operators import NotUP1D

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),
    TextureAssignerShader(3),
    ]
Operators.create(TrueUP1D(), shaders_list)