From hb at stat.berkeley.edu  Wed Mar  3 17:42:24 2010
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Wed, 3 Mar 2010 17:42:24 +0100
Subject: [Rd] R logo as SVG ?
In-Reply-To: <20100302164627.GA5157@grex.cs.uni-magdeburg.de>
References: <4B80313D.1000909@biostat.ku.dk> <4B82753B.2090006@biostat.ku.dk>
	<20100227023844.GA1272@trex.cs.uni-magdeburg.de>
	<4B88E35F.3010805@biostat.ku.dk>
	<20100227185533.GA3602@trex.cs.uni-magdeburg.de>
	<de4e29f51002271123s2ae805cex8b6d71d98ba62d8f@mail.gmail.com>
	<20100301180915.GA11344@grex.cs.uni-magdeburg.de>
	<4B8C0BC9.3050903@biostat.ku.dk> <4B8C2EA0.5050901@biostat.ku.dk>
	<20100302164627.GA5157@grex.cs.uni-magdeburg.de>
Message-ID: <59d7961d1003030842h86e3808h77d3875d040a8ac4@mail.gmail.com>

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
>



[Rd] R logo as SVG ?
Henrik Bengtsson