struct SDF {

float dot2(float2 a)
{
  return dot(a,a);
}

float circle(float2 p, float r)
{
  return length(p) - r;
}

// p = uv point
// b = width,height
// r = roundedness of the 4 corners
float rounded_box(float2 p, float2 b, float4 r)
{
  r.xy = (p.x>0.0)?r.xy : r.zw;
  r.x  = (p.y>0.0)?r.x  : r.y;
  float2 q = abs(p)-b+r.x;
  return min(max(q.x,q.y),0.0) + length(max(q,0.0)) - r.x;
}

float box(float2 p, float2 b)
{
  float2 d = abs(p)-b;
  return length(max(d,0)) + min(max(d.x,d.y),0);
}

float heart( in float2 p )
{
  p.x = abs(p.x);

  if( p.y+p.x>1.0 )
    return sqrt(dot2(p-float2(0.25,0.75))) - sqrt(2.0)/4.0;
    
  return sqrt(min(dot2(p-float2(0.00,1.00)), dot2(p-0.5*max(p.x+p.y,0.0)))) * sign(p.x-p.y);
}
};

SDF sdf;