Pattern no-repeat support

已查看 36 次
跳至第一个未读帖子

Renato Formato

未读,
2010年6月12日 14:54:112010/6/12
收件人 google-excanvas
Hi,
here is a patch against the HEAD to support no-repeat for patterns.
It works with translations and scaling, but not with rotations,
because the only way I've found to make it work is rotate the shape
itself, while current implementation does not rotate shapes but
transform its path.

I should have already signed the CLA

Index: excanvas.js
===================================================================
--- excanvas.js (revisione 73)
+++ excanvas.js (copia locale)
@@ -1069,15 +1069,16 @@
' focusposition="', focus.x, ',', focus.y, '" /
>');
} else if (fillStyle instanceof CanvasPattern_) {
if (width && height) {
- var deltaLeft = -min.x;
- var deltaTop = -min.y;
+ var wi = fillStyle.width_ * Z, hi = fillStyle.height_ * Z;
+ var deltaLeft = - width/2 + ctx.m_[2][0] * Z - min.x;
+ var deltaTop = - height/2 + ctx.m_[2][1] * Z - min.y;
lineStr.push('<g_vml_:fill',
+ ' origin="'+
(fillStyle.repetition_=="repeat"?"0,0":"-0.5,-0.5")+'"',
' position="',
- deltaLeft / width * arcScaleX * arcScaleX, ',',
- deltaTop / height * arcScaleY * arcScaleY, '"',
- ' type="tile"',
- // TODO: Figure out the correct size to fit the
scale.
- //' size="', w, 'px ', h, 'px"',
+ deltaLeft / width , ',',
+ deltaTop / height , '"',
+ ' type="'+
(fillStyle.repetition_=="repeat"?"tile":"frame")+'"',
+ ' size="', wi / width * arcScaleX , ',', hi /
height * arcScaleY , '"',
' src="', fillStyle.src_, '" />');
}
} else {
回复全部
回复作者
转发
0 个新帖子