자바 랜덤함수에 대해서 질문이요 ㅋ
갤1
2023.04.01
for(int j=0; jnode; j++){
int r =random.nextInt(200);
int d = random.nextInt(200);
//System.out.println(r);
//System.out.println(d);
cells[j] = createVertex(X+(j+1), r, d, 40, 20, Color.blue, true);
}
r,d값은 저렇게 랜덤함수를 써서 했는데요
색깔은 랜덤함수로 어떻게 할수 없을까요 ?
-
파란
걍 new Color(값1, 값2, 값3)이렇게 하심 될텐데요
값은 Math.random()*256 해서 0~255사이의 정수값이 나오게 해주시면 ok -
에다
수학쟁이// R G B 라는게 따로 있어요?? 처음봤네...ㅎㅎ 저는 랜덤값으로 항상 random.nextInt(255) 했던거 같은데..
-
에드가
new Color(Float.parseFloat(R.toString()),Float.parseFloat(G.toString()),Float.parseFloat(B.toString()))
이렇게 하시면 되지 않으실까 생각됩니다...