示例#1
0
	def shade(self, stroke):
		originalSize = stroke.stroke_vertices_size()
		if originalSize < 4:
			return
		it = stroke.stroke_vertices_begin()
		invisible = 0
		it2 = StrokeVertexIterator(it)
		it2.increment()
		fe = self.get_fedge(it.object, it2.object)
		if fe.viewedge.qi != 0:
			invisible = 1
		while not it2.is_end:
			v = it.object
			vnext = it2.object
			if (v.nature & Nature.VIEW_VERTEX) != 0:
				#if (v.nature & Nature.T_VERTEX) != 0:
				fe = self.get_fedge(v, vnext)
				qi = fe.viewedge.qi
				if qi != 0:
					invisible = 1
				else:
					invisible = 0
			if invisible:
				v.attribute.visible = False
			it.increment()
			it2.increment()
示例#2
0
 def shade(self, stroke):
     it0 = stroke.stroke_vertices_begin()
     it1 = StrokeVertexIterator(it0)
     it1.increment()
     itn = stroke.stroke_vertices_end()
     itn.decrement()
     itn_1 = StrokeVertexIterator(itn)
     itn_1.decrement()
     v0 = it0.object
     v1 = it1.object
     if (v0.nature & Nature.CUSP) == 0 and (v1.nature & Nature.CUSP) == 0:
         p0 = v0.point
         p1 = v1.point
         d1 = p0 - p1
         d1.normalize()
         newFirst = p0 + d1 * float(self._l)
         v0.point = newFirst
     vn_1 = itn_1.object
     vn = itn.object
     if (vn.nature & Nature.CUSP) == 0 and (vn_1.nature & Nature.CUSP) == 0:
         pn = vn.point
         pn_1 = vn_1.point
         dn = pn - pn_1
         dn.normalize()
         newLast = pn + dn * float(self._l)
         vn.point = newLast
     stroke.update_length()
示例#3
0
 def shade(self, stroke):
     l = stroke.length_2d
     stretch = self._l * l
     it0 = stroke.stroke_vertices_begin()
     it1 = StrokeVertexIterator(it0)
     it1.increment()
     itn = stroke.stroke_vertices_end()
     itn.decrement()
     itn_1 = StrokeVertexIterator(itn)
     itn_1.decrement()
     v0 = it0.object
     v1 = it1.object
     vn_1 = itn_1.object
     vn = itn.object
     p0 = mathutils.Vector([v0.projected_x, v0.projected_y])
     pn = mathutils.Vector([vn.projected_x, vn.projected_y])
     p1 = mathutils.Vector([v1.projected_x, v1.projected_y])
     pn_1 = mathutils.Vector([vn_1.projected_x, vn_1.projected_y])
     d1 = p0 - p1
     d1.normalize()
     dn = pn - pn_1
     dn.normalize()
     newFirst = p0 + d1 * float(stretch)
     newLast = pn + dn * float(stretch)
     v0.point = newFirst
     vn.point = newLast
     stroke.update_length()
示例#4
0
 def shade(self, stroke):
     originalSize = stroke.stroke_vertices_size()
     if originalSize < 4:
         return
     it = stroke.stroke_vertices_begin()
     invisible = 0
     it2 = StrokeVertexIterator(it)
     it2.increment()
     fe = self.get_fedge(it.object, it2.object)
     if fe.viewedge.qi != 0:
         invisible = 1
     while not it2.is_end:
         v = it.object
         vnext = it2.object
         if (v.nature & Nature.VIEW_VERTEX) != 0:
             #if (v.nature & Nature.T_VERTEX) != 0:
             fe = self.get_fedge(v, vnext)
             qi = fe.viewedge.qi
             if qi != 0:
                 invisible = 1
             else:
                 invisible = 0
         if invisible:
             v.attribute.visible = False
         it.increment()
         it2.increment()
示例#5
0
	def shade(self, stroke):
		it0 = stroke.stroke_vertices_begin()
		it1 = StrokeVertexIterator(it0)
		it1.increment()
		itn = stroke.stroke_vertices_end()
		itn.decrement()
		itn_1 = StrokeVertexIterator(itn)
		itn_1.decrement()
		v0 = it0.object
		v1 = it1.object
		if (v0.nature & Nature.CUSP) == 0 and (v1.nature & Nature.CUSP) == 0:
			p0 = v0.point
			p1 = v1.point
			d1 = p0-p1
			d1.normalize()
			newFirst = p0+d1*float(self._l)
			v0.point = newFirst
		vn_1 = itn_1.object
		vn = itn.object
		if (vn.nature & Nature.CUSP) == 0 and (vn_1.nature & Nature.CUSP) == 0:
			pn = vn.point
			pn_1 = vn_1.point
			dn = pn-pn_1
			dn.normalize()
			newLast = pn+dn*float(self._l)	
			vn.point = newLast
		stroke.update_length()
示例#6
0
	def shade(self, stroke):
		l = stroke.length_2d
		stretch = self._l*l 
		it0 = stroke.stroke_vertices_begin()
		it1 = StrokeVertexIterator(it0)
		it1.increment()
		itn = stroke.stroke_vertices_end()
		itn.decrement()
		itn_1 = StrokeVertexIterator(itn)
		itn_1.decrement()
		v0 = it0.object
		v1 = it1.object
		vn_1 = itn_1.object
		vn = itn.object
		p0 = mathutils.Vector([v0.projected_x, v0.projected_y])
		pn = mathutils.Vector([vn.projected_x, vn.projected_y])
		p1 = mathutils.Vector([v1.projected_x, v1.projected_y])
		pn_1 = mathutils.Vector([vn_1.projected_x, vn_1.projected_y])
		d1 = p0-p1
		d1.normalize()
		dn = pn-pn_1
		dn.normalize()
		newFirst = p0+d1*float(stretch)
		newLast = pn+dn*float(stretch)
		v0.point = newFirst
		vn.point = newLast
		stroke.update_length()
