Skip to content

Fretboard dot inlays #44

Open
Open
@donald-keighley

Description

Hey, I didn't see a way to add the actual dot inlays that are on most guitar fretboards, but I figured out how to do it. Works for me whether the fretboard is horizontal or vertical. Might be a good to add to the vignette. Could also be added as an option to the plot_fretboard and plot_chord functions, but would be more work.

I like the package by the way. Been using it to make fretboard diagrams for different scales and things. Very cool.

`library(tabr)

creates dot inlay layer, negative numbers will be double dots

dots = c(3,5,7,9,-12,15,17,19,21)
make_fretboard_dots = function(dots, color = 'gray', shape = 16, size = 8){
dot_x = c(rep(3.5, length(dots[dots>=0])), rep(c(2.5, 4.5), length(dots[dots<0])))
dot_y = abs(c(dots[dots>=0], rep(dots[dots<0], each = 2))) - 0.5
fretboard_dots = data.frame(x = dot_x, y = dot_y)
fretboard_dots = fretboard_dots[order(fretboard_dots$y),]
fretboard_dot_layer = ggplot2::geom_point(data = fretboard_dots, shape = shape, color = color, size = size)
return(fretboard_dot_layer)
}
fb_dots = make_fretboard_dots(dots, color = 'gray', shape = 16 , size = 8)

create the plot but don't show it

fb_plot = plot_fretboard(string = 6:1, fret = c(5, 7, 7, 5, 5, 5), fret_range = c(0,12),
labels = 'notes', label_color = "white", horizontal = FALSE)

inserts the dot inlay layer so notes plot on top of it

fb_plot$layers = c(fb_dots, fb_plot$layers)

shows the plot

plot(fb_plot)
`

Should produce this:

image

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions