]> git.lizzy.rs Git - nothing.git/blob - scripts/svg2rects.xqe
(#122) use wavy_rect for lava
[nothing.git] / scripts / 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 return (
43   $background,
44   $player,
45   count($platforms),
46   $platforms,
47   count($goals),
48   $goals,
49   count($lavas),
50   $lavas
51 )