Skip to content

Commit

Permalink
Add kwargs... to shape surface functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOresten committed Nov 27, 2023
1 parent cc2c95a commit 6771b45
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/ribbon/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ function render!(
endpoint = segment_endpoint(segment)
controls = @view acarbon_coord_matrix(segment.backbone)[:, (isone(end) ? 1 : 2):end]
coords = [startpoint controls endpoint]
surface_vertices = coil_surface(coords,
surface_vertices = coil_surface(coords;
radius=radius, spline_quality=spline_quality, slice_quality=slice_quality,
ghost_control_start=segment_startpoint(extended_segment), ghost_control_end=segment_endpoint(extended_segment)
ghost_control_start=segment_startpoint(extended_segment), ghost_control_end=segment_endpoint(extended_segment),
kwargs...
)
N = size(surface_vertices, 2)
color_matrix = expand_colors(colors, N)
Expand All @@ -38,9 +39,10 @@ function render!(
endpoint = segment_endpoint(segment)
controls = @view acarbon_coord_matrix(segment.backbone)[:, 2:end] # startpoint is first point instead. including first N *and* CA could mess with normals
coords = hcat(startpoint, controls, endpoint)
surface_vertices = helix_surface(coords,
surface_vertices = helix_surface(coords;
radius=helix_radius, width_factor=helix_width, thickness_factor=helix_thickness,
spline_quality=spline_quality, slice_quality=slice_quality,
kwargs...
)
N = size(surface_vertices, 2)
color_matrix = expand_colors(colors, N)
Expand All @@ -64,8 +66,9 @@ function render!(
oxygen_coords_side2 = @view oxygen_coord_matrix(segment.backbone)[:, 2:2:end]
coords1 = hcat(startpoint, oxygen_coords_side1, endpoint)
coords2 = hcat(startpoint, oxygen_coords_side2, endpoint)
surface_vertices = arrow_surface(coords1, coords2,
surface_vertices = arrow_surface(coords1, coords2;
width=strand_width, thickness=strand_thickness, spline_quality=spline_quality,
kwargs...
)
N = size(surface_vertices, 2)
color_matrix = expand_colors(colors, N)
Expand Down
6 changes: 4 additions & 2 deletions src/ribbon/shapes/arrow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ function arrow_surface(
points2::AbstractMatrix{T};
width = 1.0,
thickness = 0.3,
arrow_head_length = 3.5,
arrow_head_width = 2*width,
spline_quality = 20,
kwargs...
) where T <: Real
if size(points1, 2) > 3 && size(points2, 2) > 3
points1 = points1[:, [1:end-2; end]]
Expand All @@ -53,10 +56,9 @@ function arrow_surface(

cumulative_length_of_path = cumsum(norm.(eachcol(unnormalized_tangents)))
length_of_path = cumulative_length_of_path[end]
arrow_head_length = 3.0
arrow_body_length = length_of_path - arrow_head_length
l = findfirst(>(arrow_body_length), cumulative_length_of_path) / N
arrow = arrow_function(l, width, width*2.0)
arrow = arrow_function(l, width, arrow_head_width)

surface_vertices = zeros(T, 3, N, 5)
for idx in 1:N
Expand Down
1 change: 1 addition & 0 deletions src/ribbon/shapes/coil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function coil_surface(
slice_quality = 20,
ghost_control_start = nothing,
ghost_control_end = nothing,
kwargs...
) where T <: Real

path = if !isnothing(ghost_control_start) && !isnothing(ghost_control_end)
Expand Down
1 change: 1 addition & 0 deletions src/ribbon/shapes/helix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function helix_surface(
thickness_factor = 1.0,
spline_quality = 20,
slice_quality = 20,
kwargs...
) where T <: Real
path = spline(points, m=spline_quality, k=min(3, size(points, 2)-1))
N = size(path, 2)
Expand Down

2 comments on commit 6771b45

@AntonOresten
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96071

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 6771b457635771f90111c21c19a6696ad559e37b
git push origin v0.2.0

Please sign in to comment.