kopia lustrzana https://github.com/inkstitch/inkstitch
				
				
				
			add note and template to avoid self-foot-shooting
							rodzic
							
								
									47eb81cb0e
								
							
						
					
					
						commit
						e9871d8bc7
					
				| 
						 | 
				
			
			@ -12,6 +12,10 @@ class Stitch(Point):
 | 
			
		|||
 | 
			
		||||
    def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False,
 | 
			
		||||
                 tie_modus=0, force_lock_stitches=False, no_ties=False, tags=None):
 | 
			
		||||
        # DANGER: if you add new attributes, you MUST also set their default
 | 
			
		||||
        # values in __new__() below.  Otherwise, cached stitch plans can be
 | 
			
		||||
        # loaded and create objects without those properties defined, because
 | 
			
		||||
        # unpickling does not call __init__()!
 | 
			
		||||
 | 
			
		||||
        base_stitch = None
 | 
			
		||||
        if isinstance(x, Stitch):
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +46,14 @@ class Stitch(Point):
 | 
			
		|||
        if base_stitch is not None:
 | 
			
		||||
            self.add_tags(base_stitch.tags)
 | 
			
		||||
 | 
			
		||||
    def __new__(cls, *args, **kwargs):
 | 
			
		||||
        instance = super().__new__(cls)
 | 
			
		||||
 | 
			
		||||
        # Set default values for any new attributes here (see note in __init__() above)
 | 
			
		||||
        # instance.foo = None
 | 
			
		||||
 | 
			
		||||
        return instance
 | 
			
		||||
 | 
			
		||||
    def __repr__(self):
 | 
			
		||||
        return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.x,
 | 
			
		||||
                                                                   self.y,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,11 @@ class StitchGroup:
 | 
			
		|||
 | 
			
		||||
    def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False,
 | 
			
		||||
                 tie_modus=0, force_lock_stitches=False, stitch_as_is=False, tags=None):
 | 
			
		||||
        # DANGER: if you add new attributes, you MUST also set their default
 | 
			
		||||
        # values in __new__() below.  Otherwise, cached stitch plans can be
 | 
			
		||||
        # loaded and create objects without those properties defined, because
 | 
			
		||||
        # unpickling does not call __init__()!
 | 
			
		||||
 | 
			
		||||
        self.color = color
 | 
			
		||||
        self.trim_after = trim_after
 | 
			
		||||
        self.stop_after = stop_after
 | 
			
		||||
| 
						 | 
				
			
			@ -33,6 +38,14 @@ class StitchGroup:
 | 
			
		|||
        if tags:
 | 
			
		||||
            self.add_tags(tags)
 | 
			
		||||
 | 
			
		||||
    def __new__(cls, *args, **kwargs):
 | 
			
		||||
        instance = super().__new__(cls)
 | 
			
		||||
 | 
			
		||||
        # Set default values for any new attributes here (see note in __init__() above)
 | 
			
		||||
        # instance.foo = None
 | 
			
		||||
 | 
			
		||||
        return instance
 | 
			
		||||
 | 
			
		||||
    def __add__(self, other):
 | 
			
		||||
        if isinstance(other, StitchGroup):
 | 
			
		||||
            return StitchGroup(self.color, self.stitches + other.stitches)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue