[Rd] R logo as SVG ?

Henrik Bengtsson hb at stat.berkeley.edu
Wed Mar 3 17:42:24 CET 2010


My Wednesday procrastination:

There's quite some number of decimals in the SVG and some whitespace,
so some dummy trimming gives:

x <- readLines("http://developer.r-project.org/Logo/Rlogo-1.svg");
nx <- sum(nchar(x))+length(x);

for (kk in 2:0) {
  # Keep only K decimals
  pattern <- sprintf("([0-9]+)\\.([0-9]{%d})([0-9]*)", kk);
  y <- gsub(pattern, "\\1.\\2", x);
  # Drop trailing zeros
  y <- gsub("([0-9]+)\\.([1-9]+)(0+)([^0])", "\\1.\\2\\4", y);
  # Drop trailing periods
  y <- gsub("([0-9]+)\\.([, \"])", "\\1\\2", y);
  # Trim white space
  y <- gsub("^[ ]+", "", y);
  y <- gsub("[ ]+\\/>", "/>", y);

  # Keep first line as is
  y[1] <- x[1];
  # Write to file
  pathname <- sprintf("Rlogo-1,trimmed,%d.svg", kk);
  bfr <- paste(y, collapse="\n");
  bfr <- charToRaw(bfr);
  ny <- length(bfr);
  writeBin(bfr, con=pathname);
  cat(sprintf("%d bytes (%.1f%%)\n", ny, 100*ny/nx));
} # for (kk ...)

gives

36694 bytes (74.3%)
32766 bytes (66.3%)
23981 bytes (48.5%)

Not easy to see any differences between these and the original one.

/Henrik

On Tue, Mar 2, 2010 at 5:46 PM, Jens Elkner <jel+r at cs.uni-magdeburg.de> wrote:
> On Mon, Mar 01, 2010 at 10:16:16PM +0100, Peter Dalgaard wrote:
>> >Jens Elkner wrote:
> ...
>> >>BTW: screenshots I made from my desktop are available via
>> >>http://iws.cs.uni-magdeburg.de/~elkner/r/
> ...
>> >Looks quite nice. I later realized that it would be a much better idea
>> >to start by tracing the highest resolution bitmap from
>> >
>> >http://developer.r-project.org/Logo
>> >
>> >I now have a version that is only 48 K. It still needs a little touching
>> >up to get a transparent background without destroying the highlighted
>> >regions. I'm attaching it here, but it might not make it to r-devel.
>
> Good work!!!
>
> Still looks ok for me (so less is more ;-)). Added screenshots to
> the URL above (new 49K based ones have a '2' at the end). For your
> convinience/easier comparision I tied them together:
> http://iws.cs.uni-magdeburg.de/~elkner/r/menu.html
> http://iws.cs.uni-magdeburg.de/~elkner/r/nautilus.html
>
> Regards,
> jel.
> --
> Otto-von-Guericke University     http://www.cs.uni-magdeburg.de/
> Department of Computer Science   Geb. 29 R 027, Universitaetsplatz 2
> 39106 Magdeburg, Germany         Tel: +49 391 67 12768
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list