Make chart image size dynamic

It now depends on the maximum distance of icons from the chart
This commit is contained in:
Gergely Polonkai 2014-09-24 21:46:43 +02:00
parent d2ff3d0675
commit 023dbcb55f
2 changed files with 54 additions and 49 deletions

View File

@ -192,7 +192,7 @@
be a good idea to implement saving, and possibly loading to/from
there.
* Dynamic chart size :version_1.0:
* DONE Dynamic chart size :version_1.0:
Right now some planets may disappear from the chart because they get
too far from the chart ring (due to @dist).

View File

@ -15,10 +15,12 @@
<xsl:variable name="asc" select="chartinfo/ascmcs/ascendant/@degree_ut" />
<xsl:variable name="asc_rotate" select="$asc - 180"/>
<xsl:variable name="PI" select="math:constant('PI', 10)" />
<xsl:variable name="image_size" select="800" />
<xsl:variable name="chart_size" select="600" />
<xsl:variable name="icon_size" select="30" />
<xsl:variable name="r_aspect" select="$image_size * 0.3" />
<xsl:variable name="r_moon" select="$image_size * 0.0625" />
<xsl:variable name="max_dist" select="/chartinfo/bodies/body/@dist[not(. &lt; ../../body/@dist)][1]" />
<xsl:variable name="image_size" select="$chart_size + 2.82 * $icon_size * ($max_dist + 2)" />
<xsl:variable name="r_aspect" select="$chart_size * 0.4" />
<xsl:variable name="r_moon" select="$chart_size * 0.083333" />
<xsl:template name="planet-template">
<xsl:param name="planet_name"/>
@ -33,15 +35,15 @@
<xsl:attribute name="class">planet planet-<xsl:value-of select="$planet_name"/></xsl:attribute>
<xsl:attribute name="transform">rotate(<xsl:value-of select="-$rotate"/>, 0, 0)</xsl:attribute>
<line y1="0" y2="0" class="planet-marker">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.2875"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.3"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.383333"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.4"/></xsl:attribute>
</line>
<line y1="0" y2="0" class="planet-marker">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.375"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.3875"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.5"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.516666"/></xsl:attribute>
</line>
<g>
<xsl:attribute name="transform">translate(<xsl:value-of select="$image_size * 0.4125 + $dist * ($icon_size * 1.1666666)"/>, <xsl:value-of select="-$icon_size div 2"/>) rotate(<xsl:value-of select="$rotate - $asc_rotate"/>, <xsl:value-of select="$icon_size div 2"/>, <xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">translate(<xsl:value-of select="$chart_size * 0.55 + $dist * ($icon_size * 1.1666666)"/>, <xsl:value-of select="-$icon_size div 2"/>) rotate(<xsl:value-of select="$rotate - $asc_rotate"/>, <xsl:value-of select="$icon_size div 2"/>, <xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<use class="planet-symbol">
<xsl:attribute name="xlink:href">#<xsl:value-of select="$planet_base"/>_tmpl</xsl:attribute>
<xsl:choose>
@ -125,9 +127,12 @@
<xi:include href="gres://default-icons/planet-moon-apogee.xml" />
<xi:include href="gres://default-icons/point-vertex.xml" />
<!-- TODO: the size of this arrow should also depend on $image_size -->
<marker id="arrow_end" orient="auto" refX="3.5" refY="0.0" style="overflow:visible">
<polygon points="0.0,0.0 7.0,-2.0 5.0,0.0 7.0,2.0" />
<marker id="arrow_end" orient="auto" refY="0.0" style="overflow:visible">
<xsl:attribute name="refX"><xsl:value-of select="$chart_size * 0.005833"/></xsl:attribute>
<polygon>
<xsl:attribute name="points">0.0,0.0 <xsl:value-of select="$chart_size * 0.011666"/>,-<xsl:value-of select="$chart_size * 0.003333"/><xsl:text> </xsl:text><xsl:value-of select="$chart_size * 0.008333"/>,0.0 <xsl:value-of select="$chart_size * 0.011666"/>,<xsl:value-of select="$chart_size * 0.003333"/>
</xsl:attribute>
</polygon>
</marker>
</defs>
@ -146,24 +151,24 @@
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(', $asc_rotate, ',0,0)')" /></xsl:attribute>
<g id="base">
<circle id="outer_circle" cx="0" cy="0" class="thick">
<xsl:attribute name="r"><xsl:value-of select="$image_size * 0.375"/></xsl:attribute>
<xsl:attribute name="r"><xsl:value-of select="$chart_size * 0.5"/></xsl:attribute>
</circle>
<circle id="middle_circle" cx="0" cy="0" class="thin">
<xsl:attribute name="r"><xsl:value-of select="$image_size * 0.319"/></xsl:attribute>
<xsl:attribute name="r"><xsl:value-of select="$chart_size * 0.425333"/></xsl:attribute>
</circle>
<circle id="inner_circle" cx="0" cy="0" class="thick">
<xsl:attribute name="r"><xsl:value-of select="$r_aspect"/></xsl:attribute>
</circle>
<circle id="house_circle" cx="0" cy="0" class="thin">
<xsl:attribute name="r"><xsl:value-of select="$image_size * 0.0875"/></xsl:attribute>
<xsl:attribute name="r"><xsl:value-of select="$chart_size * 0.116666"/></xsl:attribute>
</circle>
<circle id="moon_circle" cx="0" cy="0" class="thick" style="fill:#00000;stroke:none">
<xsl:attribute name="r"><xsl:value-of select="$r_moon"/></xsl:attribute>
</circle>
<line id="aries_start" y1="0" y2="0" class="degree-thick">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.3"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.375"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.5"/></xsl:attribute>
</line>
<use x="0" y="0" xlink:href="#aries_start" id="taurus_start" transform="rotate(-30,0,0)" class="degree-thick" />
<use x="0" y="0" xlink:href="#aries_start" id="gemini_start" transform="rotate(-60,0,0)" class="degree-thick" />
@ -178,8 +183,8 @@
<use x="0" y="0" xlink:href="#aries_start" id="pisces_start" transform="rotate(-330,0,0)" class="degree-thick" />
<line id="deg_10" y1="0" y2="0" transform="rotate(-10,0,0)" class="degree-thin">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.3"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.31875"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.425"/></xsl:attribute>
</line>
<use x="0" y="0" xlink:href="#deg_10" id="deg_20" transform="rotate(-10,0,0)" class="degree-thin" />
<use x="0" y="0" xlink:href="#deg_10" id="deg_40" transform="rotate(-30,0,0)" class="degree-thin" />
@ -206,8 +211,8 @@
<use x="0" y="0" xlink:href="#deg_10" id="deg_350" transform="rotate(-340,0,0)" class="degree-thin" />
<line id="deg_5" y1="0" y2="0" transform="rotate(-5,0,0)" class="degree-thin">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.3"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.3125"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.416666"/></xsl:attribute>
</line>
<use x="0" y="0" xlink:href="#deg_5" id="deg_15" transform="rotate(-10,0,0)" class="degree-thin" />
<use x="0" y="0" xlink:href="#deg_5" id="deg_25" transform="rotate(-20,0,0)" class="degree-thin" />
@ -246,8 +251,8 @@
<use x="0" y="0" xlink:href="#deg_5" id="deg_355" transform="rotate(-350,0,0)" class="degree-thin" />
<line id="deg_1" y1="0" y2="0" transform="rotate(-1,0,0)" class="degree-thin">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.3"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.30625"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.408333"/></xsl:attribute>
</line>
<use x="0" y="0" xlink:href="#deg_1" id="deg_2" transform="rotate(-1,0,0)" class="degree-thin" />
<use x="0" y="0" xlink:href="#deg_1" id="deg_3" transform="rotate(-2,0,0)" class="degree-thin" />
@ -538,40 +543,40 @@
<use x="0" y="0" xlink:href="#deg_1" id="deg_359" transform="rotate(-358,0,0)" class="degree-thin" />
<use x="0" y="0" xlink:href="#sign_aries_tmpl" id="sign_aries" class="sign sign-fire">
<xsl:attribute name="transform">rotate(-15,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-15,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_taurus_tmpl" id="sign_taurus" class="sign sign-earth">
<xsl:attribute name="transform">rotate(-45,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-45,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_gemini_tmpl" id="sign_gemini" class="sign sign-air">
<xsl:attribute name="transform">rotate(-75,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-75,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_cancer_tmpl" id="sign_cancer" class="sign sign-water">
<xsl:attribute name="transform">rotate(-105,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-105,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_leo_tmpl" id="sign_leo" class="sign sign-fire">
<xsl:attribute name="transform">rotate(-135,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-135,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_virgo_tmpl" id="sign_virgo" class="sign sign-earth">
<xsl:attribute name="transform">rotate(-165,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-165,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_libra_tmpl" id="sign_libra" class="sign sign-air">
<xsl:attribute name="transform">rotate(-195,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-195,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_scorpio_tmpl" id="sign_scorpio" class="sign sign-water">
<xsl:attribute name="transform">rotate(-225,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-225,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_sagittarius_tmpl" id="sign_sagittarius" class="sign sign-fire">
<xsl:attribute name="transform">rotate(-255,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-255,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_capricorn_tmpl" id="sign_capricorn" class="sign sign-earth">
<xsl:attribute name="transform">rotate(-285,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-285,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_aquarius_tmpl" id="sign_aquarius" class="sign sign-air">
<xsl:attribute name="transform">rotate(-315,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-315,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
<use x="0" y="0" xlink:href="#sign_pisces_tmpl" id="sign_pisces" class="sign sign-water">
<xsl:attribute name="transform">rotate(-345,0,0) translate(<xsl:value-of select="$image_size * 0.32625"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
<xsl:attribute name="transform">rotate(-345,0,0) translate(<xsl:value-of select="$chart_size * 0.435"/>,-<xsl:value-of select="$icon_size div 2"/>) rotate(90,<xsl:value-of select="$icon_size div 2"/>,<xsl:value-of select="$icon_size div 2"/>)</xsl:attribute>
</use>
</g>
@ -610,45 +615,45 @@
</xsl:choose>
</xsl:variable>
<text text-anchor="middle">
<xsl:attribute name="font-size"><xsl:value-of select="$image_size * 0.0125"/></xsl:attribute>
<xsl:attribute name="font-size"><xsl:value-of select="$chart_size * 0.016666"/></xsl:attribute>
<xsl:attribute name="transform">
rotate(-<xsl:value-of select="$house_mid"/>,0,0) translate(<xsl:value-of select="$image_size * 0.06875"/>,0) rotate(90,0,0)
rotate(-<xsl:value-of select="$house_mid"/>,0,0) translate(<xsl:value-of select="$chart_size * 0.091666"/>,0) rotate(90,0,0)
</xsl:attribute>
<xsl:value-of select="@number"/>
</text>
<line y1="0" y2="0" class="house-cusp">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.0625"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.3"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.083333"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.4"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="concat('house_cusp_', @number)"/></xsl:attribute>
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(-', @degree, ')')" /></xsl:attribute>
</line>
<line y1="0" y2="0" class="house-cusp">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.375"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.4125"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.5"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.55"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="concat('house_cusp_', @number, '_outer')"/></xsl:attribute>
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(-', @degree, ')')" /></xsl:attribute>
</line>
</xsl:for-each>
<line id="descendent" y1="0" y2="0" class="axis">
<xsl:attribute name="x1"><xsl:value-of select="- $image_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="- $image_size * 0.0625"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="- $chart_size * 0.533333"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="- $chart_size * 0.083333"/></xsl:attribute>
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(-', $asc, ',0,0)')" /></xsl:attribute>
</line>
<line id="ascendant" y1="0" y2="0" class="axis axis-end">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.0625"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.533333"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.083333"/></xsl:attribute>
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(-', $asc, ')')" /></xsl:attribute>
</line>
<xsl:variable name="mc" select="chartinfo/ascmcs/mc/@degree_ut"/>
<line id="ic" y1="0" y2="0" class="axis">
<xsl:attribute name="x1"><xsl:value-of select="- $image_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="- $image_size * 0.0625"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="- $chart_size * 0.533333"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="- $chart_size * 0.083333"/></xsl:attribute>
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(-', $mc, ')')" /></xsl:attribute>
</line>
<line id="mc" y1="0" y2="0" class="axis axis-end">
<xsl:attribute name="x1"><xsl:value-of select="$image_size * 0.4"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$image_size * 0.0625"/></xsl:attribute>
<xsl:attribute name="x1"><xsl:value-of select="$chart_size * 0.533333"/></xsl:attribute>
<xsl:attribute name="x2"><xsl:value-of select="$chart_size * 0.083333"/></xsl:attribute>
<xsl:attribute name="transform"><xsl:value-of select="concat('rotate(-', $mc, ')')" /></xsl:attribute>
</line>
</g>