Clolent

변수

함수


MouseButton

LEFT, RIGHT 로 구분되어 있는 변수

if ( mousePressed && mouseButton == LEFT ) 

로 한다면 마우스가 클릭되었고, 그것이 좌클릭 일 경우 로 사용할 수 있다.


Color

무려 자료형이다 int, float 처럼 ! 16진수로 넘겨줄 수 있다.

color c1 = color(255,0,0 ) ;

color c2 = #FFFFFF ;

하고 fill ( c1 ) / fill ( c2) 이런식으로 넘겨줄 수 있다.


dist ( x, y, x2, y2 )

두 좌표 사이의 거리를 구하는 함수로 반환값은 당연하게도


get ( x, y )

해당 좌표값에 색상을 가져오너라!

get ( x, y, width, height )

해당 좌표값기준으로 width와 height 만큼 이미지를 가져와랏! 


frameRate( fps ) 

1초에 몇 프레임만 하세요 ! 하고 설정해주는 함수 




★☆ 블로그 포스팅 할때 프로세싱으로 만든거 넣기 ★☆


<script src="http://cfs.tistory.com/custom/blog/219/2191875/skin/images/processing.js"></script>

<script type="text/processing" data-processing-target="mycanvas">


내 코드

</script>
<canvas id="mycanvas"></canvas>




동서남북 랜덤한 방향으로 랜덤한 속도로 움직이는 원 구현

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
int circle = 10 ;
float x,y ;
float temp1 ;
float temp2 ;
boolean flagx =true ;
boolean flagy =true ;
 
void setup(){
  size(240,120 ) ;
  x = width/2 ;
  y = height/2 ;
  temp1 = random(-5,5) ;
  temp2 = random(-5,5) ;
}
 
void draw(){
  background(255);
  
 ellipse (  x,y,circle, circle ) ;
  if(flagx ){
     x +=temp1 ;
  }
  else {
    x -= temp1 ;    
  }
  
  if(flagy )
  y += temp2;
  else
  y-=temp2;
  
  if( x + circle/2 >= 240  ){
   flagx = false ; 
     temp1 = random(5) ;
  }
  else if ( x - circle/2 <= 0 ) {
    flagx = true ;
      temp1 = random(5) ;
  }
  
  if( y + circle/2 >= 120 ) {
   flagy = false ; 
     temp2 = random(5) ;
  }
  else if( y - circle/2 <= 0 ) {
   flagy = true ; 
     temp2 = random(5) ;
  }
  
}
  
cs


가만히 있을땐 얌전하다가, 움직이면 디스코팡팡 예제코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
int i , j , k ;
int smallcircle ;
int bigcircle ;
int tempX , tempY ;
color pastell[] = { #FFFF96 , #FFB900 , #FFEFD5 , #FFCAD5 , #FF6EED, #65FFBA, #FFFFEE, #D2FFD2, #A8F552 ,
                    #4AB34A, #46D2D2, #00FFFF, #28A0FF, #5AD2FF, #228B22, #008C8C, #90AFFF, #FFC300 };
 
void setup()
{
 size(800,640) ; 
  
  smallcircle = 20 ;
  bigcircle = 50 ;
}
 
void draw(){
 background(255) ;
 
  fill(255,244,28) ;
 ellipse(tempX, tempY, bigcircle, bigcircle ) ; 
  
  fill(255) ;
  noStroke();
  ellipse(tempX, tempY , 20,20 ) ; 
 
 for( i = 0 ; i < 30 ; i++ ) {
   for( j = 0 ; j < 10 ; j++ ) {
    if( tempX != mouseX || tempY != mouseY ){
      fill(pastell[(int)random(18)]  ) ;
    }
    ellipse( tempX +  ( bigcircle + smallcircle + 15*i ) * cos ( radians(36 * j + 8 * i) ) / 2,
           tempY +  ( bigcircle + smallcircle  + 15*i ) * sin ( radians(36 * j + 8 * i ) ) / 2 ,
           smallcircle + 5 * i, smallcircle + 5 * i ) ;  
   }
 } 
 tempX = mouseX ;
 tempY = mouseY ; 
}
cs



댓글 로드 중…

블로그 정보

Clolent - 커피물조절달인

최근에 게시된 글