This is the code for a rounded square, I wonder if it could get the one for a squircle, which is a very similar figure.
The Wikipedia states that:
Although constructing a rounded square may be conceptually and physically simpler, the squircle has the simpler equation and can be generalised much more easily.
{
x<-c(1,1,0,0)
y<-c(1,0,0,1)
rad <- max(x)/7
ver<-25
yMod<-y
yMod[which(yMod==max(yMod))]<-yMod[which(yMod==max(yMod))]-rad
yMod[which(yMod==min(yMod))]<-yMod[which(yMod==min(yMod))]+rad
topline_y<-rep(max(y),2)
topBotline_x<-c(min(x)+rad, max(x)-rad)
bottomline_y<-rep(min(y),2)
pts<- seq(-pi/2, pi*1.5, length.out = ver*4)
ptsl<-split(pts, sort(rep(1:4, each=length(pts)/4, len=length(pts))) )
xy_1 <- cbind( (min(x)+rad) + rad * sin(ptsl[[1]]), (max(y)-rad) + rad * cos(ptsl[[1]]))
xy_2 <- cbind( (max(x)-rad) + rad * sin(ptsl[[2]]), (max(y)-rad) + rad * cos(ptsl[[2]]))
xy_3 <- cbind( (max(x)-rad) + rad * sin(ptsl[[3]]), (min(y)+rad) + rad * cos(ptsl[[3]]))
xy_4 <- cbind( (min(x)+rad) + rad * sin(ptsl[[4]]), (min(y)+rad) + rad * cos(ptsl[[4]]))
newLongx<-c(x[1:2] ,xy_3[,1],topBotline_x,xy_4[,1], x[3:4], xy_1[,1],topBotline_x,xy_2[,1])
newLongy<-c(yMod[1:2],xy_3[,2],bottomline_y,xy_4[,2], yMod[3:4], xy_1[,2],topline_y ,xy_2[,2])
par(pty="s")
plot.new()
polygon(newLongx,newLongy, col="red")
}