2014-05-16 2 views
0

채우기 및 획을 적용한 순서에 따라 결과가 달라집니다. HTML 캔버스를 사용하면 순서를 제어 할 수 있습니다. 여기 SVG에서 채우기 및 획의 순서를 제어하는 ​​방법은 무엇입니까?

채우기 스트로크 전에 적용될 때 결과 : http://jsfiddle.net/YLk2F/

ctx.fillStyle = options.fillColor; 
    ctx.fillText(options.text, options.x, options.y);  
    ctx.strokeStyle = options.outlineColor; 
    ctx.lineWidth = options.outlineWidth; 
    ctx.strokeText(options.text, options.x, options.y); 

enter image description here

채운다 뇌졸중 이후에인가 될 때 : http://jsfiddle.net/jsMX9/

ctx.strokeStyle = options.outlineColor; 
ctx.lineWidth = options.outlineWidth; 
ctx.strokeText(options.text, options.x, options.y); 
ctx.fillStyle = options.fillColor; 
ctx.fillText(options.text, options.x, options.y);  

enter image description here

,536,913,632 10

SVG에서는 모든 것이 SVG 속성을 통해 이루어지며 획보다 먼저 채우기가 적용된 것처럼 보입니다. 참조 예컨대 : http://jsfiddle.net/wYw86/1

<svg id="SvgjsSvg1000" xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" xmlns:xlink="http://www.w3.org/1999/xlink"> 
    <text id="SvgjsText1006" font-family="times new roman" font-size="40pt" stroke="#ff0000" stroke-width="2" fill="#000000" transform="translate(100 100)"> 
     <tspan id="SvgjsTspan1008" style="font-weight: bold; font-style: italic; font-variant: small-caps; text-decoration: underline;">Hello World!</tspan> 
    </text> 
</svg> 

enter image description here

하면 해당 채우기가 SVG에서 뇌졸중 후 적용되도록이 순서를 반대로 할 수 있습니까? 방법?

+0

스트로크는 SVG를 채운 후에 항상 적용됩니다. SVG 단위를 정의하지 않았고 브라우저가 의도를 정확하게 추측하지 않아서보고있는 효과가있을 수 있습니다. –

+0

감사합니다. 당신이 옳았. 내 코드에 버그가있었습니다 (캔버스 예제에서는 2 픽셀 너비, svg에서는 1 픽셀 너비 사용). 올바른 코드와 이미지로 질문을 업데이트했습니다. – morpheus

+0

SVG를 채운 후에 획이 항상 적용된다는 주장을 뒷받침하는 참조가 있습니까? 그건 분명히 그런 식으로 보이지만, SVG의 기술 사양에서 이것을 찾을 수 없습니다. – morpheus

답변

1

SVG 1.1 (현재 대부분의 브라우저에서 적용되는 기능)에서 직접 수행 할 수있는 방법은 없습니다. 다음 SVG 2 사양에는 paint-order 속성이 있습니다.

Firefox는 버전 31부터 페인트 주문 지원을받을 예정이며 Chrome에도 아직 버전이 있어야합니다.

그 사이에 항상 같은 위치에 2 개의 요소를 만들 수 있고, 하나를 채우고 나머지는 다른 캔버스로 만들 수 있습니다. 이제는 캔버스로 수행하는 작업과 거의 같습니다.

+1

페인트 도료는 Chrome 35에 배송되며, http://blog.chromium.org/2014/04/chrome- 35-beta-more-developer-control.html. –

관련 문제