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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
?build
?build-mp
Testing
.*~
cmake/ConfigUser.cmake
cmake/ConfigUserAdvanced.cmake
Expand All @@ -12,6 +13,8 @@ src/newsuppl*
doc/examples/**/*.mp4
doc/examples/**/*.png
doc/examples/**/*.gif
test/**/*.ps
!test/**/*.ps.dvc
.vscode
cmake/ConfigUser.cmake.orig
cmake/ConfigUserAdvanced.cmake.orig
23 changes: 19 additions & 4 deletions src/postscriptlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -5166,12 +5166,27 @@ int PSL_setcolor (struct PSL_CTRL *PSL, double rgb[], int mode) {
if (PSL_eq (rgb[0], -2.0) || PSL_eq (rgb[0], -1.0)) return (PSL_NO_ERROR); /* Settings to be ignored */
if (PSL_same_rgb (rgb, PSL->current.rgb[mode])) return (PSL_NO_ERROR); /* Same color as already set */

/* Because psl_putcolor does not set transparency if it is 0%, we reset it here when needed */
if (PSL_eq (rgb[3], 0.0) && !PSL_eq (PSL->current.rgb[mode][3], 0.0))
/* Guard: When setting stroke or fill with transparency, preserve the other channel's transparency */
if (!PSL_eq (rgb[3], 0.0) && (mode == PSL_IS_STROKE || mode == PSL_IS_FILL)) {
double transp[2], rgb_copy[4];
/* Preserve current transparencies and update only the relevant channel */
transp[PSL_FILL_TRANSP] = (mode == PSL_IS_FILL) ? rgb[3] : PSL->current.rgb[PSL_IS_FILL][3];
transp[PSL_PEN_TRANSP] = (mode == PSL_IS_STROKE) ? rgb[3] : PSL->current.rgb[PSL_IS_STROKE][3];
/* Set transparency explicitly for both channels */
PSL_command (PSL, "%.12g %.12g /%s PSL_transp\n", 1.0 - transp[PSL_FILL_TRANSP], 1.0 - transp[PSL_PEN_TRANSP], PSL->current.transparency_mode);
/* Make a copy with transparency zeroed out for psl_putcolor to avoid double-setting */
PSL_rgb_copy (rgb_copy, rgb);
rgb_copy[3] = 0.0;
PSL_command (PSL, "%s\n", psl_putcolor (PSL, rgb_copy, 0));
}
else {
/* Because psl_putcolor does not set transparency if it is 0%, we reset it here when needed */
if (PSL_eq (rgb[3], 0.0) && !PSL_eq (PSL->current.rgb[mode][3], 0.0))
PSL_command (PSL, "%.12g %.12g /Normal PSL_transp ", PSL->init.transparencies[PSL_FILL_TRANSP], PSL->init.transparencies[PSL_PEN_TRANSP]);

/* Then, finally, set the color using psl_putcolor */
PSL_command (PSL, "%s\n", psl_putcolor (PSL, rgb, 0));
/* Then, finally, set the color using psl_putcolor */
PSL_command (PSL, "%s\n", psl_putcolor (PSL, rgb, 0));
}

/* Update the current stroke/fill color information */

Expand Down
1 change: 0 additions & 1 deletion test/baseline/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
/pscontour
/psclip
/project
/postscriptlight
/ogr
/nearneighbor
/movie
Expand Down
4 changes: 0 additions & 4 deletions test/baseline/postscriptlight.dvc

This file was deleted.

5 changes: 5 additions & 0 deletions test/baseline/postscriptlight/fillTransparency.ps.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
outs:
- md5: cd022252f83b80a3c67e52094323d52d
size: 26087
hash: md5
path: fillTransparency.ps
14 changes: 14 additions & 0 deletions test/postscriptlight/fillTransparency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env -S bash -ex
# GMT modern mode bash template
# Date: 2026-01-21T12:44:22
# User: solarsmith
# Purpose: Purpose of this script
set -e
export GMT_SESSION_NAME=$$ # Set a unique session name

gmt begin fillTransparency ps
gmt basemap -R-2/2/-2/2 -JX10c/4c -B
echo -1 0 | gmt plot -Ss1c -W1p,blue@60 -Gbrown
echo 0 0 | gmt plot -Ss1c -W1p,blue -Gbrown@30
echo 1 0 | gmt plot -Ss1c -W1p,blue@60 -Gbrown@30
gmt end
Loading