Пример #1
0
 def rectangle(self, m11, m21, m12, m22, v1, v2, radius1=0, radius2=0):
     trafo = Trafo(m11, m21, m12, m22, v1, v2)
     self.append_object(
         Rectangle(trafo,
                   radius1=radius1,
                   radius2=radius2,
                   properties=self.get_prop_stack()))
Пример #2
0
 def im(self, trafo, obj_id):
     if len(trafo) == 2: trafo = (1.0, 0.0, 0.0, 1.0) + trafo
     trafo = Trafo(*trafo)
     image = None
     if self.presenter.resources.has_key(obj_id):
         image = self.presenter.resources[obj_id]
     self.add_object(SK1Image(trafo, obj_id, image))
Пример #3
0
 def ellipse(self,
             m11,
             m21,
             m12,
             m22,
             v1,
             v2,
             start_angle=0.0,
             end_angle=0.0,
             arc_type=sk1const.ArcPieSlice):
     trafo = Trafo(m11, m21, m12, m22, v1, v2)
     properties = self.get_prop_stack()
     obj = Ellipse(trafo, start_angle, end_angle, arc_type, properties)
     self.append_object(obj)
Пример #4
0
 def e(self,
       m11,
       m12,
       m21,
       m22,
       dx,
       dy,
       start_angle=0.0,
       end_angle=0.0,
       arc_type=sk1_const.ArcPieSlice):
     trafo = Trafo(m11, m12, m21, m22, dx, dy)
     obj = Ellipse(trafo, start_angle, end_angle, arc_type)
     self.set_style(obj)
     self.add_object(obj)
Пример #5
0
	def read_headers(self):
		self.file.seek(0)
		placeable = self.file.read(calcsize(struct_placeable_header))
		key, handle, left, top, right, bottom, inch, reserved, checksum\
				 = unpack(struct_placeable_header, placeable)
		if key != WMF_SIGNATURE:
#			raise SketchLoadError(_("The file is not a placeable "
#									"windows metafile"))
			self._print("The file is not a placeable windows metafile")
		sum = 0
		for word in unpack('<10h', placeable[:20]):
			sum = sum ^ word
		if sum != checksum:
			#raise SketchLoadError(_("The file has an incorrect checksum"))
			self._print("The file has an incorrect checksum")

		self.inch = inch
		self.bbox = (left, top, right, bottom)
		factor = 72.0 / self.inch
		self.wx = self.wy = 0
		self.wwidth = right - left
		self.wheight = bottom - top
		self.vx = self.vy = 0
		self.vwidth = self.wwidth
		self.vheight = self.wheight
		self.base_trafo = Trafo(factor, 0, 0, -factor,
								0, factor * self.vheight)
		self.update_trafo()

		header = self.file.read(calcsize(struct_wmf_header))
		filetype, headersize, version, filesize, numobj, maxrecord, numparams\
					 = unpack(struct_wmf_header, header)

		self._print('\nHeader\n------\n')
		fmt = '% 10s: %s\n'
		self._print(fmt, 'inch', self.inch)
		self._print(fmt, 'bbox', self.bbox)
		self._print(fmt, 'headersize', headersize)
		self._print(fmt, 'version', version)
		self._print(fmt, 'numobj', numobj)
		self._print(fmt, 'numparams', numparams)
		self._print(fmt, 'maxrecord', maxrecord)
		self._print('\n')
Пример #6
0
	def Arc(self, arc_type=ArcArc):
		ye, xe, ys, xs, bottom, right, top, left = self.get_struct('<hhhhhhhh')
		left, top = self.trafo(left, top)
		right, bottom = self.trafo(right, bottom)
		xs, ys = self.trafo(xs, ys)
		xe, ye = self.trafo(xe, ye)
#		self.prop_stack.AddStyle(self.curstyle.copy())
		self.set_style(self.curstyle.copy())
		if arc_type == ArcArc:
#			self.prop_stack.SetProperty(fill_pattern=EmptyPattern)
			self.style.fill_pattern = EmptyPattern
		if left != right and top != bottom:
			t = Trafo((right - left) / 2, 0, 0, (bottom - top) / 2,
						(right + left) / 2, (top + bottom) / 2).inverse()
			# swap start and end-angle
			end_angle = t(xs, ys).polar()[1]
			start_angle = t(xe, ye).polar()[1]
		else:
			start_angle = end_angle = 0.0
		self.ellipse((right - left) / 2, 0, 0, (bottom - top) / 2,
						(right + left) / 2, (top + bottom) / 2,
						start_angle=start_angle, end_angle=end_angle,
						arc_type=arc_type)
Пример #7
0
 def rectangle(self, m11, m21, m12, m22, v1, v2, radius1=0, radius2=0):
     trafo = Trafo(m11, m21, m12, m22, v1, v2)
     properties = self.get_style()
     obj = Rectangle(trafo, radius1, radius2, properties)
     self.append_object(obj)
Пример #8
0
 def r(self, m11, m12, m21, m22, dx, dy, radius1=0, radius2=0):
     trafo = Trafo(m11, m12, m21, m22, dx, dy)
     obj = Rectangle(trafo, radius1, radius2)
     self.set_style(obj)
     self.add_object(obj)
Пример #9
0
 def pit(self, obj_id, trafo):
     trafo = Trafo(*trafo)
     if obj_id in self.presenter.resources:
         image = self.presenter.resources[obj_id]
         self.pattern = ImageTilePattern(image, trafo)
Пример #10
0
	def im(self, trafo, id):
		trafo = Trafo(*trafo)
		image = None
		if self.presenter.resources.has_key(id):
			image = self.presenter.resources[id]
		self.add_object(SK1Image(trafo, id, image))
Пример #11
0
	def pit(self, id, trafo):
		trafo = Trafo(*trafo)
		if self.presenter.resources.has_key(id):
			image = self.presenter.resources[id]
			self.pattern = ImageTilePattern(image, trafo)