Adding SVG image operations?

Rafał Miłecki zajec5 at gmail.com
Wed Apr 16 23:06:22 CEST 2008


Currently we use some hacks when using SVG images. Let me just call
analog clock's code:

1) For drawing hand we use QPainter trick. We save current QPainter,
then rotate it, then draw choosen hand only and after all we restore
QPainter status. Isn't this little complex?

2) For drawing text with current time we use QPainter::drawText(...).
This causes possibility of situation when text is in place which was
designed by SVG author for sth else. What's more, we have no idea if
style of font does fit to SVG image.

I think it would be great if we could just modify (in buffer) some
code of SVG and redraw it.  Some examples:

1) SVG author places simple line in image:
<line id="MinuteHand" x1="50" y1="50" x2="50" y2="0" />
which results in vertical hand. We just move it when needed:
<line id="MinuteHand" x1="50" y1="50" x2="48" y2="5" />

2) Author places:
<text id="TextTime" x="35" y="165">23:59</text>
and we manage to update content of text element.

In future we could do even more. We could define names of JavaScript
functions building some kind of API. For example function
"isTimeTextDisplayed(status)" that is called every time KDE user
change displaying time as text. In that way we let SVG author adjust
image depending on KDE user's settings. Example:

function isTimeTextDisplayed(status) {
  if (status) {
    document.getElementById("foo").style.display="hidden";
  }
  else {
    document.getElementById("foo").style.display="";
  }
}

Opinions?

-- 
Rafał Miłecki


More information about the Panel-devel mailing list