svgR

A Ubuntu logo. Skip to output

  S<-100 #seperation between centers
  R<-c(0.4,0.95)*S # arc radii: require 0< R[1]< R[2]
  r<-S * c(0.24,0.4) # require: 1-R[1]> r[2] >1-R[2] ( or R[1]<1-r[2]<R[2] ); 0<r[1]<r[2]
  Gap<-.1*S #space between arcs
  theta<-asin(Gap/R)
  XY1<-t(diag(R) %*% cbind(cos(theta),sin(theta)))  #rows are the starting points of arc
  XY2<-t(diag(R) %*% cbind(cos(2*pi/3-theta),sin(2*pi/3-theta))) #rows are ending points of arc  
  d.eta= acos( (S^2 + r[2]^2 - (R[2]^2))/(2*S*r[2]) ) 
  eta<- -2*pi/3 + d.eta*c(-1,1)
  cxy<- + S*c(cos(pi/3),sin(pi/3)) #center of satellite
  xy1<-cxy + t(r[2]*cbind(cos(eta), sin(eta)))
   
  WH<-c(800,400)
  svgR( wh=WH,
    defs(
      path( id="arc", d=list(M=XY1[,1], 
                             L=XY1[,2], 
                             A=c( c(R[2],R[2]), 0,  0, 1 , xy1[,2] ) , 
                             A=c( c(r[2],r[2]), 0,  0, 0 , xy1[,1] ) , 
                             A=c( c(R[2],R[2]), 0,  0, 1 , XY2[,2] ) ,                  
                             L=XY2[,1], 
                             A=c( c(R[1],R[1]), 0,  0, 0 , XY1[,1] ) ,
                             Z=0),
            stroke="black", stroke.width="3" ),
      circle(id="satellite", cxy=cxy, r=r[1], stroke="black"),     
      g( id='ubuntu',
         g(  transform=list(translate=WH/2 ,rotate=0) , 
             use( "xlink:href"="#arc", fill="red"),
             use( "xlink:href"="#satellite", fill="yellow")
         ),
         g(  transform=list(translate=WH/2 ,rotate=120) , 
             use( "xlink:href"="#arc", fill="yellow"),
             use( "xlink:href"="#satellite", fill="orange")
         ),
         g(  transform=list(translate=WH/2 ,rotate=240) , 
             use( "xlink:href"="#arc", fill="orange"),
             use( "xlink:href"="#satellite", fill="red")
         )       
      )
    ), 
    use( "xlink:href"="#ubuntu",  
      filter=filter(  height=1.5, #shadow
        feComposite( operator='over',
          in1='SourceGraphic',
          in2=feOffset( dxy=c(5,5),
            in1=feGaussianBlur(  stdDeviation=6,
              in1='SourceAlpha' 
            )
          )
        )
      )
    ),
    use( "xlink:href"="#ubuntu",  
      filter=filter( #emboss
        feComposite(   operator='in',
          in1=feSpecularLighting(  surfaceScale=-3, style='lighting-color:white', specularConstant=1, 
                specularExponent=16,  kernelUnitLength=1,
                feDistantLight(azimuth=45, elevation=45),
                in1=feGaussianBlur( in1='SourceAlpha', stdDeviation=2)
          ), 
          in2='SourceGraphic'
        )
      )
    )
  )