2017年4月6日星期四



  



// 마우스 클릭할때 렌덤으로 다양한 패턴이 생성
// Made by zhangbo0037  2017.03.23
// Media Art class in Soongsil University
 
void setup()
{
  size(500,800);
  Draw();
}

void draw()
{
}

void mousePressed()
{
  Draw();
}

void Draw()
{
   background(236,216,192);

   color Color[];
   Color = new color[9];
   Color[0] = color(186,36,64);
   Color[1] = color(214,95,25);
   Color[2] = color(34,138,102);
   Color[3] = color(240,95,59);
   Color[4] = color(181,176,63);
   Color[5] = color(12,79,72);
   Color[6] = color(186,43,25);
   Color[7] = color(230,203,70);
   Color[8] = color(50,50,50);
 
   int Count=0;
     
   for (int i=0; i<30 i="" p="">  {
    Count++;
    int Num = int(random(1,9));
   
    switch(Num)
    {
      case 1 :
      {
        Triangle( random(20,25), random(20,25),  // Bottom & Height of Triangle
                  Color[int(random(0,9))],       // Triangle's Color
                  30,                            // The number of Same Triangles
                   2,                            // The space of each Triangles
                   0, (Count-1)*28,              // Translation of Triangle's line
                   1,                            // Scaling of all Triangle
                   1);                           // Choose different type of Triangles
                   break;
      }
     
      case 2 :
      {
        Triangle( random(20,25), random(20,25),  // Bottom & Height of Triangle
                  Color[int(random(0,9))],       // Triangle's Color
                  30,                            // The number of Same Triangles
                   2,                            // The space of each Triangles
                   0, (Count-1)*28,              // Translation of Triangle's line
                   1,                            // Scaling of all Triangle
                   2);                           // Choose different type of Triangles
             break;
      }
     
      case 3 :
      {
        Triangle( random(10,15), random(10,15),  // Bottom & Height of Triangle
                  Color[int(random(0,9))],       // Triangle's Color
                  50,                            // The number of Same Triangles
                   2,                            // The space of each Triangles
                   0, (Count-1)*28,              // Translation of Triangle's line
                   1,                            // Scaling of all Triangle
                   3);                           // Choose different type of Triangles
             break;
      }
     
      case 4 :
      {
        Triangle( random(10,15), random(10,15),  // Bottom & Height of Triangle
                  Color[int(random(0,9))],       // Triangle's Color
                  50,                            // The number of Same Triangles
                   2,                            // The space of each Triangles
                   0, (Count-1)*28,              // Translation of Triangle's line
                   1,                            // Scaling of all Triangle
                   4);                           // Choose different type of Triangles
             break;
      }
     
      case 5 :
      {
        Circle( int(random(10,15)),          // Radius of each Circle
                Color[int(random(0,9))],     // Circle's Color
                50,                          // The number of Same Circle
                 5,                          // The space of each Circle
                 0, (Count-1)*28,            // Translation of all Circles
                 1);                         // Scaling of all Circles
        break;
      }
     
      case 6 :
      {
        Diagonal( int(random(15,20)),         // Longth of Diagonal
                  Color[int(random(0,9))],    // Diagonal's Color
                  80,                         // The number of Same Diagonals
                   8,                         // The space of each Diagonal
                   0, (Count-1)*28,           // Translation of all Diagonals
                   1,                         // Scaling of all Diagonals
                   1);                        // Choose different type of Diagonals
        break;
      }
     
      case 7 :
      {
        Rectangle(Color[int(random(0,9))],    // Rectangle's Color
                    0, (Count-1)*28,          // Translation of all rectangles
                    1);                       // Scaling of all rectangles
        break;
      }
     
      case 8 :
      {
        Diamond(random(15,20), random(15,20),   // Width & Height of Diamond
                Color[int(random(0,9))],        // Diamond's Color
                 80,                            // The number of Same Diamonds
                 10,                            // The space of each Diamond
                  0, (Count-1)*28,              // Translation of all diamonds
                  1);                           // Scaling of all diamonds
        break;
      }
    }
  }
}

//----------------------------------------------------------------------------------------
// Fuction_1: Draw Triangle
//----------------------------------------------------------------------------------------
void Triangle(float Bottom, float Height,            // Bottom & Height of Triangle
              color Color,                             // Triangle's Color
              int n,                                 // The number of Same Triangles
              float Space,                           // The space of each Triangles
              float TransX, float TransY,            // Translation of all Triangle
              float Scale,                           // Scaling of all Triangle
              int Switch)                            // Choose different type of Triangles
{
   pushMatrix();
 
   // Translation
   translate(TransX, TransY);
   scale(Scale);
 
   // Contents
   stroke(Color);
   strokeWeight(2);
   fill(Color);
 
   // Repeating
   for (int i=0; i < n; i++)                    
   {
     if (Switch == 1)
     {
      triangle(     0    + i*(Bottom) , Height,    
                Bottom/2 + i*(Bottom) ,   0      
                , Bottom + i*(Bottom) , Height);
     }
   
     if (Switch == 2)
     {
      triangle(     0    + i*(Bottom) , 0,    
                Bottom/2 + i*(Bottom) , Height      
                , Bottom + i*(Bottom) , 0);
     }
   
     if (Switch == 3)
     {
      triangle(     0    + i*(Height) ,   0   ,    
                  Height + i*(Height) , Bottom/2,      
                    0    + i*(Height) , Bottom);
     }
   
     if (Switch == 4)
     {
      triangle(   Bottom   + i*(Height) ,   0   ,    
                    0      + i*(Height) , Bottom/2,      
                  Bottom   + i*(Height) , Bottom );
     }
      translate(Space, 0);
   }
 
   popMatrix();
}

//----------------------------------------------------------------------------------------
// Fuction_2: Draw Circle
//----------------------------------------------------------------------------------------
void Circle(float Radius,                          // Bottom & Height of Triangle
            color Color,                             // Triangle's Color
            int n,                                 // The number of Same Triangles
            float Space,                           // The space of each Triangle
            float TransX, float TransY,            // Translation of all Triangle
            float Scale)                           // Scaling of all Triangle
{
   pushMatrix();
 
   // Translation
   translate(TransX, TransY);
   scale(Scale);
 
   // Contents
   stroke(Color);
   fill(Color);
 
   // Repeating
   for (int i=0; i < n; i++)                    
   {
      ellipse(i*Radius, 10, Radius, Radius);
      translate(Space, 0);
   }
 
   popMatrix();
}

//----------------------------------------------------------------------------------------
// Fuction_3: Draw diagonal
//----------------------------------------------------------------------------------------
void Diagonal(float Longth,                         // Longth of Triangle
              color Color,                          // Diagonal's Color
              int n,                                // The number of Same Diagonals
              float Space,                          // The space of each Diagonal
              float TransX, float TransY,           // Translation of all Diagonals
              float Scale,                          // Scaling of all Diagonals
              int Switch)                           // Choose different type of Diagonals
{
   pushMatrix();
 
   // Translation
   translate(TransX, TransY);
   scale(Scale);
 
   // Contents
   stroke(Color);
   fill(Color);
 
   // Repeating
   for (int i=0; i < n; i++)                    
   {
     if (Switch == 1) line(0, 0, 0+Longth, 0+Longth);
     if (Switch == 2) line(0+Longth, 0, 0, 0+Longth);
      translate(Space, 0);
   }
 
   popMatrix();
}

//----------------------------------------------------------------------------------------
// Fuction_4: Draw rectangle
//----------------------------------------------------------------------------------------

void Rectangle(color Color,                          // rectangle's Color
               float TransX, float TransY,           // Translation of all rectangles
               float Scale)                          // Scaling of all rectangles
{
   pushMatrix();
 
   // Translation
   translate(TransX, TransY);
   scale(Scale);
 
   // Contents
   stroke(Color);
   fill(Color);
 
   // Repeating
   rect(0, 0, width, int(random(5,10)));
 
   popMatrix();
}

//----------------------------------------------------------------------------------------
// Fuction_5: Draw diamond
//----------------------------------------------------------------------------------------

void Diamond(float Bottom, float Height,           // Width & Height of Diamond
             color Color,                          // Diamond's Color
             int n,                                // The number of Same diamonds
             float Space,                          // The space of each Diamond
             float TransX, float TransY,           // Translation of all diamonds
             float Scale)                          // Scaling of all diamonds
{
   pushMatrix();
 
   // Translation
   translate(TransX, TransY);
   scale(Scale);
 
   // Contents
   stroke(Color);
   fill(Color);
 
  PShape diamond;
  diamond = createShape();
  diamond.beginShape();
  diamond.vertex(Bottom/2, 0); //top
  diamond.vertex(0, Height/2); //Left
  diamond.vertex(Bottom/2, Height); //Bottom
  diamond.vertex(0, Height/2);//Right
  diamond.endShape(CLOSE);
 
   // Repeating
   for (int i=0; i < n; i++)                    
   {
     shape(diamond, 0, 0);
     translate(Space, 0);
   }
 
   popMatrix();
}
//// Made by zhangbo0037, 04/01/2017

float alpha = 255;  
  
void setup() 
{
  size(800, 500);
  background(color(218,206,190));
  Draw();
}

void Draw()
{
  pushMatrix();

  translate(0, 200);
  for (int k = 0; k < 5; k++)
  {
    for (int i = 0; i < 15; i++)
    {
      polygon(i*60+random(-5,5)+k*(-30), (k*60+random(-5,5)), 2.5, alpha);
    }
    alpha = alpha + k * (-25);
  }
  popMatrix();
}

void draw() 
{
}

void Color_()
{
  color Color[];
  Color = new color[3];
  Color[0] = color(218,206,190); // Background Color
  Color[1] = color(42,27,34);  // Dark Purple
  Color[2] = color(64,54,107); // Light Purple
}

void  polygon(float TransX, float TransY, float Scale, float Alpha)
{
  pushMatrix();
  
  translate(TransX, TransY);
  scale(Scale);
  strokeWeight(0.05);
  fill(color(42,27,34), Alpha);
  
  float Vertex_1_x = random(5,10);
  float Vertex_1_y = random(-5,5);
  
  float Vertex_2_x = random(-5,5);
  float Vertex_2_y = random(10,20);
  
  float Vertex_3_x = random(10,15);
  float Vertex_3_y = random(15,25);
  
  float Vertex_4_x = random(20,25);
  float Vertex_4_y = random(12,18);
  
  PShape diamond;
  diamond = createShape();
  diamond.beginShape();
  diamond.vertex(Vertex_1_x, Vertex_1_y);    //Top: Vertex_1
  diamond.vertex(Vertex_2_x, Vertex_2_y);    //Left: Vertex_2
  diamond.vertex(Vertex_3_x, Vertex_3_y);    // Bottom: Vertex_3
  diamond.vertex(Vertex_4_x, Vertex_4_y);    // Right: Vertex_4
  diamond.endShape(CLOSE);
  shape(diamond, 0, 0);
  
  strokeWeight(0.05);
  stroke(color(64,54,107), Alpha);
  for (int i = 0; i < random(100,150); i++)
  {
    line(Vertex_1_x + random(-15,15), Vertex_1_y + random(-15,15), Vertex_3_x + random(-15,15), Vertex_3_y + random(-15,15));
  }
  
  for (int i = 0; i < random(100,150); i++)
  {
    line(Vertex_2_x + random(-15,15), Vertex_2_y + random(-15,15), Vertex_4_x + random(-15,15), Vertex_4_y + random(-15,15));
  }
  
  for (int i = 0; i < random(100,150); i++)
  {
    line(Vertex_1_x + random(-15,15), Vertex_1_y + random(-15,15), Vertex_2_x + random(-15,15), Vertex_2_y + random(-15,15));
  }
  
  for (int i = 0; i < random(100,150); i++)
  {
    line(Vertex_3_x + random(-15,15), Vertex_3_y + random(-15,15), Vertex_4_x + random(-15,15), Vertex_4_y + random(-15,15));
  }
  
  for (int i = 0; i < random(100,150); i++)
  {
    line(Vertex_2_x + random(-15,15), Vertex_2_y + random(-15,15), Vertex_3_x + random(-15,15), Vertex_3_y + random(-15,15));
  }
  
  for (int i = 0; i < random(100,150); i++)
  {
    line(Vertex_1_x + random(-15,15), Vertex_1_y + random(-15,15), Vertex_4_x + random(-15,15), Vertex_4_y + random(-15,15));
  }
  popMatrix();
}

2017年3月9日星期四

2017.03.09  프로세싱 수업:

렌덤한 칼러와 위치를 가진 점들을 그려봤습니다.

int centerX, centerY;
float x, y, angle, radius, rad;

void setup()
{
  frameRate(1.5);
  radius=100;
  centerX = width/2;
  centerY = height/2;
  size(1280,720);
  stroke(0);
}

void draw()
{
  background(255);
  for (angle = 0; angle < 360; angle++)
  {
 
    rad = radians(angle);
    x = centerX + 2*(radius * cos(rad) * cos(random(0,720)));
    y = centerY + 2*(radius * sin(rad) * sin(random(0,720)));

    stroke(random(0,255),random(0,255),random(0,255),255);
    strokeWeight(random(0,25));
    point(x,y);
  }
}

2010年6月13日星期日

这个博客的第一个帖子

哈哈 今天申请了个博客 

先写点东西吧 !