]> git.lizzy.rs Git - nothing.git/blob - devtools/svg2rects.xqe
(#167) Implement background static blocks
[nothing.git] / devtools / svg2rects.xqe
1 declare namespace svg ="http://www.w3.org/2000/svg";
2
3 let $rects := //svg:svg/svg:rect
4 let $player := for $rect in $rects where $rect/@id = "player"
5   return concat (
6     $rect/@x, " ",
7     $rect/@y, " ",
8     replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
9   )
10 let $platforms := for $rect in $rects where matches($rect/@id, "^rect.*")
11   return concat (
12     $rect/@x, " ",
13     $rect/@y, " ",
14     $rect/@width, " ",
15     $rect/@height, " ",
16     replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
17   )
18 let $regions := for $rect in $rects where matches($rect/@id, "region.*") return $rect
19 let $goals := for $rect in $rects where matches($rect/@id, "goal.*") return (
20   let $goal_id := replace($rect/@id, "goal(.*)", "$1")
21   let $goal_region := for $region in $regions where $region/@id = concat("region", $goal_id) return $region
22   return concat (
23     $rect/@x, " ",
24     $rect/@y, " ",
25     $goal_region[1]/@x, " ",
26     $goal_region[1]/@y, " ",
27     $goal_region[1]/@width, " ",
28     $goal_region[1]/@height, " ",
29     replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
30   )
31 )
32 let $lavas := for $rect in $rects where matches($rect/@id, "lava.*")
33   return concat (
34     $rect/@x, " ",
35     $rect/@y, " ",
36     $rect/@width, " ",
37     $rect/@height, " ",
38     replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
39   )
40 let $background := for $rect in $rects where $rect/@id = "background"
41 return replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
42 let $backplatforms := for $rect in $rects where matches($rect/@id, "^backrect.*")
43   return concat (
44     $rect/@x, " ",
45     $rect/@y, " ",
46     $rect/@width, " ",
47     $rect/@height, " ",
48     replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
49   )
50 return (
51   $background,
52   $player,
53   count($platforms),
54   $platforms,
55   count($goals),
56   $goals,
57   count($lavas),
58   $lavas,
59   count($backplatforms),
60   $backplatforms
61 )