[PATCH] fix color in 3D "smooth" style in postscript output

9 views
Skip to first unread message

Qian Yun

unread,
Apr 18, 2024, 5:57:15 AM4/18/24
to fricas-devel
Currently we get mono color in postscript output of "smooth" style
3D drawings.

That's caused by "GSetForeground" before "GDrawPoint".
"GSetForeground" can only set gray scale.

Luckily the all four usage of "GDrawPoint" are all for the purpose
of generating "smooth" style image. So this change will not break
anywhere else.

So I decode color and use "setrgbcolor" for it and remove
"installGC" from "drawpoint.ps" because that's responsible for
setting the grey color.

- Qian
fix-3D-smooth-color-PS-output.patch

Qian Yun

unread,
Apr 19, 2024, 7:10:58 AM4/19/24
to fricas-devel
I'd like to also include the following in this patch.

You will notice that the ps output has a strange gray background.

The following code snippet is responsible for setting color.

#define psShadeMax 17.0 /* same as XShadeMax */
#define psShadeMul (1.0/(psShadeMax-1.0)) /* white and 16 gray
shades */

It makes no sense to compute a constant grey color and use it.
(I guess it was mono color so put a grey background there?)

Let's simply have a white background instead.

- Qian

diff --git a/src/graph/view3D/smoothShade3d.c
b/src/graph/view3D/smoothShade3d.c
index 7e80157a..432a0f98 100644
--- a/src/graph/view3D/smoothShade3d.c
+++ b/src/graph/view3D/smoothShade3d.c
@@ -567,8 +567,7 @@ scanLines(int dFlag)
XFillRectangle(dsply,viewport->viewWindow,trashGC,0,0,
vwInfo.width,vwInfo.height);
} else {
- GSetForeground(GC9991,
- 1.0-(float)((int)(psShadeMax-0.3*psShadeMax)-1)*psShadeMul,dFlag);
+ GSetForeground(GC9991, psWhite, dFlag);
quadMesh[0].x = 0; quadMesh[0].y = 0;
quadMesh[1].x = graphWindowAttrib.width+2;
quadMesh[1].y = 0;

Qian Yun

unread,
Apr 19, 2024, 10:41:44 PM4/19/24
to fricas-devel
Also the calculation of rgb and print of "setrgbcolor"
should be made into a separate function, because the
2D PS output will need this as well.

- Qian

Waldek Hebisch

unread,
Apr 21, 2024, 1:20:36 PM4/21/24
to fricas...@googlegroups.com
On Sat, Apr 20, 2024 at 10:41:39AM +0800, Qian Yun wrote:
> Also the calculation of rgb and print of "setrgbcolor"
> should be made into a separate function, because the
> 2D PS output will need this as well.

Yes. The patches looks good. As I mentioned, since you keep
finding new things it makes sense to collect them in bigger
change.
> --
> You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/0e864821-510e-4880-89af-312fc1c94fd3%40gmail.com.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages