示例#1
0
    def draw(self, vsk: vsketch.Vsketch) -> None:
        vsk.size("a6", landscape=False)

        doc = execute(
            "msrandom -ms -q 0.01mm -n 5 10 module_sets/ms_neon_v1 linemerge -t 0.5mm "
            "layout -m 2cm a6 ")

        for line in doc.layers[1]:

            line = vp.interpolate(line, step=0.1)

            if not self.liquify:
                vsk.polygon(line)
                continue

            perlin_x = vsk.noise(self.freq * line.real,
                                 self.freq * line.imag,
                                 grid_mode=False)
            perlin_y = vsk.noise(
                self.freq * line.real,
                self.freq * line.imag,
                1000 * np.ones_like(line.real),
                grid_mode=False,
            )
            line += self.ampl * 2.0 * ((perlin_x - 0.5) +
                                       (perlin_y - 0.5) * 1j)

            vsk.polygon(line)
            vsk.vpype("linesimplify -t 0.005mm")
示例#2
0
    def draw(self, vsk: vsketch.Vsketch) -> None:
        vsk.size("a4", landscape=True)
        vsk.scale("cm")

        x_coords = np.linspace(0, 25, 1000)

        perlin = vsk.noise(
            x_coords * self.x_freq,
            np.arange(self.num_line) / self.num_line * self.y_freq)

        for i in range(self.num_line):
            y_coords = perlin[:, i] + self.y_offset / self.num_line * i
            vsk.polygon(x_coords, y_coords)
示例#3
0
    def draw(self, vsk: vsketch.Vsketch) -> None:
        vsk.size("a4", landscape=False, center=False)
        vsk.scale(2)

        y_coords = np.linspace(0.0, 250.0, self.num_lines)
        x_coords = np.linspace(0.0, 250.0, 500)
        perlin = vsk.noise(x_coords * 0.1, y_coords * 0.2)

        x_factor = 0.5 * (1.0 - np.cos(x_coords / 250.0 * 2 * np.pi))
        y_factor = 0.5 * (1.0 - np.cos(y_coords / 250.0 * 2 * np.pi))

        for j, y in enumerate(y_coords):
            vsk.polygon(x_coords,
                        y + perlin[:, j] * 12 * y_factor[j] * x_factor)

        vsk.vpype("layout -h center -v top a4 translate 0 3.8cm")
示例#4
0
    def draw(self, vsk: vsketch.Vsketch) -> None:
        vsk.size(self.page_size)

        width = round((vsk.width - 2 * self.margin) / self.base_pitch) * self.base_pitch
        height = round((vsk.height - 2 * self.margin) / self.base_pitch) * self.base_pitch

        mls0 = MultiLineString(
            [
                [(0, y), (width, y)]
                for y in np.arange(0, height + self.base_pitch, self.base_pitch)
            ]
        )
        mls1 = MultiLineString(
            [
                [(0, y), (width, y)]
                for y in np.arange(self.base_pitch / 2, height, self.base_pitch)
            ]
        )
        mls2 = MultiLineString(
            [
                [(0, y), (width, y)]
                for y in np.arange(self.base_pitch / 4, height, self.base_pitch / 2)
            ]
        )

        # build a separation
        yy = np.linspace(0, height, 100)
        xx = np.array([vsk.noise(y * 0.002) for y in yy]) * width / 1.8 + 3 * width / 5 - 200
        p1 = Polygon(list(zip(xx, yy)) + [(width, height), (width, 0)])

        vsk.geometry(mls0)

        circles = [
            Point(vsk.random(0, width), vsk.random(0, height)).buffer(
                vsk.random(self.min_radius, self.max_radius)
            )
            for _ in range(5)
        ]

        all_geom = circles + [p1]
        itrsct = unary_union(
            [a.intersection(b) for a, b in itertools.combinations(all_geom, 2)]
        )
        vsk.geometry(mls1.intersection(unary_union(all_geom)))
        vsk.geometry(mls2.intersection(itrsct))
示例#5
0
    def draw(self, vsk: vsketch.Vsketch) -> None:
        vsk.size("a4", landscape=True)
        vsk.scale("cm")

        vsk.rotate(-90, degrees=True)

        noise_coord = np.linspace(0, 1, self.point_per_line)
        dirs = np.linspace(0, 2 * math.pi, self.num_line)
        perlin = vsk.noise(noise_coord, dirs, [0, 100])

        for i, direction in enumerate(dirs):
            rdir = vsk.map(perlin[:, i, 0], 0, 1, direction - self.rdir_range,
                           direction + self.rdir_range)
            roffset = vsk.map(perlin[:, i, 1], 0, 1, 0.05, 0.12)

            xoffset = roffset * np.cos(rdir)
            yoffset = roffset * np.sin(rdir)

            vsk.polygon(np.cumsum(xoffset), np.cumsum(yoffset))
示例#6
0
    def draw(self, vsk: vsketch.Vsketch) -> None:
        vsk.size("a4", landscape=False)
        vsk.scale("cm")

        t = np.arange(self.N) * self.freq
        perlin = vsk.noise(t, np.arange(8) * 1000)

        for i in range(self.N):
            v = i * self.drift
            vsk.bezier(
                perlin[i, 0] * 10 + v,
                perlin[i, 1] * 10 + v,
                perlin[i, 2] * 10 + v,
                perlin[i, 3] * 10 + v,
                perlin[i, 4] * 10 + v,
                perlin[i, 5] * 10 + v,
                perlin[i, 6] * 10 + v,
                perlin[i, 7] * 10 + v,
            )