2014-09-11 4 views
0

저는 세 줄을 그려서 두 번째와 세 번째 줄의 무게를 바꾸고 두 번째와 세 번째 줄을 채색하려고합니다. 나는 모든 일을 제대로하고 있다고 생각하지만 일이 잘되지 않습니다. 선 대신 정점을 사용하고 있지만 코드가 올바르게 작동하지 않습니다. 색상이 없습니다. 도움 주셔서 감사합니다. 나는 그것이 무언가다는 것을 확실하다 벙어리 나는 분실하고있다.3 개의 꼭지점을 색칠하려고합니다.

//write the code to draw 3 lines 
// 
//set the area size 
size(100,200); 
// 
smooth(); //not needed for lines but there for comment 

background(#FCFDFF); //go white 
//line(x1,y1,x2,y2); 
//but doesn't work to for fill color. Use vertex 
//vertex(x, y) 
//x float: x-coordinate of the vertex 
//y float: y-coordinate of the vertex 
//z float: z-coordinate of the vertex 
// 
//set stroke using strokeWeight 
//draw first line with a stroke weight of 3 
beginShape(LINES); 
background(#FFFFFF); 
strokeWeight(3); 
vertex(20, 30); 
vertex(20, 90); 
// 
//draw second line with stroke weight of 5 and color it RED 
//second line 
strokeWeight(5); 
fill(255,0,0); 
vertex(40, 30); 
vertex(40, 90); 
// 
//draw third line with rounded ends and stroke weight 
//of 7 and PURPLE 
// 
strokeWeight(7); 
strokeJoin(ROUND); 
fill(#C811F2); 
vertex(60, 30); 
vertex(60, 90); 
endShape(); 

//end of program 

//NEW code I wrote - 
size(100,200); 
background(#FCFDFF); //go white 
//draw 3 lines 
//line(x1,y1,x2,y2); 
//but doesn't work to fill color. Use vertex and stroke(); 
//vertex(x, y) 
//x float: x-coordinate of the vertex 
//y float: y-coordinate of the vertex 
//z float: z-coordinate of the vertex 
//set stroke using strokeWeight 
//draw first line with a stroke weight of 3 
//noStroke(); 
beginShape(LINES); 
background(#FFFFFF); 
// 
strokeWeight(3); 
vertex(20, 30); //top 
vertex(20, 90); //bottom 
// 
//draw second line with stroke weight of 5 and RED 
// 
stroke(255,0,0); 
strokeWeight(5); 
vertex(40, 30); //top 
vertex(40, 90); //bottom 
// 
//draw third line with rounded ends and stroke weight 
//of 7 and PURPLE 
// 
stroke(#C40FD8); 
strokeWeight(7); 
strokeJoin(ROUND); 
vertex(60, 30); //top 
vertex(60, 90); //bottom 
endShape(); 
//end of program 

답변

0

이 작업을 수행하는 쉬운 방법은 선을 그려서 정점에 원을 그리는 것입니다.

//write the code to draw 3 lines 
// 
//set the area size 
size(100,200); 
// 
smooth(); //not needed for lines but there for comment 

background(#FCFDFF); //go white 
//line(x1,y1,x2,y2); 
//but doesn't work to for fill color. Use vertex 
//vertex(x, y) 
//x float: x-coordinate of the vertex 
//y float: y-coordinate of the vertex 
//z float: z-coordinate of the vertex 
// 
//set stroke using strokeWeight 
//draw first line with a stroke weight of 3 
beginShape(LINES); 
background(#FFFFFF); 
strokeWeight(3); 
vertex(20, 30); 
vertex(20, 90); 
ellipse(20, 30, 10, 10); 
ellipse(20, 90, 10, 10); 
// 
//draw second line with stroke weight of 5 and color it RED 
//second line 
strokeWeight(5); 
fill(255,0,0); 
vertex(40, 30); 
vertex(40, 90); 
ellipse(40, 30, 10, 10); 
ellipse(40, 90, 10, 10); 
// 
//draw third line with rounded ends and stroke weight 
//of 7 and PURPLE 
// 
strokeWeight(7); 
strokeJoin(ROUND); 
fill(#C811F2); 
vertex(60, 30); 
vertex(60, 90); 
ellipse(60, 30, 10, 10); 
ellipse(60, 90, 10, 10); 
endShape(); 

원하는대로 정확하게 작동하지 않을 수 있지만 약간 조정하면 작동합니다. 그게 네가 의도 한대로가 아니라면 알려줘.

+0

을 사용하지 잊어 버렸습니다. 나는 제 2의 '선'을 끝까지 제곱 할 수 있도록 수정해야한다. – Waynewal

+0

도움말을 잊어서 고맙습니다. 내 메일은이 대답을 잡지 못했습니다. 귀하의 제안은 아주 잘 진행되었습니다. 지연 돼서 죄송합니다. – Waynewal

0

뜨아 ....
사실이 드디어 해낸 코드이었다 fill(); 사용 stroke();

+0

감사! 위의 프로그램의 끝 부분을 편집합니다. 도우려는 데 시간을 내주는 것이 좋지만 점차적으로 넓은 라인이있는 2 개의 수직선과 2, 3 번째 색상이 필요합니다. – Waynewal

관련 문제