Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# sportyR 2.2.3

- Fixed [#38](https://github.com/sportsdataverse/sportyR/issues/38) to natively support PWHL
- Added titles to documentation

# sportyR 2.2.2

Expand Down
6 changes: 6 additions & 0 deletions R/cani-functions.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' Can I Plot League?
#'

Check warning on line 2 in R/cani-functions.R

View workflow job for this annotation

GitHub Actions / lint

file=R/cani-functions.R,line=2,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Check to see if a league can be plotted, and alert as to which function(s)
#' that league will work for
#'
Expand Down Expand Up @@ -120,6 +122,8 @@
}
}

#' Can I Plot Sport?
#'

Check warning on line 126 in R/cani-functions.R

View workflow job for this annotation

GitHub Actions / lint

file=R/cani-functions.R,line=126,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Check to see if a sport can be plotted, and alert as to which league(s) are
#' plottable for the sport
#'
Expand Down Expand Up @@ -239,6 +243,8 @@
}
}

#' Can I Color a League Feature?
#'

Check warning on line 247 in R/cani-functions.R

View workflow job for this annotation

GitHub Actions / lint

file=R/cani-functions.R,line=247,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Check to see what features of a surface can be colored
#'
#' @param league_code The case-insensitive league code to be plotted
Expand Down
4 changes: 4 additions & 0 deletions R/coordinate-transformations.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' Reflect Coordinates
#'

Check warning on line 2 in R/coordinate-transformations.R

View workflow job for this annotation

GitHub Actions / lint

file=R/coordinate-transformations.R,line=2,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Perform a mathematical reflection of coordinates over a specified axis
#'
#' @param df The data frame to reflect. It must have \code{x} and \code{y}
Expand Down Expand Up @@ -29,6 +31,8 @@
return(df)
}

#' Rotate Coordinates
#'

Check warning on line 35 in R/coordinate-transformations.R

View workflow job for this annotation

GitHub Actions / lint

file=R/coordinate-transformations.R,line=35,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Perform a mathematical rotation about (0, 0) of coordinates. This rotation is
#' given as x' = x \* cos(theta) - y \* sin(theta) y' = x \* sin(theta) + y \*
#' cos(theta)
Expand Down
10 changes: 10 additions & 0 deletions R/create-shapes.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' Create Circle
#'

Check warning on line 2 in R/create-shapes.R

View workflow job for this annotation

GitHub Actions / lint

file=R/create-shapes.R,line=2,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Create a set of \code{x} and \code{y} coordinates that form a circle (or the
#' arc of a circle)
#'
Expand Down Expand Up @@ -30,6 +32,8 @@
return(circle_coords)
}

#' Create Rectangle
#'

Check warning on line 36 in R/create-shapes.R

View workflow job for this annotation

GitHub Actions / lint

file=R/create-shapes.R,line=36,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Create a set of \code{x} and \code{y} coordinates that form a rectangle
#'
#' @param x_min The minimum value of \code{x}
Expand All @@ -47,9 +51,11 @@
y = c(y_min, y_min, y_max, y_max, y_min)
)

return(rectangle_coords)

Check warning on line 54 in R/create-shapes.R

View workflow job for this annotation

GitHub Actions / lint

file=R/create-shapes.R,line=54,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' Create Square
#'

Check warning on line 58 in R/create-shapes.R

View workflow job for this annotation

GitHub Actions / lint

file=R/create-shapes.R,line=58,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Create a set of \code{x} and \code{y} coordinates that form a square. This
#' function is a wrapper on \code{create_rectangle()} above
#'
Expand All @@ -71,6 +77,8 @@
return(square_coords)
}

#' Create Diamond
#'

Check warning on line 81 in R/create-shapes.R

View workflow job for this annotation

GitHub Actions / lint

file=R/create-shapes.R,line=81,col=3,[trailing_whitespace_linter] Remove trailing whitespace.
#' Create a set of \code{x} and \code{y} coordinates that form a diamond. This
#' function is a wrapper on \code{create_rectangle()} above
#'
Expand Down Expand Up @@ -103,6 +111,8 @@
return(diamond_coords)
}

