---
# System prepended metadata

title: Учебная практика. Среда 20.06.2021. Федяева Евгения Игоревна

---

# Учебная практика. Среда 20.06.2021. Федяева Евгения Игоревна

1. Присутствовала на лекции.
2. [Смешарик](https://www.shadertoy.com/view/7lfXzr)
```
    float Circle(vec2 xy, float r, vec2 pos)
    {
        float d = length(xy-pos);
          float cl = smoothstep(r, r-0.008, d);
            return cl;
    }
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 xy = fragCoord.xy/iResolution.xy;
    xy -= 0.5;
      xy.x *= iResolution.x/iResolution.y;
      float sm = Circle(xy, 0.23, vec2(0.0, -0.1)); //body
        sm -= Circle(xy, 0.05, vec2(0.06, -0.06)); //eye
        sm -= Circle(xy, 0.045, vec2(-0.06, -0.06)); //eye
        sm -= Circle(xy, 0.03, vec2(0.0, -0.12)); //nose
        sm += Circle(xy, 0.022, vec2(0.08, -0.06));
        sm += Circle(xy, 0.02, vec2(-0.045, -0.06));
      xy.x /= iResolution.y/(2.0*iResolution.x);
        sm = max(sm, Circle(xy, 0.18, vec2(0.25, 0.28))); //ear
        sm = max(sm, Circle(xy, 0.18, vec2(-0.25, 0.28))); //ear
        sm = max(sm, Circle(xy, 0.08, vec2(0.87, -0.1))); //hand
        sm = max(sm, Circle(xy, 0.08, vec2(-0.87, -0.1))); //hand  
      xy.x /= 4.0*iResolution.x/iResolution.y;
        sm = max(sm, Circle(xy, 0.04, vec2(0.08, -0.3))); //leg
        sm = max(sm, Circle(xy, 0.04, vec2(-0.08, -0.3))); //leg
   
          vec3 pic = vec3(0.2, 0.7, 1.0)*sm;
            fragColor = vec4(pic, 1.0);
}
```
За основу рисунка взят круг, как и в случае с чебурашкой. Смешарик создается сложением(вычитанием) различных кругов, а также с помощью операции `max`.
3. [Имя и фамилия](https://www.shadertoy.com/view/NlfXzr)
```
    float Q(float x, float y, float r)
    {
        return max(abs(x),abs(y)) - r ; 
    }
    mat2 rotate(float ang) 
    {
        return mat2(cos(ang),-sin(ang),
                    sin(ang),cos(ang));
    }
    float E(vec2 p, float ax, float ay)
    {
        float c = Q((p.x - ax) / 2.0, p.y + ay, 0.035) * 100.0;
          c = min(c, Q((p.x - ax) / 2.0, p.y + ay + 0.2, 0.035) * 100.0); 
          c = min(c, Q((p.x - ax) / 2.0, p.y + ay - 0.2, 0.035) * 100.0);
          c = min(c, Q((p.x - ax - 0.06) * 1.5, (p.y + ay) / 7.0, 0.035) * 100.0);
            return c; 
    }  
    float V(vec2 p, float ax1, float ay1, float ax2, float ay2)
    {
        vec2 pos = rotate(radians(-80.0)) * p;
          float c = Q((pos.x + ax1) / 9.0, pos.y + ay1, 0.03) * 100.0;
        pos = rotate(radians(80.0)) * p;
          c = min(c, Q((pos.x + ax2) / 9.0, pos.y + ay2, 0.03) * 100.0);
            return c;
    }
    float G(vec2 p, float ax, float ay)
    {
        float c = Q((p.x - ax + 0.06) / 1.4, p.y + ay, 0.035) * 100.0;
          c = min(c, Q((p.x - ax) / 2.0, p.y + ay + 0.2, 0.035) * 100.0); 
          c = min(c, Q((p.x - ax) / 2.0, p.y + ay - 0.2, 0.035) * 100.0);
          c = min(c, Q((p.x - ax - 0.06) * 1.5, (p.y + ay) / 7.0, 0.035) * 100.0);
          c = min(c, Q((p.x - ax + 0.045) / 0.6, (p.y + ay + 0.15) / 2.0, 0.035) * 100.0);
          c = min(c, Q((p.x - ax + 0.05) / 0.6, (p.y + ay - 0.1) / 3.0, 0.035) * 100.0);  
            return c; 
    } 
    float N(vec2 p, float ax, float ay)
    {
        float c = Q((p.x - ax - 0.06) * 1.5, (p.y + ay) / 7.5, 0.035) * 100.0;
          c = min(c, Q((p.x - ax + 0.1) * 1.5, (p.y + ay) / 7.5, 0.035) * 100.0);
        vec2 pos = rotate(radians(-76.0)) * p;
          c = min(c, Q((pos.x -0.43) / 9.5, pos.y + 0.36, 0.03) * 100.0);
            return c; 
    } 
    float I(vec2 p, float ax, float ay)
    {
        float c = Q((p.x - ax - 0.06) * 1.5, (p.y + ay) / 7.3, 0.035) * 100.0;
          c = min(c, Q((p.x - ax - 0.06) * 1.5, (p.y + ay + 0.33) / 1.0, 0.035) * 100.0);
            return c;
    }
    float A(vec2 p, float ax1, float ay1, float ax2, float ay2, float ax3, float ay3)
    {
        vec2 pos = rotate(radians(-80.0)) * p;
          float c = Q((pos.x + ax1) / 9.0, pos.y + ay1, 0.03) * 100.0;
        pos = rotate(radians(80.0)) * p;
          c = min(c, Q((pos.x + ax2) / 9.0, pos.y + ay2, 0.03) * 100.0);
          c = min(c, Q((p.x + ax3) / 1.8, p.y + ay3, 0.035) * 100.0);
            return c;
    }
    float F(vec2 p, float ax, float ay)
    {
        float c = Q((p.x - ax) / 2.0, p.y + ay, 0.035) * 100.0;
          c = min(c, Q((p.x - ax) / 2.0, p.y + ay + 0.2, 0.035) * 100.0); 
          c = min(c, Q((p.x - ax - 0.06) * 1.5, (p.y + ay) / 7.0, 0.035) * 100.0);
            return c; 
    }  
    float D(vec2 p, float ax, float ay)
    {
        float c = Q((p.x - ax - 0.02) / 1.8, p.y + ay + 0.2, 0.035) * 100.0;           
          c = min(c, Q((p.x - ax - 0.02) / 1.8, p.y + ay - 0.2, 0.035) * 100.0);
          c = min(c, Q((p.x - ax - 0.06) * 1.5, (p.y + ay) / 7.0, 0.035) * 100.0);
          c = min(c, Q((p.x - ax + 0.04) * 1.5, (p.y + ay) / 6.0, 0.035) * 100.0);
            return c; 
    }  
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 p = 1.0 - 2.0 * fragCoord/iResolution.xy;   

    float c = E(p, 0.7, 0.5);
      c = min(c, V(p, -0.58, -0.43, 0.42, 0.52));
      c = min(c, G(p, 0.24, 0.5));
      c = min(c, E(p, 0.0, 0.5));
      c = min(c, N(p, -0.22, 0.5));
      c = min(c, I(p, -0.5, 0.5));
      c = min(c, I(p, -0.62, 0.5));
      c = min(c, A(p, -0.35, 0.9, 0.62, -0.62, 0.76, 0.5));
      c = min(c, F(p, 0.85, -0.2));
      c = min(c, E(p, 0.65, -0.2));
      c = min(c, D(p, 0.45, -0.2));
      c = min(c, I(p, 0.25, -0.2));
      c = min(c, A(p, 0.17, -0.12, -0.22, 0.15, -0.15, -0.2));
      c = min(c, I(p, -0.1, -0.2));
      c = min(c, E(p, -0.2, -0.2));
      c = min(c, V(p, 0.26, 0.34, -0.11, -0.49));
      c = min(c, A(p, 0.325, 0.69, -0.09, -0.65, 0.68, -0.2));
    
        vec3 pic = vec3(1.0, 1.0, 0.0)*(-c);
          fragColor = vec4(pic, 1.0);
}
```
Основной фигурой является прямоугольник. Буква представляет собой композицию различных прямоугольников. Для каждой уникальной буквы описана своя функция, задающая её, для облегчения составления слов, так как некоторые буквы повторяются.
4. [Портрет](https://www.shadertoy.com/view/7lsSzr)
```
float max_of_three(float a, float b, float c)
    {
        return max(a,max(b,c));
    }
             
        float L(vec2 p, vec2 P0, vec2 P1)
        {
                float a = -(P1.y-P0.y);
                float b =  (P1.x-P0.x);
                float d =  P0.x*P1.y- P0.y*P1.x; 
                float x = p.x;
                float y = p.y;
                
                 return a*x + b*y + d;
        }
    
    float T(vec2 p, vec2 P0, vec2 P1, vec2 P2)
    {
        return  max_of_three(
                   L(p, P0, P1),
                   L(p, P1, P2), 
                   L(p, P2, P0)
                   );   
    }

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
//  digitalized my profile                      
 vec2 P[62];
       P[ 0] = vec2(0.8966 ,    	0.90457);
       P[ 1] = vec2(0.83835,     	0.94749);
       P[ 2] = vec2(0.74804,     	0.97120);
       P[ 3] = vec2(0.60602,     	0.97572);
       P[ 4] = vec2(0.4928 ,    	0.96725);
       P[ 5] = vec2(0.4038 ,    	0.95144);
       P[ 6] = vec2(0.38416,     	0.92716);
       P[ 7] = vec2(0.31806,     	0.88481);
       P[ 8] = vec2(0.25131,     	0.83682);
       P[ 9] = vec2(0.22448,     	0.80632);
       P[10] = vec2(0.20484,     	0.76906);
       P[11] = vec2(0.18194,     	0.70920);
       P[12] = vec2(0.17343,     	0.67871);
       P[13] = vec2(0.1623 ,    	0.67476);
       P[14] = vec2(0.16492,     	0.65951);
       P[15] = vec2(0.17277,     	0.64766);
       P[16] = vec2(0.1695 ,    	0.60757);
       P[17] = vec2(0.17147,     	0.58837);
       P[18] = vec2(0.17081,     	0.57199);
       P[19] = vec2(0.1538 ,    	0.55167);
       P[20] = vec2(0.11453,     	0.50536);
       P[21] = vec2(0.098822,     	0.48447);
       P[22] = vec2(0.088351,     	0.47149);
       P[23] = vec2(0.085733,     	0.45850);
       P[24] = vec2(0.092277,     	0.44212);
       P[25] = vec2(0.11584,     	0.42292);
       P[26] = vec2(0.13809,     	0.41728);
       P[27] = vec2(0.14529,     	0.40599);
       P[28] = vec2(0.14725,     	0.39074);
       P[29] = vec2(0.13743,     	0.38340);
       P[30] = vec2(0.12696,     	0.37719);
       P[31] = vec2(0.13089,     	0.36533);
       P[32] = vec2(0.14202,     	0.35347);
       P[33] = vec2(0.14463,     	0.34557);
       P[34] = vec2(0.13874,     	0.33540);
       P[35] = vec2(0.13416,     	0.31903);
       P[36] = vec2(0.14332,     	0.30491);   
       P[37] = vec2(0.15641,     	0.29814);
       P[38] = vec2(0.16099,     	0.28176);
       P[39] = vec2(0.15903,     	0.25861);
       P[40] = vec2(0.1538 ,    	0.24111);
       P[41] = vec2(0.15641,     	0.22021);
       P[42] = vec2(0.1767 ,    	0.19989);
       P[43] = vec2(0.20681,     	0.18521);
       P[44] = vec2(0.25785,     	0.17956);
       P[45] = vec2(0.31872,     	0.18012);   
       P[46] = vec2(0.37435,     	0.17335);
       P[47] = vec2(0.41623,     	0.13043);
       P[48] = vec2(0.44372,     	0.098814);
       P[49] = vec2(0.45681,     	0.061547);
       P[50] = vec2(0.47055,     	0.023151);
       P[51] = vec2(0.48429,     	-0.0062112);

    vec2 p = 1.0 - 2.0* fragCoord/iResolution.xy;
    vec2 m = 1.0 - 2.0* iMouse.xy/iResolution.xy;

     float x = p.x * iResolution.x/iResolution.y;
     float y = p.y ;
     
     float mx = m.x * iResolution.x/iResolution.y;
     float my = m.y ;
           
       x/=mx;
       y/=my;
            
         p.x=x;
         p.y=y;
   

      float  z = 1.0e25;
              for(int i=0;i<51-3;i++)
                z = min(z, T(p,  P[i],P[i+1], P[i+3]) );   
       float     f = 1.25/z; 

               vec3 col = vec3(1.0, 1.0, 1.0);
                if(f >= 0.0)col.g = sin(iTime/10.0);
                   else     col.r = f;
                     fragColor = vec4(col,1.0);
}
```
Координаты точек получены с помощью ресурса https://open-graphics-service.glitch.me/ . Положение портрета менятеся в зависимости от положения мыши.