HtmlRotatableImage: Trial class for generating rotatable HTML images using...

Description Usage Arguments Details Fields and Methods Author(s) Examples

Description

Package: R.io
Class HtmlRotatableImage

Object
~~|
~~+--HtmlRotatableImage

Directly known subclasses:

public static class HtmlRotatableImage
extends Object

Trial class for generating rotatable HTML images using javascript.

Usage

1
HtmlRotatableImage(imagename=NULL, rows=0, cols=0, width=NULL, height=NULL, figurePath="figures/")

Arguments

imagename
rows
cols
width,height

Width and height in pixels of the generated images.

figurePath

Pathname where images should be written.

Details

The generated HTML and the JavaScript is known to work on Microsoft Internet Explorer v6.0, Netscape Navigator v4.0 and v6, and Opera v4.02. It does not work on Netscape Navigator 3.04. This does not mean that it does not work on other web browser, just that they have not been tested by the author.

The generated code passes the WDG HTML Validator (http://www.htmlhelp.com/tools/validator/) without warnings or errors, except for the attribute name in the HTML tag <img>. The standard says id should be used, but that tag is not supported by Javascript for all browsers (or at least I can't get it to work).

Fields and Methods

Methods:

currentImageExists -
getHtmlImgTag -
getHtmlMapTag -
getHtmlScriptTag -
getImageName -
getImageNames -
getMapName -
getPreloadJSCode -
getProgress -
nbrOfImages -
ncol -
nrow -
start -
step -
writeCurrentImage -

Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clone, detach, equals, extend, finalize, gc, getEnvironment, getFields, getInstanciationTime, getStaticInstance, hasField, hashCode, ll, load, objectSize, print, save

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Not run: filename <- "HtmlRotatableImage.html";
fout <- FileOutputStream(filename)
out <- HtmlPrintStream(fout)
phis <- seq(from=-30, to=30, by=15);
thetas <- seq(from=0, to=360, by=30);
img <- HtmlRotatableImage("img.png", rows=phis, cols=thetas)

# Create the HTML document with the required Javascript
writeDocType(out)
pushTag(out, "html")
pushTag(out, "head")
printTag(out, "title", "Output from example(HtmlImageRotator)")
printTag(out, "meta", "http-equiv"="Content-Type", content="text/html;")
print(out, getHtmlScriptTag(img))
popTag(out)
pushTag(out, "body", onLoad=getPreloadJSCode(img))
print(out, getHtmlImgTag(img))
print(out, getHtmlMapTag(img))
popTags(out)
close(out)


# Create the images to loaded by the HTML document
x <- seq(-10, 10, length=50)
y <- x
f <- function(x,y) {
  r <- sqrt(x^2+y^2)
  10 * sin(r)/r
}
z <- outer(x, y, f)
z[is.na(z)] <- 1

dphi <- 45 / nrow(img);
dtheta <- 360 / (ncol(img)+1);

start(img);
for (k in seq(nbrOfImages(img))) {
  if (!currentImageExists(img)) {
    phitheta <- step(img);
    phi <- phitheta[1];
    theta <- phitheta[2];
    cat("phi=", phi, ", theta=", theta, "\n", sep="");
    par(bg = "white")
    persp(x, y, z, theta=theta, phi=phi, expand=0.5, col="lightblue",
          ltheta=120, shade=0.75, ticktype="detailed",
          xlab="X", ylab="Y", zlab="Z")
    writeCurrentImage(img);
  }
  cat(floor(100*getProgress(img)), ", ", sep="")
}


## End(Not run)

HenrikBengtsson/R.io documentation built on May 6, 2019, 11:54 p.m.