PPT.AddShape | R Documentation |
Add various shapes to a slide. YOu can position it and modify a limited number of aspects of its appearance (color etc.). However, not all the parameters for all shapes can be implemented.
PPT.AddShape(
ppt,
shape.type = 1,
top = 0.05,
left = 0.05,
width = 0.9,
height = 0.9,
fill.color = "grey",
fill.transparency = 0,
line.color = "black",
line.type = 1,
line.size = 1,
maxscale = 1,
newslide = FALSE
)
ppt |
The ppt object as used in R2PPT. |
shape.type |
The shape to add. The possible types are documented in the
|
top, left |
Vertical and horizontal placement of the shape. Either as
fraction of slides dimensions or as pixel value. Values bigger than
|
width, height |
Dimensions of shape. For values smaller than
|
fill.color |
Background color either as hex value or R color name. |
fill.transparency |
Transparency of filling ( |
line.color |
Color of text either as hex value or color name. |
line.type |
|
line.size |
Thickness of line (default |
maxscale |
Threshold below which values are interpreted as proportional
scaling factors for the |
newslide |
Logical (default is |
Mark Heckmann
## Not run:
# open new PPT presentation
p <- PPT.Init(visible=T, method = "RDCOMClient")
## EXAMPLE 1 ##
# Look up the shape type number in the "MsoAutoShapeType enumeration".
# It is one integer, e.g. rectangle = 1, just google it.
p <- PPT.AddBlankSlide(p)
# add a rectangle
p <- PPT.AddShape(p, shape.type= 1, height=.4, width =.4, left=.05, top=.05)
# add a rounded rectangle
p <- PPT.AddShape(p, shape.type= 5, height=.4, width =.4, left=.05, top=.55)
# add a triangle
p <- PPT.AddShape(p, shape.type= 7, height=.4, width =.4, left=.55, top=.05)
# add a smiley
p <- PPT.AddShape(p, shape.type= 17, height=.4, width =.4, left=.55, top=.55)
## EXAMPLE 2 ##
# add many type of shapes on one slide in two loops to get an
# overview what shapes exist. The fill and line parameters are
# randomly modified to get a variety of shapes.
p <- PPT.AddBlankSlide(p)
cols <- colors() # all named R colors
i <- 0 # counter
set.seed(0) # make sampling redproducible
# loop over left and top to alter position of shape
for ( left in seq(.05, .85, by=.1) ) {
for ( top in seq(.05, .85, by=.1) ) {
i <- i + 1
p <- PPT.AddShape(p,
shape.type= i, # go though shapes one by one 1,2,....
height=.08, width =.08, # height and width of shape
left=left, top=top, # shape position is modified in each loop
fill.transparency = sample(c(0,.3, .7), 1), # use different transparencies
fill.color = cols[i], # go through all colors for filling
line.color = sample(cols, 1), # random line color
line.size = sample(1:30/10, 1), # random line size
line.type = sample(1:8, 1) # random line type
)
}
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.