@@ -436,16 +436,19 @@ element_render <- function(theme, element, ..., name = NULL) {
436
436
437
437
# ' Generate grid grob from theme element
438
438
# '
439
+ # ' The `element_grob()` function is vestigial and `draw_element()` should
440
+ # ' be used instead.
441
+ # '
439
442
# ' @param element Theme element, i.e. `element_rect` or similar.
440
443
# ' @param ... Other arguments to control specific of rendering. This is
441
444
# ' usually at least position. See the source code for individual methods.
442
445
# ' @keywords internal
443
446
# ' @export
444
- element_grob <- S7 :: new_generic(" element_grob " , " element" )
447
+ draw_element <- S7 :: new_generic(" draw_element " , " element" )
445
448
446
- S7 :: method(element_grob , element_blank ) <- function (element , ... ) zeroGrob()
449
+ S7 :: method(draw_element , element_blank ) <- function (element , ... ) zeroGrob()
447
450
448
- S7 :: method(element_grob , element_rect ) <-
451
+ S7 :: method(draw_element , element_rect ) <-
449
452
function (element , x = 0.5 , y = 0.5 , width = 1 , height = 1 ,
450
453
fill = NULL , colour = NULL ,
451
454
linewidth = NULL , linetype = NULL , linejoin = NULL ,
@@ -464,7 +467,7 @@ S7::method(element_grob, element_rect) <-
464
467
rectGrob(x , y , width , height , gp = modify_list(element_gp , gp ), ... )
465
468
}
466
469
467
- S7 :: method(element_grob , element_text ) <-
470
+ S7 :: method(draw_element , element_text ) <-
468
471
function (element , label = " " , x = NULL , y = NULL ,
469
472
family = NULL , face = NULL , colour = NULL , size = NULL ,
470
473
hjust = NULL , vjust = NULL , angle = NULL , lineheight = NULL ,
@@ -492,7 +495,7 @@ S7::method(element_grob, element_text) <-
492
495
margin_x = margin_x , margin_y = margin_y , debug = element @ debug , ... )
493
496
}
494
497
495
- S7 :: method(element_grob , element_line ) <-
498
+ S7 :: method(draw_element , element_line ) <-
496
499
function (element , x = 0 : 1 , y = 0 : 1 ,
497
500
colour = NULL , linewidth = NULL , linetype = NULL , lineend = NULL ,
498
501
linejoin = NULL , arrow.fill = NULL ,
@@ -531,7 +534,7 @@ S7::method(element_grob, element_line) <-
531
534
)
532
535
}
533
536
534
- S7 :: method(element_grob , element_polygon ) <-
537
+ S7 :: method(draw_element , element_polygon ) <-
535
538
function (element , x = c(0 , 0.5 , 1 , 0.5 ),
536
539
y = c(0.5 , 1 , 0.5 , 0 ), fill = NULL ,
537
540
colour = NULL , linewidth = NULL ,
@@ -553,7 +556,7 @@ S7::method(element_grob, element_polygon) <-
553
556
)
554
557
}
555
558
556
- S7 :: method(element_grob , element_point ) <-
559
+ S7 :: method(draw_element , element_point ) <-
557
560
function (element , x = 0.5 , y = 0.5 , colour = NULL ,
558
561
shape = NULL , fill = NULL , size = NULL ,
559
562
stroke = NULL , ... ,
@@ -567,6 +570,18 @@ S7::method(element_grob, element_point) <-
567
570
default.units = default.units , ... )
568
571
}
569
572
573
+ # TODO: the S3 generic should be phased out once S7 is adopted more widely
574
+ # ' @rdname draw_element
575
+ # ' @export
576
+ element_grob <- function (element , ... ) {
577
+ UseMethod(" element_grob" )
578
+ }
579
+
580
+ # ' @export
581
+ element_grob.default <- function (element , ... ) {
582
+ draw_element(element , ... )
583
+ }
584
+
570
585
# ' Define and register new theme elements
571
586
# '
572
587
# ' The underlying structure of a ggplot2 theme is defined via the element tree, which
0 commit comments