Skip to content

Commit

Permalink
Fix CairoMakie line color bug #3704 (#3712)
Browse files Browse the repository at this point in the history
* Fix #3704

* add reference test

* add changelog entry
  • Loading branch information
jkrumbiegel committed Mar 18, 2024
1 parent 77e90f5 commit 3afefb4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
@@ -1,8 +1,8 @@
# Changelog

## [Unreleased]
- Added supported markers hint to unsupported marker warn message.

- Added supported markers hint to unsupported marker warn message [#3666](https://github.com/MakieOrg/Makie.jl/pull/3666).
- Fixed bug in CairoMakie line drawing when multiple successive points had the same color [#3712](https://github.com/MakieOrg/Makie.jl/pull/3712).
- Remove StableHashTraits in favor of calculating hashes directly with CRC32c [#3667](https://github.com/MakieOrg/Makie.jl/pull/3667).

## [0.20.8] - 2024-02-22
Expand Down
7 changes: 7 additions & 0 deletions CairoMakie/src/primitives.jl
Expand Up @@ -257,6 +257,13 @@ function draw_multi(primitive::Lines, ctx, positions, colors::AbstractArray, lin
end
else
prev_continued = false

# finish previous line segment
Cairo.set_line_width(ctx, prev_linewidth)
!isnothing(dash) && Cairo.set_dash(ctx, dash .* prev_linewidth)
Cairo.set_source_rgba(ctx, red(prev_color), green(prev_color), blue(prev_color), alpha(prev_color))
Cairo.stroke(ctx)

if !this_nan
this_linewidth != prev_linewidth && error("Encountered two different linewidth values $prev_linewidth and $this_linewidth in `lines` at index $(i-1). Different linewidths in one line are only permitted in CairoMakie when separated by a NaN point.")
# this is not nan
Expand Down
4 changes: 4 additions & 0 deletions ReferenceTests/src/tests/primitives.jl
Expand Up @@ -36,6 +36,10 @@ end
s
end

@reference_test "lines issue #3704" begin
lines(1:10, sin, color = [fill(0, 9); fill(1, 1)], linewidth = 3, colormap = [:red, :cyan])
end

@reference_test "scatters" begin
s = Scene(size = (800, 800), camera = campixel!)

Expand Down

0 comments on commit 3afefb4

Please sign in to comment.