Пример #1
0
	def to_str (self):
		""" action: transforme le text en texte
		argument: le text
		retourne: une chaine contenant les caracteristiques de l'objet
		"""
#		creer la chaine contenant les caracteristiques
		chn = "<text x='%s' y='%s'>%s</text>"
#		ecrire les caracteristiques de la forme
		chn = chn %(
			txt.float_to_str (self.px),
			txt.float_to_str (self.py),
			txt.float_to_str (self.text) )
#		id, classe
		chn= obj.to_str (self, chn)
		return chn
Пример #2
0
    def to_str(self):
        """ action: ecrire un pattern
		retourne: un texte correspondant au pattern
		"""
        #		ecrire les formes
        list_shapes = dsvg.group.to_str(self)
        #		modification propres aux pattern
        list_shapes = '<defs>' + list_shapes + '</defs>'
        chn = " width='%s' height='%s' x='%s' y='%s' patternUnits='userSpaceOnUse'" % (
            txt.float_to_str(self.width), txt.float_to_str(self.height),
            txt.float_to_str(self.px), txt.float_to_str(self.py))
        #		placer list shapes apres les eventuels id et class
        d = list_shapes.find('pattern')
        d = list_shapes.find('>', d)
        list_shapes = list_shapes[:d] + chn + list_shapes[d:]
        return list_shapes
Пример #3
0
	def to_str (self):
		""" action: transforme le rect en texte
		argument: le rect
		retourne: une chaine contenant les caracteristiques de l'objet
		"""
#		creer la chaine contenant les caracteristiques des rectangles
		chn = "<rect x='%s' y='%s' width='%s' height='%s'/>"
#		ajouter les caracteristiques dans la chaine
		chn = chn %(
			txt.float_to_str (self.px),
			txt.float_to_str (self.py),
			txt.float_to_str (self.width),
			txt.float_to_str (self.height) )
#		id, classe
		chn= obj.to_str (self, chn)
		return chn
Пример #4
0
	def to_str (self):
		""" action: transforme le poly en texte
		argument: le poly
		retourne: une chaine contenant les caracteristiques de l'objet
		"""
#		modifier les coordonnees des points pour qu'ils sortent de l'intervalle 0-1
		self.denormalisation()
#		transformer les float en str
		list_points =[]
		range_points = range (len (self.ptx))
		for i in range_points:
			ptx = txt.float_to_str (self.ptx[i])
			pty = txt.float_to_str (self.pty[i])
			list_points.append (ptx +','+ pty)
		str_points =' '.join (list_points)
		str_points = '<'+ self.nature +" points='" + str_points +"'/>"
#		id, classe
		str_points = obj.to_str (self, str_points)
		return str_points
Пример #5
0
	def to_str (self):
		""" action: transforme la ligne en texte
		argument: la ligne
		retourne: une chaine contenant les caracteristiques de l'objet
		"""
#		modifier width et height pour qu'ils correspondent a des coordonnees
		x2= self.width + self.px
		y2= self.height + self.py
#		creer la chaine contenant les caracteristiques
		chn = "<line x1='%s' y1='%s' x2='%s' y2='%s'/>"
#		ajouter les caracteristiques dans la chaine
		chn = chn %(
			txt.float_to_str (self.px),
			txt.float_to_str (self.py),
			txt.float_to_str (x2),
			txt.float_to_str (y2) )
#		id, classe
		chn= obj.to_str (self, chn)
		return chn
Пример #6
0
	def to_str (self):
		""" action: transforme le circle en texte
		argument: le circle
		retourne: une chaine contenant les caracteristiques de l'objet
		"""
#		width correspond au diametre, je veux le rayon
		rayon = self.width /2
#		retrouver la position du centre
		posx = self.px + rayon
		posy = self.py + rayon
#		creer la chaine contenant les caracteristiques
		chn = "<circle cx='%s' cy='%s' r='%s'/>"
#		ecrire les caracteristiques de la forme
		chn = chn %(
			txt.float_to_str (posx),
			txt.float_to_str (posy),
			txt.float_to_str (rayon) )
#		id, classe
		chn= obj.to_str (self, chn)
		return chn
Пример #7
0
	def to_file (self):
		""" action: ecrire le contenu d'un svg dans son fichier """
#		creer le contenu svg, <svg>...</svg>
		self.px =0
		self.py =0
		text_svg = self.to_str()
#		rajouter des infos dans la balise <svg>
		text_svg = text_svg[:4] + """ width='%s' height='%s'
	xmlns:xlink='http://www.w3.org/1999/xlink'
	xmlns='http://www.w3.org/2000/svg'>
""" %( txt.float_to_str (self.width), txt.float_to_str (self.height) )+ text_svg[5:]
#		feuille de style interne
		if self.style:
			self.style = self.style.strip()
			style = '<style><![CDATA[\n' + self.style + '\n]]></style>\n'
			d= text_svg.find ('>\n') +2
			text_svg = text_svg[:d] + style + text_svg[d:]
#		feuille de style externe
		if self.style_externe: text_svg = "<?xml-stylesheet type='text/css' href='%s.css' ?>\n" % self.style_externe + text_svg
		text_svg = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" + text_svg
#		ecrire
		txt.ecrire (self.file, text_svg, 'w')