The R Project SVN R

Rev

Rev 81097 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 81097 Rev 83917
Line 10... Line 10...
10
        y <- y + unit(rev(seq(n)) - mean(seq(n)), "lines")
10
        y <- y + unit(rev(seq(n)) - mean(seq(n)), "lines")
11
    }
11
    }
12
    grid.text(lines, y=y, gp=gpar(fontfamily="HersheySans"))
12
    grid.text(lines, y=y, gp=gpar(fontfamily="HersheySans"))
13
}
13
}
14
 
14
 
-
 
15
devMask <- function(aMask, lMask) {
-
 
16
    support <- dev.capabilities()$masks
-
 
17
    if (is.character(support)) {
-
 
18
        if ("alpha" %in% support) {
-
 
19
            aMask
-
 
20
        } else {
-
 
21
            if ("luminance" %in% support) {
-
 
22
                as.mask(lMask, type="luminance")
-
 
23
            } else {
-
 
24
                FALSE
-
 
25
            }
-
 
26
        }
-
 
27
    } else {
-
 
28
        FALSE
-
 
29
    }
-
 
30
}
-
 
31
 
15
################################################################################
32
################################################################################
16
## Paths that produce same result as normal drawing
33
## Paths that produce same result as normal drawing
17
 
34
 
18
grid.newpage()
35
grid.newpage()
19
grid.stroke(circleGrob())
36
grid.stroke(circleGrob())
Line 188... Line 205...
188
clipped by circle path
205
clipped by circle path
189
result is two half-moons", .8)
206
result is two half-moons", .8)
190
    
207
    
191
## path that is masked
208
## path that is masked
192
grid.newpage()
209
grid.newpage()
193
pushViewport(viewport(mask=circleGrob(r=.2, gp=gpar(fill="black"))))
210
pushViewport(viewport(mask=devMask(circleGrob(r=.2, gp=gpar(fill="black")),
-
 
211
                                   circleGrob(r=.2, gp=gpar(col="white",
-
 
212
                                                            fill="white")))))
194
grid.fill(circleGrob(1:2/3, r=.1), gp=gpar(fill="grey"))
213
grid.fill(circleGrob(1:2/3, r=.1), gp=gpar(fill="grey"))
195
popViewport()
214
popViewport()
196
HersheyLabel("filled path (two circles)
215
HersheyLabel("filled path (two circles)
197
masked by filled circle 
216
masked by filled circle 
198
result is two half-moons", .8)
217
result is two half-moons", .8)