kopia lustrzana https://github.com/inkstitch/inkstitch
Merge remote-tracking branch 'origin/claudine/random_satin_column' into george-steel/random-base-satin
commit
dd115ae02f
|
|
@ -2,11 +2,12 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 Authors
|
# Copyright (c) 2010 Authors
|
||||||
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
|
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
from inkex import paths
|
from inkex import paths
|
||||||
from shapely import affinity as shaffinity
|
from shapely import affinity as shaffinity
|
||||||
from shapely import geometry as shgeo
|
from shapely import geometry as shgeo
|
||||||
|
|
@ -96,36 +97,31 @@ class SatinColumn(EmbroideryElement):
|
||||||
return min(max(self.get_int_param("random_split_factor", 0), 0), 100)
|
return min(max(self.get_int_param("random_split_factor", 0), 0), 100)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@param('random_first_rail_factor_in',
|
@param('random_zigzag_spacing',
|
||||||
_('First Rail Random Factor inside'),
|
_('Zig-zag spacing randomness(peak-to-peak)'),
|
||||||
tooltip=_('shorten stitch around first rail at most this percent.'),
|
tooltip=_('percentage of randomness of Peak-to-peak distance between zig-zags.'),
|
||||||
type='int', unit="%", sort_index=60)
|
type='int', unit="%", sort_index=64)
|
||||||
def random_first_rail_factor_in(self):
|
def random_zigzag_spacing(self):
|
||||||
return min(max(self.get_int_param("random_first_rail_factor_in", 0), 0), 100)
|
# peak-to-peak distance between zigzags
|
||||||
|
return max(self.get_int_param("random_zigzag_spacing", 0), 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@param('random_first_rail_factor_out',
|
@param('random_width_decrease_percent',
|
||||||
_('First Rail Random Factor outside'),
|
_('Random percentage of satin width decrease'),
|
||||||
tooltip=_('lengthen stitch around first rail at most this percent.'),
|
tooltip=_('shorten stitch across rails at most this percent.'
|
||||||
type='int', unit="%", sort_index=61)
|
'Two values separated by a space may be used for an aysmmetric effect.'),
|
||||||
def random_first_rail_factor_out(self):
|
type='int', unit="% (each side)", sort_index=60)
|
||||||
return max(self.get_int_param("random_first_rail_factor_out", 0), 0)
|
def random_width_decrease_percent(self):
|
||||||
|
return self.get_split_float_param("random_width_decrease_percent", (0, 0))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@param('random_second_rail_factor_in',
|
@param('random_width_increase_percent',
|
||||||
_('Second Rail Random Factor inside'),
|
_('Random percentage of satin width increase'),
|
||||||
tooltip=_('shorten stitch around second rail at most this percent.'),
|
tooltip=_('lengthen stitch across rails at most this percent.'
|
||||||
type='int', unit="%", sort_index=62)
|
'Two values separated by a space may be used for an aysmmetric effect.'),
|
||||||
def random_second_rail_factor_in(self):
|
type='int', unit="% (each side)", sort_index=60)
|
||||||
return min(max(self.get_int_param("random_second_rail_factor_in", 0), 0), 100)
|
def random_width_increase_percent(self):
|
||||||
|
return self.get_split_float_param("random_width_increase_percent", (0, 0))
|
||||||
@property
|
|
||||||
@param('random_second_rail_factor_out',
|
|
||||||
_('Second Rail Random Factor outside'),
|
|
||||||
tooltip=_('lengthen stitch around second rail at most this percent.'),
|
|
||||||
type='int', unit="%", sort_index=63)
|
|
||||||
def random_second_rail_factor_out(self):
|
|
||||||
return max(self.get_int_param("random_second_rail_factor_out", 0), 0)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@param('short_stitch_inset',
|
@param('short_stitch_inset',
|
||||||
|
|
@ -160,15 +156,6 @@ class SatinColumn(EmbroideryElement):
|
||||||
# peak-to-peak distance between zigzags
|
# peak-to-peak distance between zigzags
|
||||||
return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01)
|
return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01)
|
||||||
|
|
||||||
@property
|
|
||||||
@param('random_zigzag_spacing',
|
|
||||||
_('Zig-zag spacing randomness(peak-to-peak)'),
|
|
||||||
tooltip=_('percentage of randomness of Peak-to-peak distance between zig-zags.'),
|
|
||||||
type='int', unit="%", sort_index=64)
|
|
||||||
def random_zigzag_spacing(self):
|
|
||||||
# peak-to-peak distance between zigzags
|
|
||||||
return max(self.get_int_param("random_zigzag_spacing", 0), 0)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@param(
|
@param(
|
||||||
'pull_compensation_percent',
|
'pull_compensation_percent',
|
||||||
|
|
@ -550,7 +537,7 @@ class SatinColumn(EmbroideryElement):
|
||||||
for rung in self.rungs:
|
for rung in self.rungs:
|
||||||
point_lists.append(self.flatten_subpath(rung))
|
point_lists.append(self.flatten_subpath(rung))
|
||||||
|
|
||||||
# If originally there were only two subpaths (no rungs) with same number of rails, we may the rails may now
|
# If originally there were only two subpaths (no rungs) with same number of rails, the rails may now
|
||||||
# have two rails with different number of points, and still no rungs, let's add one.
|
# have two rails with different number of points, and still no rungs, let's add one.
|
||||||
|
|
||||||
if not self.rungs:
|
if not self.rungs:
|
||||||
|
|
@ -841,11 +828,9 @@ class SatinColumn(EmbroideryElement):
|
||||||
|
|
||||||
if to_travel <= 0:
|
if to_travel <= 0:
|
||||||
|
|
||||||
decalage0 = random.uniform(-self.random_first_rail_factor_in, self.random_first_rail_factor_out) / 100
|
mismatch0 = random.uniform(-self.random_width_decrease_percent[0], self.random_width_increase_percent[0]) / 100
|
||||||
decalage1 = random.uniform(-self.random_second_rail_factor_in, self.random_second_rail_factor_out) / 100
|
mismatch1 = random.uniform(-self.random_width_decrease_percent[1], self.random_width_increase_percent[1]) / 100
|
||||||
|
add_pair(pos0 + (pos0 - pos1) * mismatch0, pos1 + (pos1 - pos0) * mismatch1)
|
||||||
add_pair(pos0 + (pos0 - pos1) * decalage0, pos1 + (pos1 - pos0) * decalage1)
|
|
||||||
|
|
||||||
to_travel = spacing * (random.uniform(1, 1 + self.random_zigzag_spacing/100))
|
to_travel = spacing * (random.uniform(1, 1 + self.random_zigzag_spacing/100))
|
||||||
|
|
||||||
if to_travel > 0:
|
if to_travel > 0:
|
||||||
|
|
@ -1023,10 +1008,10 @@ class SatinColumn(EmbroideryElement):
|
||||||
points = []
|
points = []
|
||||||
distance = left.distance(right)
|
distance = left.distance(right)
|
||||||
split_count = count or int(-(-distance // max_stitch_length))
|
split_count = count or int(-(-distance // max_stitch_length))
|
||||||
|
random_move = 0
|
||||||
for i in range(split_count):
|
for i in range(split_count):
|
||||||
line = shgeo.LineString((left, right))
|
line = shgeo.LineString((left, right))
|
||||||
|
|
||||||
random_move = 0
|
|
||||||
if self.random_split_factor and i != split_count-1:
|
if self.random_split_factor and i != split_count-1:
|
||||||
random_move = random.uniform(-self.random_split_factor / 100, self.random_split_factor / 100)
|
random_move = random.uniform(-self.random_split_factor / 100, self.random_split_factor / 100)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,11 +123,9 @@ inkstitch_attribs = [
|
||||||
'pull_compensation_mm',
|
'pull_compensation_mm',
|
||||||
'pull_compensation_percent',
|
'pull_compensation_percent',
|
||||||
'stroke_first',
|
'stroke_first',
|
||||||
|
'random_width_decrease_percent',
|
||||||
|
'random_width_increase_percent',
|
||||||
'random_split_factor',
|
'random_split_factor',
|
||||||
'random_first_rail_factor_in',
|
|
||||||
'random_first_rail_factor_out',
|
|
||||||
'random_second_rail_factor_in',
|
|
||||||
'random_second_rail_factor_out',
|
|
||||||
'random_zigzag_spacing',
|
'random_zigzag_spacing',
|
||||||
'use_seed',
|
'use_seed',
|
||||||
# stitch_plan
|
# stitch_plan
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue