Wings 3D Development Forum
Adding colors to wpc_ps - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Design & Development (https://www.wings3d.com/forum/forumdisplay.php?fid=6)
+--- Thread: Adding colors to wpc_ps (/showthread.php?tid=3102)

Pages: 1 2


Adding colors to wpc_ps - edb - 04-21-2023

Hello,

I've added color support to wpc_ps so it can have some colors imported like the svg importer, my changes are at the branch:
eb/ps-additions.
I'll make a pull request after some more testing. I haven't made huge changes as postscript as a file format seems very complicated.

Also an installable beam file: wpc_ps.tar

I've tried to find some files to help with testing, I saw the thread but the google drive link seem to be gone: http://www.wings3d.com/forum/showthread.php?tid=2279&page=2


RE: Adding colors to wpc_ps - micheus - 04-21-2023

edb Wrote:I've tried to find some files to help with testing, I saw the thread but the google drive link seem to be gone: http://www.wings3d.com/forum/showthread....279&page=2
Yeah, I just saw that.

But, If I remember those files didn't use any color for the objects. The ones you see in that thread I assigned inside Wings3D for better visualize the source differences.

As them were provided to me by tkbd I hope he can provide some with colours for your tests. Smile


RE: Adding colors to wpc_ps - edb - 04-26-2023

Thanks micheus for letting me know.

I'll try testing with the software I have for now.

I've added a small fix:
wpc_ps.tar


RE: Adding colors to wpc_ps - tkbd - 04-26-2023

I'm sorry.
I tried the sample files in my HDD,but I couldn't find it because too old date.
Unfortunately, I can't use GoogleDrive in my current environment.
but,I can send you a test file if needed.
You can also tell me your email address through direct message of the Wings3D forum.


FYI:
I tried to read PS/EPS files that created by various vector graphic Editors.
I test MacOSX mojave and Wings3D 2.2.9 and installed your latest wpc_ps.tar

Perhaps it treat too strigt to the data that SVG "creator" directive.
So,many EPS/PS test files could not be read.
These could be read by the Wings3D built-in EPS/PS importer before your version installation.
I'll post some console output and the beginning of the file.

Some PS/EPS files output error(It is no crash but file loading failure)
The example in Wings3D console
Code:
{179,164},
                         {178,179},
                         {177,178},
                         {176,177},
                         {175,176},
                         {174,175},
                         {173,174},
:
omitt
:
                         {9,10},
                         {8,9},
                         {7,8},
                         {6,7},
                         {5,6},
                         {4,5},
                         {3,4},
                         {2,3},
                         {1,2},
                         {0,1}]]],
                      [{file,"src/wpc_ps.erl"},{line,193}]},
              {wpc_ps,try_import_ps,2,[{file,"src/wpc_ps.erl"},{line,154}]},
              {wpc_ps,make_ps,2,[{file,"src/wpc_ps.erl"},{line,103}]},
              {wpa,do_import,3,[{file,"wpa.erl"},{line,143}]},
              {wpa,'-import/3-fun-0-',3,[{file,"wpa.erl"},{line,132}]},
              {wings_file,'-import_filename_1/2-fun-0-',3,
                          [{file,"wings_file.erl"},{line,67}]},
              {wings_develop,time_command,2,
                             [{file,"wings_develop.erl"},{line,87}]},
              {wings_plugin,command,3,[{file,"wings_plugin.erl"},{line,168}]},
              {wings,raw_command_1,3,[{file,"wings.erl"},{line,646}]},
              {wings,raw_command,4,[{file,"wings.erl"},{line,643}]},
              {wings_wm,handle_event,3,[{file,"wings_wm.erl"},{line,1040}]},
              {wings_wm,send_event,2,[{file,"wings_wm.erl"},{line,1006}]},
              {wings_wm,do_dispatch,2,[{file,"wings_wm.erl"},{line,898}]},
              {wings_wm,dispatch_event,1,[{file,"wings_wm.erl"},{line,807}]},
              {wings_wm,get_and_dispatch,0,[{file,"wings_wm.erl"},{line,693}]},
              {wings,init_part2,3,[{file,"wings.erl"},{line,108}]},
              {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]

It generally knowns that a PostScript file create by Print dialog with printer driver too.
They append something string to "%%Creator:" directive of the PostScript file.
Some printers or applications add string with unknown character encoding,then mojibake happen
In the case,Wings3D refuse it that even correctly PostScript data part.
In this case,PS format convert from PDF file...



Wings3D console (for example)
Code:
wpc_ps: EPS Creator: "(\343\203\225\343\202\232\343\203\254\343\203\222\343\202\231\343\203\245\343\203\274: CGPDFTOPS CUPS FILTER)"

Oct:343/203/225 -> Hex:E3 83 95 -> UTF-8:E38395 -> フ

The octal data "\343\203\225\343\202\232\343\203\254\343\203\222\343\202\231\343\203\245\343\203\274"
means the UTF-8 code(hex) as "E38395,E3829A,E383AC,E38392,E38299,E383A5,E383BC"
,and it stands for the string "フ゜レヒ゛ュー"
it is a built in viewer application of MacOS

