Exemplo n.º 1
0
def test_vector_data_bounds_empty_layer():
    vd = VectorData()

    vd.add(LineCollection([(0, 10 + 10j)]), 1)
    vd.add(LineCollection())

    assert vd.bounds() == (0, 0, 10, 10)
Exemplo n.º 2
0
    def process(self, processors):
        vector_data = VectorData()

        for _ in range(self.number):
            state = execute_processors(processors)
            vector_data.extend(state.vector_data)

        return vector_data
Exemplo n.º 3
0
def test_vector_data_lid_iteration():
    lc = LineCollection([(0, 1 + 1j)])
    vd = VectorData()
    vd.add(lc, 1)

    for lc in vd.layers_from_ids([1, 2, 3, 4]):
        lc.append([3, 3 + 3j])

    assert vd.count() == 1
    assert len(vd.layers[1]) == 2
Exemplo n.º 4
0
    def process(self, processors):
        vector_data = VectorData()

        for i in range(self.number[0]):
            for j in range(self.number[1]):
                state = execute_processors(processors)
                state.vector_data.translate(self.offset[0] * i,
                                            self.offset[1] * j)
                vector_data.extend(state.vector_data)

        return vector_data
Exemplo n.º 5
0
    def __init__(self, data: Dict[str, Any]):
        self.count = data["count"]
        self.length = data.get("length", 0)
        self.pen_up_length = data.get("pen_up_length", 0)
        self.bounds = data.get("bounds", [0, 0, 0, 0])
        self.layers = data.get("layers", {})

        self.vector_data = VectorData()
        for vid, lines in self.layers.items():
            self.vector_data[int(vid)] = LineCollection(
                [np.array([x + 1j * y for x, y in line]) for line in lines])
Exemplo n.º 6
0
def ldelete(vector_data: VectorData, layers) -> VectorData:
    """Delete one or more layers.

    LAYERS can be a single layer ID, the string 'all' (to delete all layers), or a
    coma-separated, whitespace-free list of layer IDs.
    """

    lids = set(multiple_to_layer_ids(layers, vector_data))

    new_vector_data = VectorData()
    for lid in vector_data.ids():
        if lid not in lids:
            new_vector_data[lid] = vector_data[lid]

    return new_vector_data
Exemplo n.º 7
0
def test_ops_on_vector_data_with_emtpy_layer():
    vd = VectorData()
    lc = LineCollection()
    vd.add(lc, 1)
    _all_vector_data_ops(vd)
Exemplo n.º 8
0
def test_ops_on_emtpy_vector_data():
    vd = VectorData()
    _all_vector_data_ops(vd)
Exemplo n.º 9
0
def test_vector_data_bounds():
    vd = VectorData()
    vd.add(LineCollection([(-10, 10), (0, 0)]), 1)
    vd.add(LineCollection([(0, 0), (-10j, 10j)]), 2)
    assert vd.bounds() == (-10, -10, 10, 10)