示例#7
0
 def shade(self, stroke):
     it = stroke.stroke_vertices_begin()
     it2 = StrokeVertexIterator(it)
     it2.increment()
     ## case where the first vertex is a TVertex
     v = it.object
     if (v.nature & Nature.T_VERTEX) != 0:
         tv = self.castToTVertex(v)
         if tv is not None:
             ve = self.get_fedge(v, it2.object).viewedge
             dir = self.findOrientation(tv, ve)
             if dir is not None:
                 #print(dir.x, dir.y)
                 v.attribute.set_attribute_vec2("orientation", dir)
     while not it2.is_end:
         vprevious = it.object
         v = it2.object
         if (v.nature & Nature.T_VERTEX) != 0:
             tv = self.castToTVertex(v)
             if tv is not None:
                 ve = self.get_fedge(vprevious, v).viewedge
                 dir = self.findOrientation(tv, ve)
                 if dir is not None:
                     #print(dir.x, dir.y)
                     v.attribute.set_attribute_vec2("orientation", dir)
         it.increment()
         it2.increment()
     ## case where the last vertex is a TVertex
     v = it.object
     if (v.nature & Nature.T_VERTEX) != 0:
         itPrevious = StrokeVertexIterator(it)
         itPrevious.decrement()
         tv = self.castToTVertex(v)
         if tv is not None:
             ve = self.get_fedge(itPrevious.object, v).viewedge
             dir = self.findOrientation(tv, ve)
             if dir is not None:
                 #print(dir.x, dir.y)
                 v.attribute.set_attribute_vec2("orientation", dir)
示例#8
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()
示例#9
0
	def shade(self, stroke):
		it = stroke.stroke_vertices_begin()
		it2 = StrokeVertexIterator(it)
		it2.increment()
		## case where the first vertex is a TVertex
		v = it.object
		if (v.nature & Nature.T_VERTEX) != 0:
			tv = self.castToTVertex(v)
			if tv is not None:
				ve = self.get_fedge(v, it2.object).viewedge
				dir = self.findOrientation(tv, ve)
				if dir is not None:
					#print(dir.x, dir.y)
					v.attribute.set_attribute_vec2("orientation", dir)
		while not it2.is_end:
			vprevious = it.object
			v = it2.object
			if (v.nature & Nature.T_VERTEX) != 0:
				tv = self.castToTVertex(v)
				if tv is not None:
					ve = self.get_fedge(vprevious, v).viewedge
					dir = self.findOrientation(tv, ve)
					if dir is not None:
						#print(dir.x, dir.y)
						v.attribute.set_attribute_vec2("orientation", dir)
			it.increment()
			it2.increment()
		## case where the last vertex is a TVertex
		v = it.object 
		if (v.nature & Nature.T_VERTEX) != 0:
			itPrevious = StrokeVertexIterator(it)
			itPrevious.decrement()
			tv = self.castToTVertex(v)
			if tv is not None:
				ve = self.get_fedge(itPrevious.object, v).viewedge
				dir = self.findOrientation(tv, ve)
				if dir is not None:
					#print(dir.x, dir.y)
					v.attribute.set_attribute_vec2("orientation", dir)
示例#10
0
 def shade(self, stroke):
     it = stroke.stroke_vertices_begin()  ## get the first vertex
     itlast = stroke.stroke_vertices_end()  ##
     itlast.decrement()  ## get the last one
     t = itlast.object.point - it.object.point  ## tangent direction
     itmiddle = StrokeVertexIterator(it)  ##
     while itmiddle.object.u < 0.5:  ## look for the stroke middle vertex
         itmiddle.increment()  ##
     it = StrokeVertexIterator(itmiddle)
     it.increment()
     while not it.is_end:  ## position all the vertices along the tangent for the right part
         it.object.point = itmiddle.object.point \
             +t*(it.object.u-itmiddle.object.u)
         it.increment()
     it = StrokeVertexIterator(itmiddle)
     it.decrement()
     while not it.is_begin:  ## position all the vertices along the tangent for the left part
         it.object.point = itmiddle.object.point \
             -t*(itmiddle.object.u-it.object.u)
         it.decrement()
     it.object.point = itmiddle.object.point - t * itmiddle.object.u  ## first vertex
     stroke.update_length()
示例#11
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()
示例#12
0
	def shade(self, stroke):
		it = stroke.stroke_vertices_begin() 	## get the first vertex
		itlast = stroke.stroke_vertices_end() 	## 
		itlast.decrement()			## get the last one
		t = itlast.object.point - it.object.point	## tangent direction
		itmiddle = StrokeVertexIterator(it)	## 
		while itmiddle.object.u < 0.5:	## look for the stroke middle vertex
			itmiddle.increment()		##
		it = StrokeVertexIterator(itmiddle)	
		it.increment()
		while not it.is_end:			## position all the vertices along the tangent for the right part
			it.object.point = itmiddle.object.point \
			    +t*(it.object.u-itmiddle.object.u)
			it.increment()
		it = StrokeVertexIterator(itmiddle)
		it.decrement()
		while not it.is_begin:			## position all the vertices along the tangent for the left part
			it.object.point = itmiddle.object.point \
			    -t*(itmiddle.object.u-it.object.u)
			it.decrement()
		it.object.point = itmiddle.object.point-t*itmiddle.object.u ## first vertex
		stroke.update_length()