2017-02-16 1 views
0

c.fillStyle 삼각형 색상하지 않는 이유는 무엇입니까?왜 캔버스 필() fillStyle에서는 지정된 색상과 모양을 페인트하지 않는 이유는 무엇입니까?

var c= document.getElementById('myCanvas').getContext('2d'); 

//c.fillRect(20,10,250,175);// 

c.moveTo(225,75); 
c.lineTo(112.5,225); 

c.moveTo(112.5,225); 
c.lineTo(337.5,225); 

c.moveTo(337.5,225); 
c.lineTo(225,75); 

c.strokeStyle= '#9e9e9e'; 
c.stroke(); 

c.fillStyle= '#ffc061'; 
c.fill(); 
+0

개선 문법. – Leonard

답변

0

lineTo 다음에 moveTo 메서드를 호출하면 현재 위치를 점프하여 채우기 영역이 끊어지기 때문에. 그래서 당신은 다음과 같이 제거의 moveTo의 방법으로이 문제를 해결할 수 있습니다.

c.moveTo(225,75); 
c.lineTo(112.5,225); 
c.lineTo(337.5,225); 
c.closePath(); 

c.strokeStyle= '#9e9e9e'; 
c.stroke(); 

c.fillStyle= '#ffc061'; 
c.fill(); 
관련 문제