@@ -436,16 +436,19 @@ element_render <- function(theme, element, ..., name = NULL) {
436436
437437# ' Generate grid grob from theme element
438438# '
439+ # ' The `element_grob()` function is vestigial and `draw_element()` should
440+ # ' be used instead.
441+ # '
439442# ' @param element Theme element, i.e. `element_rect` or similar.
440443# ' @param ... Other arguments to control specific of rendering. This is
441444# ' usually at least position. See the source code for individual methods.
442445# ' @keywords internal
443446# ' @export
444- element_grob <- S7 :: new_generic(" element_grob " , " element" )
447+ draw_element <- S7 :: new_generic(" draw_element " , " element" )
445448
446- S7 :: method(element_grob , element_blank ) <- function (element , ... ) zeroGrob()
449+ S7 :: method(draw_element , element_blank ) <- function (element , ... ) zeroGrob()
447450
448- S7 :: method(element_grob , element_rect ) <-
451+ S7 :: method(draw_element , element_rect ) <-
449452 function (element , x = 0.5 , y = 0.5 , width = 1 , height = 1 ,
450453 fill = NULL , colour = NULL ,
451454 linewidth = NULL , linetype = NULL , linejoin = NULL ,
@@ -464,7 +467,7 @@ S7::method(element_grob, element_rect) <-
464467 rectGrob(x , y , width , height , gp = modify_list(element_gp , gp ), ... )
465468 }
466469
467- S7 :: method(element_grob , element_text ) <-
470+ S7 :: method(draw_element , element_text ) <-
468471 function (element , label = " " , x = NULL , y = NULL ,
469472 family = NULL , face = NULL , colour = NULL , size = NULL ,
470473 hjust = NULL , vjust = NULL , angle = NULL , lineheight = NULL ,
@@ -492,7 +495,7 @@ S7::method(element_grob, element_text) <-
492495 margin_x = margin_x , margin_y = margin_y , debug = element @ debug , ... )
493496 }
494497
495- S7 :: method(element_grob , element_line ) <-
498+ S7 :: method(draw_element , element_line ) <-
496499 function (element , x = 0 : 1 , y = 0 : 1 ,
497500 colour = NULL , linewidth = NULL , linetype = NULL , lineend = NULL ,
498501 linejoin = NULL , arrow.fill = NULL ,
@@ -531,7 +534,7 @@ S7::method(element_grob, element_line) <-
531534 )
532535 }
533536
534- S7 :: method(element_grob , element_polygon ) <-
537+ S7 :: method(draw_element , element_polygon ) <-
535538 function (element , x = c(0 , 0.5 , 1 , 0.5 ),
536539 y = c(0.5 , 1 , 0.5 , 0 ), fill = NULL ,
537540 colour = NULL , linewidth = NULL ,
@@ -553,7 +556,7 @@ S7::method(element_grob, element_polygon) <-
553556 )
554557 }
555558
556- S7 :: method(element_grob , element_point ) <-
559+ S7 :: method(draw_element , element_point ) <-
557560 function (element , x = 0.5 , y = 0.5 , colour = NULL ,
558561 shape = NULL , fill = NULL , size = NULL ,
559562 stroke = NULL , ... ,
@@ -567,6 +570,18 @@ S7::method(element_grob, element_point) <-
567570 default.units = default.units , ... )
568571 }
569572
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+
570585# ' Define and register new theme elements
571586# '
572587# ' The underlying structure of a ggplot2 theme is defined via the element tree, which
0 commit comments