2014-04-28 5 views
0

버튼 클릭만으로 사각형을 그리려합니다. 사용자는 색상을 선택한 다음 버튼을 클릭하여 특정 색상의 사각형을 그릴 수 있습니다. 이 속성을 얻는 방법. 내 피들에 레이어 버튼을 클릭하면 캔버스에 사각형을 얻을 수 있습니다. 확인란을 선택 취소하고 다시 클릭하면 같은 위치에 직사각형이 표시됩니다. 나는 매번 다른 색깔의 사각형을 만들고 싶다. 매번 같은 색의 사각형을 묘사하는 코드 펜입니다. 사용자 정의 색상 사각형을 그립니다.

http://codepen.io/anon/pen/Ffhjg/

내가 편집하려고 코드입니다. 지금은 매회 검은 색으로 그려져 있습니다. :(

http://codepen.io/anon/pen/zaFfw

+0

명이 생각할 수있는 것을 당신이하지 않으면, 당신은 문제를주고있다 생각하는 코드를 분리해야 더 빨리 도움을받을 수 있습니다 당신은 그들이 당신의 일을하기를 원합니다. – juanpastas

+0

좋아요. –

답변

0

은 init3에 다음 코드를 추가

var oMaterialCB = document.getElementById("pickColor"); 
     var sMaterial = oMaterialCB.options[oMaterialCB.selectedIndex].text; 
     var sMaterialColor = oMaterialCB.options[oMaterialCB.selectedIndex].value; 
     m_iCurrentLayerIndex = AddToCB('LayerList', sMaterial + 'Layer'); 


     //x,y, width, height 
     var l_dYOfPrevLayer = document.getElementById('TextLayer_ULy').value; 

     var Display_DY = DisplayCoords(l_dYOfPrevLayer); //m_oSetup.Layers[m_iCurrentLayerIndex-1].BottomBoundary; 

     addRect(0,Display_DY,640,100, sMaterialColor); 
     // get the last box, update the index for that box and type of that box 


     } 
관련 문제