Skip to content

Commit

Permalink
Run the rendering in individual quantas
Browse files Browse the repository at this point in the history
  • Loading branch information
dukescript committed Jul 6, 2018
1 parent 83c230e commit 19db8b1
Showing 1 changed file with 45 additions and 17 deletions.
62 changes: 45 additions & 17 deletions snapsvg/src/test/java/net/java/html/lib/snapsvg/SnapSvgTest.java
Expand Up @@ -57,26 +57,54 @@ String assertText(String msg) {
}

@Test
public void drawSomethingSimple() throws Exception {
public Runnable[] drawSomethingSimple() throws Exception {
Paper s = Exports.Snap("#demo");
Element bigCircle = s.circle(150, 150, 100);
bigCircle.attr(values(
"fill", "#bada55",
"stroke", "#000",
"strokeWidth", 5
));

Element smallCircle = s.circle(100, 150, 70);
Element discs = Element.$as(s.group(smallCircle, s.circle(200, 150, 70)));
discs.attr(values(
"fill", "#fff"
));
Element[] elements = { null, null, null };

bigCircle.attr(values(
"mask", discs
));

smallCircle.animate(values("r", 50), 1000);
return new Runnable[] {
() -> {
if (elements[0] == null) try {
elements[0] = s.circle(150, 150, 100);
} catch (NullPointerException ex) {
ex.printStackTrace();
}
},
() -> {
if (elements[0] == null) try {
elements[0] = s.circle(150, 150, 100);
} catch (NullPointerException ex) {
ex.printStackTrace();
}
},
() -> {
Element bigCircle = elements[0];
bigCircle.attr(values(
"fill", "#bada55",
"stroke", "#000",
"strokeWidth", 5
));
elements[0] = bigCircle;
},
() -> {
Element smallCircle = s.circle(100, 150, 70);
Element discs = Element.$as(s.group(smallCircle, s.circle(200, 150, 70)));
discs.attr(values(
"fill", "#fff"
));
elements[1] = smallCircle;
elements[2] = discs;
},
() -> {
Element bigCircle = elements[0];
Element smallCircle = elements[1];
Element discs = elements[2];
bigCircle.attr(values(
"mask", discs
));
smallCircle.animate(values("r", 50), 1000);
}
};
}

private static Objs values(Object... attrs) {
Expand Down

0 comments on commit 19db8b1

Please sign in to comment.