日期:2014-05-17  浏览次数:20467 次

进来看看,有没有什么js库或者方法能在页面里面画斜线或者旋转
如题:我在兼容性上面卡住了,锯齿严重
我就是想画出斜线(当然包括直线、竖线)。

另一条思路,我自己用div填充,然后旋转div角度,可是遇到2个问题:
1.起始位置和结束位置我能得到,可是中间怎么衔接。
2.旋转做不到兼容
求支招
js画线

------解决方案--------------------
canvas有一些,这个应该可能支持到除了IE6,7,8以外的大部分浏览器。

我写的一段代码,大部分是画矩形的操作,你要画线应该也很容易,你看看能不能参考


function main(){
                this.canvas=document.getElementById("gameCanvas");
                this.context=null;
                if(this.canvas.getContext){
                    this.context=canvas.getContext("2d");
                }
                if(!this.context){
                    alert("Your browser does not support canvas.");
                    return;
                }
                
                this.container=document.getElementById("mainDiv");
                
                this.cardCanvasDic=[];
                
                this.cardCellWidth=120;
                this.cardCellHeight=150;
                this.cardCellSpan=20;
                
                this.getCardPosition=function(row,column){
                    var _x=cardCellSpan+(column-1)*(cardCellWidth+cardCellSpan);
                    var _y=cardCellSpan+(row-1)*(cardCellHeight+cardCellSpan);
                    return {x:_x, y:_y};
                };
                
                this.DrawAbilities=function(ctx,abilities){
             &nbs