#' Create an "X" Shape
#'
#' Create a set of \code{x} and \code{y} coordinates that form an "X"-like shape
#'
#' @param bar_length The length of one of the bars that forms the "X" shape,
Expand Down
20 changes: 20 additions & 0 deletions R/features-baseball.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Surface Base Features --------------------------------------------------------

#' Baseball Infield Dirt
#'
#' The dirt that comprises the infield. This includes the base paths, infield
#' arc, and home plate circle.
#'
Expand Down Expand Up @@ -104,6 +106,8 @@ baseball_infield_dirt <- function(home_plate_circle_radius = 0,
return(infield_dirt)
}

#' Baseball Infield Grass
#'
#' The dirt that comprises the infield grass. This is the area inside the lines
#' drawn by the basepaths
#'
Expand Down Expand Up @@ -267,6 +271,8 @@ baseball_infield_grass <- function(home_plate_circle_radius = 0,

# Surface Lines ----------------------------------------------------------------

#' Baseball Batter's Box
#'
#' The batter's boxes on the field. This is where a batter must stand to legally
#' hit the ball
#'
Expand Down Expand Up @@ -325,6 +331,8 @@ baseball_batters_box <- function(batters_box_length = 0,
return(batters_box_df)
}

#' Baseball Catcher's Box
#'
#' The catcher's box. This is where the catcher is located on defense, usually
#' marked by two white lines and a back line as well. The box may take various
#' shapes, which are controlled by the \code{catchers_box_shape} parameter
Expand Down Expand Up @@ -452,6 +460,8 @@ baseball_catchers_box <- function(catchers_box_depth = 0,
return(catchers_box_df)
}

#' Baseball Foul Line
#'
#' The foul line. These are the white lines that extend from the back tip of
#' home plate (but not visibly through the batter's boxes) out to the fair/foul
#' pole in the outfield. Since a ball on the line is considered in fair
Expand Down Expand Up @@ -538,6 +548,8 @@ baseball_foul_line <- function(is_line_1b = FALSE,
return(foul_line_df)
}

#' Baseball Running Lane
#'
#' The running lane is entirely in foul territory. The depth should be measured
#' from the foul-side edge of the baseline to the outer edge of the running lane
#' mark
Expand Down Expand Up @@ -619,6 +631,8 @@ baseball_running_lane <- function(running_lane_depth = 0,

# Surface Features -------------------------------------------------------------

#' Baseball Home Plate
#'
#' Home plate. This is a pentagonal shape with its back tip located at the
#' origin of the coordinate system. The angled sides of home plate intersect the
#' baselines
Expand Down Expand Up @@ -651,6 +665,8 @@ baseball_home_plate <- function(home_plate_edge_length = 0) {
return(home_plate_df)
}

#' Baseball Base
#'
#' One of the bases on the diamond, or really any base on the field. These are
#' squares that are rotated 45 degrees
#'
Expand Down Expand Up @@ -696,6 +712,8 @@ baseball_base <- function(base_side_length = 0,
return(base_df)
}

#' Baseball Pitcher's Mound
#'
#' The pitcher's mound. This is where the pitcher's plate is located, but the
#' pitcher's plate is not necessarily centered on the pitcher's mound
#'
Expand All @@ -716,6 +734,8 @@ baseball_pitchers_mound <- function(pitchers_mound_radius = 0) {
return(pitchers_mound_df)
}

#' Baseball Pitcher's Plate
#'
#' The pitcher's plate. This is where the pitcher must throw the ball from. It's
#' usually a long rectangle with its front edge as its anchor point
#'
Expand Down
48 changes: 47 additions & 1 deletion R/features-basketball.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Surface Base Features --------------------------------------------------------

#' Basketball Half Court
#'
#' Each half court spans from the inner edge of the baseline to the center of
#' the division line, and serves as the base layer of the court plot
#'
Expand All @@ -24,6 +26,8 @@ basketball_half_court <- function(court_length = 0, court_width = 0) {
return(half_court_df)
}

#' Basketball Two-Point Range
#'
#' If a court has a three-point line (see [basketball_three_point_line()]), then
#' any made basket (not including free throws) made from inside of the arc are
#' worth two points. The area inside of this arc is therefore referred to as two
Expand Down Expand Up @@ -102,6 +106,8 @@ basketball_two_point_range <- function(basket_center_to_baseline = 0,
return(two_point_range_df)
}

#' Basketball Center Circle (Interior)
#'
#' The center circle is broken into two parts: the
#' [basketball_center_circle_outline()], and the fill (this feature), which is
#' the court coloring inside of the inner edge of this circle
Expand All @@ -126,6 +132,8 @@ basketball_center_circle_fill <- function(center_circle_radius = 0,
return(center_circle_fill_df)
}

#' Basketball Painted Area
#'
#' The painted area is the area contained by the free throw lane (see
#' [basketball_free_throw_lane_boundary()] for more information on the free
#' throw lane)
Expand Down Expand Up @@ -159,6 +167,8 @@ basketball_painted_area <- function(lane_length = 0,
return(painted_area_df)
}

#' Basketball Free Throw Circle (Interior)
#'
#' The filled-in section of the free throw circle. The circle is the area where
#' a free throw shooter stands when attempting the free throw. The outline of
#' this area will be created separately via
Expand Down Expand Up @@ -190,6 +200,8 @@ basketball_free_throw_circle_fill <- function(free_throw_circle_radius = 0,

# Surface Boundaries -----------------------------------------------------------

#' Basketball Court Apron
#'
#' The apron of the court is the colored boundary around the exterior of some
#' courts. If no such colored boundary exists, this should take the same color
#' as the court floor
Expand Down Expand Up @@ -242,6 +254,8 @@ basketball_court_apron <- function(court_length = 0,
return(court_apron_df)
}

#' Basketball Endline
#'
#' The endline on a basketball court, also called the baseline, is located
#' beyond each basket. In cases where the endline is the court apron, the
#' endline should still be generated and its color should be set equal to the
Expand All @@ -265,6 +279,8 @@ basketball_endline <- function(court_width = 0, line_thickness = 0) {
return(endline_df)
}

#' Basketball Sideline
#'
#' The sideline on a basketball court run the full length of the court,
#' typically with the team bench areas and substitution areas on their exterior.
#' In cases where the sideline is the court apron, the sideline should still be
Expand Down Expand Up @@ -294,6 +310,8 @@ basketball_sideline <- function(court_length = 0, line_thickness = 0) {

# Surface Lines ----------------------------------------------------------------

#' Basketball Center Circle (Outline)
#'
#' The center circle is broken into two parts: the outline (this feature) and
#' the fill, which is the court coloring inside of the inner edge of this circle
#'
Expand Down Expand Up @@ -327,6 +345,8 @@ basketball_center_circle_outline <- function(center_circle_radius = 0,
return(center_circle_outline_df)
}

#' Basketball Division Line (Half Court Line)
#'
#' The division line divides the court into two halves, and is sometimes
#' referred to as the time line or half-court line. The center of this line goes
#' through the y axis, with half of the line lying in a team's offensive half
Expand Down Expand Up @@ -362,6 +382,8 @@ basketball_division_line <- function(court_width = 0,
return(division_line_df)
}

#' Basketball Three-Point Line
#'
#' An arc on the court, behind which any made basket counts as three points and
#' in front of which, any made basket will count as two points (see
#' [basketball_two_point_range()] for more information).
Expand Down Expand Up @@ -457,6 +479,8 @@ basketball_three_point_line <- function(basket_center_to_baseline = 0,
return(three_point_line_df)
}

#' Basketball Free Throw Lane (Boundary)
#'
#' The lines providing the boundary to the free throw lane. When a player is
#' shooting a free throw, all non-shooting players must be outside of this
#' boundary
Expand Down Expand Up @@ -503,6 +527,8 @@ basketball_free_throw_lane_boundary <- function(lane_length = 0,
return(free_throw_lane_boundary_df)
}

#' Basketball Free Throw Circle (Outline)
#'
#' The outline of the free throw circle. The interior filling area is created
#' via [basketball_free_throw_circle_fill()]
#'
Expand Down Expand Up @@ -544,6 +570,8 @@ basketball_free_throw_circle <- function(overhang = 0,
return(free_throw_circle_outline_df)
}

#' Basketball Free Throw Circle (Dashes)
#'
#' On some courts, there are a series of dashes that comprise the bottom half of
#' the free throw circle (e.g. the half closer to the basket). This function
#' generates a single dash
Expand Down Expand Up @@ -582,6 +610,8 @@ basketball_free_throw_circle_dash <- function(feature_radius = 0,
return(free_throw_circle_dash_df)
}

#' Basketball Lane Space Mark (Blocks)
#'
#' The lane space marks, also known as the blocks, denote where non-shooting
#' players stand during free throws. Players may not cross these lines before
#' the ball touches the rim on the shot attempt
Expand All @@ -605,6 +635,8 @@ basketball_lane_space_mark <- function(feature_thickness = 0, mark_depth = 0) {
return(lane_space_mark_df)
}

#' Basketball Inbounding Line
#'
#' The inbounding line is where the ball is inbounded on the sideline when
#' necessary. Lines drawn on the top of the court should be drawn in a top-down
#' direction, and lines on the bottom of the court should be drawn in the
Expand Down Expand Up @@ -643,6 +675,8 @@ basketball_inbounding_line <- function(line_thickness = 0,
return(inbounding_line_df)
}

#' Basketball Substitution Line
#'
#' The substitution line is where players checking into the game wait for a
#' stoppage. Lines drawn on the top of the court should be drawn in a top-down
#' direction, and lines on the bottom of the court should be drawn in the
Expand Down Expand Up @@ -680,6 +714,8 @@ basketball_substitution_line <- function(line_thickness = 0,
return(substitution_line_df)
}

#' Basketball Team Bench Line
#'
#' Players not in the game must stay within the team bench lines unless moving
#' to the substitution area (see [basketball_substitution_line()] class)
#'
Expand Down Expand Up @@ -714,7 +750,9 @@ basketball_team_bench_line <- function(line_thickness = 0,
return(team_bench_line_df)
}

#' The arc located in the free-throw lane is called the restricted arc. The
#' Basketball Restricted Arc
#'
#' The arc located in the free throw lane is called the restricted arc. The
#' interior radius should be specified for this feature.
#'
#' @param feature_radius The interior radius of the restricted arc
Expand Down Expand Up @@ -769,6 +807,8 @@ basketball_restricted_arc <- function(feature_radius = 0,

# Surface Features -------------------------------------------------------------

#' Basketball Lower Defensive Box Mark
#'
#' The lower defensive box is an imaginary box on the court extending from the
#' lines on the baseline to the lines inside the painted area. This box helps
#' determine when a block/charge call should take place, as an offensive player
Expand Down Expand Up @@ -809,6 +849,8 @@ basketball_lower_defensive_box_mark <- function(drawn_direction = "",
return(lower_defensive_box_mark_df)
}

#' Basketball Backboard
#'
#' The backboard is the backing onto which the basket ring (created by
#' [basketball_basket_ring()]) is affixed. This will be drawn as a
#' rectangle on the court as the court is drawn from an aerial view
Expand All @@ -833,6 +875,8 @@ basketball_backboard <- function(backboard_width = 0, backboard_thickness = 0) {
return(backboard_df)
}

#' Basketball Basket Ring (Rim)
#'
#' The hoop through which the ball must pass to score points for a team is
#' called the basket ring
#'
Expand Down Expand Up @@ -907,6 +951,8 @@ basketball_basket_ring <- function(basket_ring_connector_width = 0,
return(basket_ring_df)
}

#' Basketball Net
#'
#' To make the basket ring easier to identify, the nets will also be drawn onto
#' the plot. They will typically be white in color
#'
Expand Down
Loading