目录
当前位置: 首页 > 文档资料 > Snap.svg 英文文档 >

Element.toPattern(x, y, width, height)

优质
小牛编辑
131浏览
2023-12-01

Creates a <pattern> element from the current element To create a pattern you have to specify the pattern rect:

Parameters

  1. xstringnumber
  2. ystringnumber
  3. widthstringnumber
  4. heightstringnumber

Returns: Element the <pattern> element

You can use pattern later on as an argument for fill attribute:

var p = paper.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({
fill: "none",
stroke: "#bada55",
strokeWidth: 5
}).pattern(0, 0, 10, 10),
c = paper.circle(200, 200, 100);
c.attr({
fill: p
});