On Fri, Dec 5, 2008 at 11:45 AM, Richard Heyes <richard.heyes@...> wrote:
> Hi,
>
> Has anyone had any problem with using the rotate() method in
> conjunction with Opera?
>
> Eg: http://dev.rgraph.org/trash/tradar.html
>
> Works fine in Firefox, Chrome and Safari, but not Opera. Cheers.
It looks like the problem you're experiencing is that Opera applies
transforms to paths when it's stroking/filling them, not when you're
constructing the path. So "rotate(); lineTo(); stroke()" is equivalent
(in Opera, not other browsers) to "lineTo(...); rotate(...);
stroke()". That means you can't do "lineTo(); rotate(); lineTo(); ...;
stroke()", because both lines get rotated by exactly the same amount.
(Opera's behaviour used to match the HTML5 canvas specification, but
then the spec changed to match what other browsers did, and Opera
hasn't been fixed yet.)
To make it work in all browsers, you'll probably have to not use
rotate() and instead do the trigonometry manually. I think it should
work if you change the "Thi bit draws the graph" loop to something
like:
for (i in this.data) {
/* ... same as before, then: */
var angle = RGraph.degrees2Radians(360 / this.data.length) * i;
if (i == 0) {
this.context.moveTo(xPos*Math.cos(angle), xPos*Math.sin(angle));
} else {
this.context.lineTo(xPos*Math.cos(angle), xPos*Math.sin(angle));
}
}
--
Philip Taylor
excors@...