def read_gimp_path(context, filename=''):
    if not filename:
        filename = context.application.GetOpenFilename()
        if not filename:
            return
    paths = read_path(filename)
    object = PolyBezier(paths)
    object.Transform(Trafo(1, 0, 0, -1, 0, 800))
    #context.main_window.PlaceObject(object)
    context.document.Insert(object)
	def import_curves(self):
		objcount=0
		objnum=len(self.info.paths_heap)
		jump=87.0/objnum
		interval=int((objnum/20)/10)+1
		interval_count=0
		for obj in self.info.paths_heap:
			objcount+=1
			interval_count+=1
			if interval_count>interval:
				interval_count=0
				app.updateInfo(inf2=_("Interpreting object %u of %u")%(objcount,objnum),inf3=10+int(jump*objcount))
			if obj==1:
				self.begin_group()
			elif obj==0:
				self.end_group()
			elif type(obj)==TupleType and obj[0]=='BMP':
				self.image(obj[1],obj[2])
			elif obj.is_Rectangle:
				self.set_style(obj)
				[m11,m21,m12,m22,v1,v2]=obj.trafo
				if len(obj.radiuses):
					self.rectangle(m11, m21, m12, m22, v1, v2, obj.radiuses[0], obj.radiuses[1])
				else:
					self.rectangle(m11, m21, m12, m22, v1, v2)
			elif obj.is_Ellipse:
				ellipse_type=app.conf.const.ArcPieSlice
				if obj.ellipse_type:
					ellipse_type=app.conf.const.ArcArc
					obj.colorIndex=False
				self.set_style(obj)
				[m11,m21,m12,m22,v1,v2]=obj.trafo
				self.ellipse(m11, m21, m12, m22, v1, v2, obj.angles[0], obj.angles[1],ellipse_type)
					
			else:
				self.set_style(obj)
						
				object = PolyBezier(paths = tuple(obj.paths), properties = self.get_prop_stack())
				self.append_object(object)
				
				if obj.outlineIndex:
					if self.info.outl_data[obj.outlineIndex].spec & 0x10:
						copy = object.Duplicate()
						copy.properties.SetProperty(line_width=0)
						self.append_object(copy)
				else:
					if self.info.default_outl_data.spec & 0x10:
						copy = object.Duplicate()
						copy.properties.SetProperty(line_width=0)
						self.append_object(copy)
Example #3
0
def create_star_outline(context):
    args = CreateStarDlg(context.application.root).RunDialog()
    if args is None:
        return
    path = apply(create_star_path, args)
    bezier = PolyBezier((path, ))
    context.main_window.PlaceObject(bezier)
def create_star(context):
	# Instantiate the modal dialog...
	dlg = CreateStarDlg(context.application.root)
	# ... and run it.
	result = dlg.RunDialog()
	if result is not None:
		# if the result is not None, the user pressed OK. Now constuct
		# the star-path...
		corners, steps, radius = result
		path = create_star_path(corners, steps, radius)
	
		# ... and create the bezier object. The parameter to the
		# constructor must be a tuple of paths
		bezier = PolyBezier((path,))

		# Set the line color to blue, the line width to 4pt
		bezier.SetProperties(line_pattern = SolidPattern(StandardColors.blue),
								line_width = 4)

		# and insert it into the document
		context.main_window.PlaceObject(bezier)
Example #5
0
 def makePageFrame(self):
     doc = self.doc
     layout = doc.Layout()
     hor_p = layout.Width()
     ver_p = layout.Height()
     path = CreatePath()
     path.AppendLine(Point(0, 0))
     path.AppendLine(Point(hor_p, 0))
     path.AppendLine(Point(hor_p, ver_p))
     path.AppendLine(Point(0, ver_p))
     path.AppendLine(Point(0, 0))
     path.AppendLine(path.Node(0))
     path.ClosePath()
     bezier = PolyBezier((path, ))
     doc.Insert(bezier)
 def bezier(self, paths=None):
     self.append_object(
         PolyBezier(paths=paths, properties=self.get_prop_stack()))
Example #7
0
	def import_curves(self):
		objcount=0
		objnum=len(self.info.paths_heap)
		jump=87.0/objnum
		interval=int((objnum/20)/10)+1
		interval_count=0
		for obj in self.info.paths_heap:
			objcount+=1
			interval_count+=1
			if interval_count>interval:
				interval_count=0
				app.updateInfo(inf2=_("Interpreting object %u of %u")%(objcount,objnum),inf3=10+int(jump*objcount))
			if obj==1:
				self.begin_group()
			elif obj==0:
				self.end_group()
			elif type(obj)==TupleType and obj[0]=='BMP':
				self.image(obj[1],obj[2])
			else:
				style = self.style
				if obj.colorIndex:
					if self.info.fill_data.has_key(obj.colorIndex):
						style.fill_pattern = SolidPattern(self.info.fill_data[obj.colorIndex])
					else:
						style.fill_pattern = EmptyPattern
				else:
					style.fill_pattern = EmptyPattern
					
				if obj.outlineIndex:
					if self.info.outl_data.has_key(obj.outlineIndex):
						if self.info.outl_data[obj.outlineIndex].spec & 0x01:
							style.line_pattern = EmptyPattern
						else:
							style.line_pattern = SolidPattern(self.info.outl_data[obj.outlineIndex].color)
						
						if self.info.outl_data[obj.outlineIndex].spec & 0x04:
							style.line_dashes = self.info.outl_data[obj.outlineIndex].dashes
						
						if self.info.outl_data[obj.outlineIndex].spec & 0x20:
							style.line_width = self.info.outl_data[obj.outlineIndex].width*obj.scale
						else:
							style.line_width = self.info.outl_data[obj.outlineIndex].width
							
						style.line_cap = self.info.outl_data[obj.outlineIndex].caps + 1
						style.line_join = self.info.outl_data[obj.outlineIndex].corner
					else:
						style.line_pattern = EmptyPattern
				else:
					if self.info.default_outl_data:
						if self.info.default_outl_data.spec & 0x01:
							style.line_pattern = EmptyPattern
						else:
							style.line_pattern = SolidPattern(self.info.default_outl_data.color)
							
						if self.info.default_outl_data.spec & 0x04:
							style.line_dashes = self.info.default_outl_data.dashes

						if self.info.default_outl_data.spec & 0x20:
							style.line_width = self.info.default_outl_data.width*obj.scale
						else:
							style.line_width = self.info.default_outl_data.width
						style.line_cap = self.info.default_outl_data.caps + 1
						style.line_join = self.info.default_outl_data.corner
					else:
						style.line_pattern = EmptyPattern
						
				object = PolyBezier(paths = tuple(obj.paths), properties = self.get_prop_stack())
				self.append_object(object)
				
				if obj.outlineIndex:
					if self.info.outl_data[obj.outlineIndex].spec & 0x10:
						copy = object.Duplicate()
						copy.properties.SetProperty(line_width=0)
						self.append_object(copy)
				else:
					if self.info.default_outl_data.spec & 0x10:
						copy = object.Duplicate()
						copy.properties.SetProperty(line_width=0)
						self.append_object(copy)