def test_circle_mode( vsk: vsketch.Vsketch, data: Tuple[float, float, float], mode: str, expected: Tuple[float, float, float, float], ) -> None: vsk.detail(0.01) vsk.circle(*data, mode=mode) assert line_count_equal(vsk, 1) assert bounds_equal(vsk, *expected)
def draw(self, vsk: vsketch.Vsketch) -> None: vsk.size("a5", landscape=True) vsk.scale("1.5cm") vsk.detail(self.detail_value) vsk.circle(0, 0, 1) vsk.circle(0, 0, 2) with vsk.pushMatrix(): vsk.scale(4) # the scale is taken into account to compute details vsk.circle(0, 0, 1) vsk.translate(4, 0) for i in range(-4, 5): with vsk.pushMatrix(): vsk.translate(0, i * 0.4) vsk.bezier(0, 0, 1, -2, 2, 2, 3, 0)
def test_circle_bad_args(vsk: vsketch.Vsketch) -> None: with pytest.raises(ValueError): vsk.circle(0, 0) # type: ignore with pytest.raises(ValueError): vsk.circle(0, 0, radius=10, diameter=20) with pytest.raises(ValueError): vsk.circle(2, 2, 5, mode="jumbo")
def draw(self, vsk: vsketch.Vsketch) -> None: vsk.size("10in", "10in") vsk.scale("3mm") i = 0 for i, prime in enumerate(get_primes(self.N)): vsk.circle(0, 0, 2 * (i + 1)) if self.random_phase: phase = np.random.random() * 2 * math.pi else: phase = -math.pi / 2 for angle in np.linspace(0, 2 * math.pi, prime, endpoint=False): vsk.line( (i + 1) * math.cos(angle + phase), (i + 1) * math.sin(angle + phase), (i + 2) * math.cos(angle + phase), (i + 2) * math.sin(angle + phase), ) vsk.circle(0, 0, 2 * (i + 2))
def draw(self, vsk: vsketch.Vsketch) -> None: vsk.size("a4", landscape=True) vsk.scale("1cm") vsk.penWidth("0.5mm") p = translate( Polygon( [(-3, -1), (1.5, -2), (1.4, 2), (0, 1.5), (-1, 2.3)], holes=[[(-0.5, -0.5), (0.5, -0.5), (0.5, 0.5), (-0.5, 0.5)]], ), 2.5, 14, ) # the default is no fill and stroke to layer 1 vsk.square(0, 0, 4) vsk.circle(2, 8, 4) vsk.geometry(p) vsk.translate(7, 0) # add some fill to layer 2 vsk.fill(2) vsk.penWidth("1mm", 2) vsk.square(0, 0, 4) vsk.circle(2, 8, 4) vsk.geometry(p) vsk.translate(7, 0) # with thick stroke vsk.fill(2) vsk.penWidth("1mm", 2) vsk.strokeWeight(4) vsk.square(0, 0, 4) vsk.circle(2, 8, 4) vsk.geometry(p) vsk.translate(7, 0) # remove stroke and set fill to layer 3 with a thicker pen vsk.fill(3) vsk.penWidth("2mm", 3) vsk.noStroke() vsk.square(0, 0, 4) vsk.circle(2, 8, 4) vsk.geometry(p)
def test_circle_default(vsk: vsketch.Vsketch) -> None: # default should be diameter vsk.detail(0.01) # make sure we have a tight bound match vsk.circle(0, 0, 5) assert line_count_equal(vsk, 1) assert bounds_equal(vsk, -2.5, -2.5, 2.5, 2.5)
def test_circle_radius(vsk: vsketch.Vsketch) -> None: vsk.circle(0, 0, radius=5) assert line_count_equal(vsk, 1) assert bounds_equal(vsk, -5, -5, 5, 5)