The R Project SVN R

Rev

Rev 51096 | Rev 51274 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51096 Rev 51121
Line 1902... Line 1902...
1902
    if (GRecording(call, dd))
1902
    if (GRecording(call, dd))
1903
	GErecordGraphicOperation(op, originalArgs, dd);
1903
	GErecordGraphicOperation(op, originalArgs, dd);
1904
    return R_NilValue;
1904
    return R_NilValue;
1905
}
1905
}
1906
 
1906
 
-
 
1907
SEXP attribute_hidden do_raster(SEXP call, SEXP op, SEXP args, SEXP env)
-
 
1908
{
-
 
1909
    /* raster(image, xl, yb, xr, yt, angle, interpolate, ...) */
-
 
1910
    const void *vmax;
-
 
1911
    unsigned int *image;
-
 
1912
    SEXP raster, dim, sxl, sxr, syb, syt, angle, interpolate;
-
 
1913
    double *xl, *xr, *yb, *yt, x0, y0, x1, y1;
-
 
1914
    int i, n, nxl, nxr, nyb, nyt;
-
 
1915
    SEXP originalArgs = args;
-
 
1916
    pGEDevDesc dd = GEcurrentDevice();
-
 
1917
 
-
 
1918
    if (length(args) < 7) error(_("too few arguments"));
-
 
1919
    GCheckState(dd);
-
 
1920
 
-
 
1921
    raster = CAR(args); args = CDR(args);
-
 
1922
    n = LENGTH(raster);
-
 
1923
    dim = getAttrib(raster, R_DimSymbol);
-
 
1924
 
-
 
1925
    vmax = vmaxget();
-
 
1926
    image = (unsigned int*) R_alloc(n, sizeof(unsigned int));
-
 
1927
    for (i=0; i<n; i++) {
-
 
1928
        image[i] = RGBpar3(raster, i, R_TRANWHITE);
-
 
1929
    }
-
 
1930
 
-
 
1931
    xypoints(call, args, &n);
-
 
1932
    if(n == 0) return R_NilValue;
-
 
1933
 
-
 
1934
    sxl = CAR(args); nxl = length(sxl); args = CDR(args);/* x_left */
-
 
1935
    syb = CAR(args); nyb = length(syb); args = CDR(args);/* y_bottom */
-
 
1936
    sxr = CAR(args); nxr = length(sxr); args = CDR(args);/* x_right */
-
 
1937
    syt = CAR(args); nyt = length(syt); args = CDR(args);/* y_top */
-
 
1938
 
-
 
1939
    angle = CAR(args); args = CDR(args);
-
 
1940
    interpolate = CAR(args); args = CDR(args);
-
 
1941
 
-
 
1942
    GSavePars(dd);
-
 
1943
    ProcessInlinePars(args, dd, call);
-
 
1944
 
-
 
1945
    xl = REAL(sxl);
-
 
1946
    xr = REAL(sxr);
-
 
1947
    yb = REAL(syb);
-
 
1948
    yt = REAL(syt);
-
 
1949
 
-
 
1950
    GMode(1, dd);
-
 
1951
    for (i = 0; i < n; i++) {
-
 
1952
	x0 = xl[i%nxl];
-
 
1953
	y0 = yb[i%nyb];
-
 
1954
	x1 = xr[i%nxr];
-
 
1955
	y1 = yt[i%nyt];
-
 
1956
	GConvert(&x0, &y0, USER, DEVICE, dd);
-
 
1957
	GConvert(&x1, &y1, USER, DEVICE, dd);
-
 
1958
	if (R_FINITE(x0) && R_FINITE(y0) && R_FINITE(x1) && R_FINITE(y1))
-
 
1959
           GRaster(image, INTEGER(dim)[1], INTEGER(dim)[0], 
-
 
1960
                   x0, y0, x1 - x0, y1 - y0,
-
 
1961
                   REAL(angle)[i % LENGTH(angle)],
-
 
1962
                   LOGICAL(interpolate)[i % LENGTH(interpolate)], dd);
-
 
1963
    }
-
 
1964
    GMode(0, dd);
-
 
1965
 
-
 
1966
    GRestorePars(dd);
-
 
1967
    /* NOTE: only record operation if no "error"  */
-
 
1968
    if (GRecording(call, dd))
-
 
1969
	GErecordGraphicOperation(op, originalArgs, dd);
-
 
1970
 
-
 
1971
    vmaxset(vmax);
-
 
1972
    return R_NilValue;
-
 
1973
}
-
 
1974
 
1907
 
1975
 
1908
SEXP attribute_hidden do_arrows(SEXP call, SEXP op, SEXP args, SEXP env)
1976
SEXP attribute_hidden do_arrows(SEXP call, SEXP op, SEXP args, SEXP env)
1909
{
1977
{
1910
    /* arrows(x0, y0, x1, y1, length, angle, code, col, lty, lwd, ...) */
1978
    /* arrows(x0, y0, x1, y1, length, angle, code, col, lty, lwd, ...) */
1911
    SEXP sx0, sx1, sy0, sy1, col, lty, lwd;
1979
    SEXP sx0, sx1, sy0, sy1, col, lty, lwd;