-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroup.h
42 lines (34 loc) · 1.03 KB
/
Group.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#ifndef GROUP_H
#define GROUP_H
#include "SVGElement.h"
class my_group : public SVGElement {
private:
std::vector<SVGElement *> elements;
string transform;
public:
my_group(string name, string transform)
: elements(elements), SVGElement(name), transform(transform) {}
void addElement(SVGElement *element) { this->elements.push_back(element); }
void render(Graphics &graphic, vector<LinearGradient> gradients) override {
for (int i = 0; i < elements.size(); i++) {
if (elements[i]->getTransform() != "") {
GraphicsState save = graphic.Save();
Transform t;
t.parseTransform(elements[i]->getTransform());
t.appleMultipleTransforms(graphic);
elements[i]->render(graphic, gradients);
graphic.Restore(save);
continue;
}
elements[i]->render(graphic, gradients);
}
}
~my_group() override {
for (SVGElement *element : this->elements) {
delete element;
}
}
string getTransform() override { return this->transform; }
};
#endif