PostScript file created by Printer driver
Code:
%!PS-Adobe-3.0
%APL_DSC_Encoding: UTF8
%APLProducer: (Version 11.7.4 (Build 20G1120) Quartz PS Context)
%%Title: (rect_test.pdf)
%%Creator: (\\343\\203\\225\\343\\202\\232\\343\\203\\254\\343\\203\\222\\343\\202\\231\\343\\203\\245\\343\\203\\274: cgpdftops CUPS filter)
%%CreationDate: (Wednesday, April 26 2023 09:19:45 JST)
%%For: (System Administrator)
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%PageOrder: Ascend
%RBINumCopies: 1
%%Pages: (atend)
%%BoundingBox: (atend)
%%EndComments
userdict/dscInfo 5 dict dup begin
/Title(rect_test.pdf)def
/Creator(\\343\\203\\225\\343\\202\\232\\343\\203\\254\\343\\203\\222\\343\\202\\231\\343\\203\\245\\343\\203\\274: cgpdftops CUPS filter)def
/CreationDate(Wednesday, April 26 2023 09:19:45 JST)def
/For(System Administrator)def
/Pages 1 def
end put
%%BeginProlog
%%BeginFile: lw8_errorhandler-2.0
/currentpacking where
    { pop /oldpack currentpacking def /setpacking where
        {
            pop false setpacking



FYI:The head data of some PS/EPS files
PS file created by Inkscape
Code:
%!PS-Adobe-3.0
%%Creator: cairo 1.17.6 (https://cairographics.org)
%%CreationDate: Wed Apr 26 09:59:31 2023
%%Pages: 1
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%DocumentMedia: A4 595 842 0 () ()
%%BoundingBox: 70 65 542 719
%%EndComments
%%BeginProlog

PS file created by Illustrator
Code:
%!PS-Adobe-3.1
%ADO_DSC_Encoding: UTF8
%%Title: inkscape1.2_pslv3.eps
%%Creator: (Adobe Graphics Manager)
%%For: mymac
%%CreationDate: 2023/04/26
%%BoundingBox: -1 -1 596 842
%%HiResBoundingBox: -0.0377 -0.0449 595.2378 841.8450
%%CropBox: -0.0377 -0.0449 595.2378 841.8450
%%LanguageLevel: 3


EPS file create by Affinity
Code:
%!PS-Adobe-3.0 EPSF-3.0
%%HiResBoundingBox: 0 0 472 307
%%BoundingBox: 0 0 472 307
%%Creator: Serif Affinity
%LanguageLevel: 3
%%DocumentData: Clean7Bit
%ADO_ContainsXMP: MainFirst
%%EndComments
%%BeginProlog
101 dict begin


EPS file create by VectorStyler
https://www.vectorstyler.com/
Code:
%!PS-Adobe-3.1 EPSF-3.0
%%BoundingBox: 0 0 841 595
%%Copyright:
%%Creator:
%%CreationDate: 12/12/2022
%%DocumentData: Clean8Bit
%%For:
%%LanguageLevel: 3
%%Title:
%%Version: 3.0 1
%%Routing:
%%DocumentProcessColors: Red Green Blue
%%EndComments
%%BeginProlog
%ZTK postscript prolog code

PS file create by VectorStyler
Code:
%!PS-Adobe-3.1
%%BoundingBox: 0 0 841 595
%%Copyright:
%%Creator: ()
%%CreationDate: 12/12/2022
%%DocumentData: Clean8Bit
%%For:
%%LanguageLevel: 3
%%Title:
%%Version: 3.0 1
%%Routing:
%%Pages: (atend)
%%Orientation: Portrait

The eps files by Libreoffice and scribus too.
Anyway, I will test other condifionSmile
If I find out anything, I may report it here.


RE: Adding colors to wpc_ps - edb - 04-27-2023

Hello tkbd,

Thanks for the information. I'll send a direct message soon. Another option is pastebin could be used to paste the ps/eps source. For the testing I'm going to limit the scope for the creators that was supported previously:
  • Adobe Illustrator
  • InkScape
  • LibreOffice
  • Scribus

I don't have Illustrator so test files of shapes made in it will help a lot. (test files for the other software is helpful too!)


RE: Adding colors to wpc_ps - tkbd - 04-30-2023

OK, I send data to you Smile
I also attached some useful test data and some issue reportss.

edb Wrote:I don't have Illustrator so test files of shapes made in it will help a lot. (test files for the other software is helpful too!)

---------
tkbd


RE: Adding colors to wpc_ps - edb - 05-06-2023

Thanks tkbd, I received the test files.


RE: Adding colors to wpc_ps - edb - 05-10-2023

Hello tkbd,

I've fixed a few issues so far with aics5.eps and illustrator_ps2_error.ps, there's a few more fixes to do and I'll be posting a new build.


RE: Adding colors to wpc_ps - edb - 05-13-2023

New wpc_ps build with many fixes, the original test files seem to work.
wpc_ps.tar


RE: Adding colors to wpc_ps - edb - 05-14-2023

New wpc_ps build now with affinity support, and the option of using a custom bind map file to load EPSs from other sources:
wpc_ps.tar

The vectorstyler EPS test file also now imports as a "generic" EPS, since it has an empty creator string it has to be treated as a generic EPS.