Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fretboard dot inlays #44

Open
donald-keighley opened this issue Jan 6, 2025 · 0 comments
Open

Fretboard dot inlays #44

donald-keighley opened this issue Jan 6, 2025 · 0 comments

Comments

@donald-keighley
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant