Wings 3D Development Forum
New plugins: color tools - 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: New plugins: color tools (/showthread.php?tid=3114)

Pages: 1 2 3


New plugins: color tools - edb - 05-23-2023

Hello,

I've made some plugins related to color and the wings palette.

Color Panel

A color panel for quick selection of colors, it maintains a color history like in some paint programs, and the color history can be sent to the palette.

[Image: nFSG12XX_o.png]

Palette Import/Export

I've made some functionality to import and export different kinds of files to the wings palette. Since it is a standalone plugin at the moment I decided to put them in the Tools menu.

Import:
From swatch image:
Reads an image file of a color swatch (image of solid color squares that some color generator web sites can export).

Text file:
Read various plain text files, it recognizes hex color codes, CSS style rgb(...) and tabular data.

Adobe Palette:
Reads various adobe palette types.

Sample from image:
Scans the image for the most used colors.

Export:
SVG swatch image / EPS swatch image:
Generates a swatch-style picture in SVG/EPS.

Text file:
Generate text file with hex or tabular data.

SVG/TeX legend:
Generate a list of labelled colors (currently labels show "Color1", Color2", etc).




[Image: UwWW2HZ6_o.png]

Download

Color tools beam files:
wings_palette_patch.tar
wpc_color_panel.tar


RE: New plugins: color tools - micheus - 05-23-2023

Hi edb

This is I nice stuff to the palette usage.

I have some suggestions...

Color Panel: I think it would be better for colour selection if we could move the cursor - while keeping the mouse button pressed - see a preview of the colour (using just the small square you will store the colour). Then, by releasing the colour we already know with more "precision" the chosen colour.

Although your colour pick is the same as the one in the default OS used by Wings3D (HSL - at least for Windows) the main advantage I see is the possibility to pick a set each time instead of only one. Maybe this can be useful for other OSs too.

For the entire content of this plugin, I think you could implement is as an upgrade to the official Palette window, which you could add the Color Panel as a second option to fill the selected square (usually it's done via Edit option) or append a set of colors the user has created when using your dialog.

The Import and Export option would be added as submenu of the Palette's one with the addition of the native Wings3D option (.wpal).


Also, take a look on this old thread: How to better organize a color palette ?
I would like you to take a "special" look on post #4, #10 (see tkbd idea and files)

I'm sure that should not be a problem to do the adaptation in the src/wings_palette.erl and I think this has potential to be approved by dgud.


Think about. Smile


RE: New plugins: color tools - edb - 05-24-2023

Hello micheus,

Thanks for the feedback. I'll look at trying to add a color preview when the mouse button is held down.

I think the palette window as it is is pretty good. I used wings_palette.erl as a reference to how the floating windows in wings are written, since it's one of the simpler modules in the wings source. It helped a lot in my case to get a floating window plugin working, so a module like wings_palette.erl has some advantages to be small and simple especially for future plugin developers. As for palette editing, I'll have to think if there is any ideas for the color dialog when "edit" is pushed.

When I modified the #st{} pal list I was impressed how the palette window reacts right away to the change in state, it makes the two color windows seem more integrated even when they are different windows.

I should mention I'm probably going to make more color related plugins as well, at least one more floating window tool after this one.

I can try adding the palette import/export stuff right away to the menu of wings_palette.erl, but I don't know how to make submenus using wings_menu:popup_menu yet. I first tried by doing a second psend/popup_menu call after the first psend/popup_menu in a handle_event. But nothing appears after the click but it does appear after a second right click, but I don't think I'm doing it right.


RE: New plugins: color tools - micheus - 05-24-2023

Ok. So, keep doing your way for now. We can think about integrate than in the future depending on the viability after all stuff you will add.

But, since the Import/Export stuff you implemented act over the native Palette it would be appropriated those options be appended to the Import/Export option we already find there (Palette window), because it will not be intuitive to have two places to handle this kind of stuff.


edb Wrote:I can try adding the palette import/export stuff right away to the menu of wings_palette.erl, but I don't know how to make submenus using wings_menu:popup_menu yet. I first tried by doing a second psend/popup_menu call after the first psend/popup_menu in a handle_event. But nothing appears after the click but it does appear after a second right click, but I don't think I'm doing it right.
You didn't asked for help, but I think you don't need to go through the hard path I've made. Smile
I started to build a thread bout menus for programmers and at the end I hope this can help you spend more time coding than trying to figure out how the things work:
"How to" about context menus
I'm going to keep adding info there later.


RE: New plugins: color tools - tkbd - 05-25-2023

hello edb
I love this tool.
Then, I found two issues and good things through Palette tools test.

Good things
  • Palette Tools could import GIMP Palettes file(gpl) and Adobe color books file(acb).
  • The tools also could export with color list by column ,it is compatible to gpl file.
    (gpl palette file often used by GIMP and Inkscape.)
  • I use often use Import From swatch Image(png,tif)----Get each corlors from widly filled pixel area in the color grid image.


Unsatisfied point
New Color tool palette can trim for new created colors, but can't eliminate specific one color.


Issue 1.Some aco(Photoshop swatch) files can't load colors (no message in log window)
Issue occurred = HKS E-Z Process.aco , HKS E-Z.aco,ANPA Colors.aco,etc
No problem = VisiBone.aco , Windows.aco, Mac OS.aco,WebSafeColors.aco


Issue 2.Cant export color palette completely by SVG(EPS) format
Wings crash log output when exporting through Palette tools the color palette that has some gaps with undefine color(s) in wings3d-built-in palette window.(It is workaround that used compact command for fix gap.)
The SVG file generate,but it is incompletely.
It's a good to skip datas with undefined colors(It is a slashed swatch in palette window).


It is as like color ,color,... (omit)... color , none,none ,color,none ....
The output log is a following.
Code:
wpc_palette_imports: Error function_clause stack trace: [{wpc_palette_imports,
        export_swimg_svg_1,
        [<0.111.0>,
         [none,none,
          {0.8627450980392157,
           1.0,
           0.8627450980392157}],
         39],
        [{file,
          "src/wpc_palette_imports.erl"},
         {line,1087}]},
       {wpc_palette_imports,
        export_swimg_svg,2,
        [{file,
          "src/wpc_palette_imports.erl"},
         {line,1084}]},
       {wpc_palette_imports,
        '-do_export_swimg_svg/2-fun-0-',
        2,
        [{file,
          "src/wpc_palette_imports.erl"},
         {line,961}]},
       {wings_file,
        '-export_filename_1/2-fun-0-',
        3,
        [{file,
          "wings_file.erl"},
         {line,97}]},
       {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,1039}]},
       {wings_wm,
        send_event,2,
        [{file,
          "wings_wm.erl"},
         {line,1005}]},
       {wings_wm,
        do_dispatch,2,
        [{file,
          "wings_wm.erl"},
         {line,897}]},
       {wings_wm,
        get_and_dispatch,0,
        [{file,
          "wings_wm.erl"},
         {line,692}]},
       {wings,init_part2,3,
        [{file,"wings.erl"},
         {line,108}]},
       {proc_lib,
        init_p_do_apply,3,
        [{file,
          "proc_lib.erl"},
         {line,226}]}]



RE: New plugins: color tools - edb - 05-26-2023

Hello micheus and tkbd,

micheus Wrote:"How to" about context menus
I'm going to keep adding info there later.

Thank you the information about the submenus it helped a lot.

tkbd Wrote:New Color tool palette can trim for new created colors, but can't eliminate specific one color.

Thanks for the feedback tkbd for the good things and the things need improvements, I'll try to find a way to remove a specific color.

tkbd Wrote:Issue 1.Some aco(Photoshop swatch) files can't load colors (no message in log window)

tkbd Wrote:Issue 2.Cant export color palette completely by SVG(EPS) format

Thanks I'll have a fix for issue 1 and 2 for the next build.


The next build for the palette import / export will be a patch. I should have something soon.


RE: New plugins: color tools - edb - 05-26-2023

Palette import/export patch:
wings_palette_patch.tar

I'll make a pull request soon.

The wpc_palette_imports.beam can be deleted from plugins as it is now replaced with a patch for wings_palette_imports.beam


RE: New plugins: color tools - micheus - 05-26-2023

Hi edb
I just checked the import/export plugin.

Do you intend to make it part of the native wings_palette code?
If so, I think that all the options must be grouped in the sub-menu. Keep one option for Wings3D palette and others is not nice to look at.


RE: New plugins: color tools - edb - 05-26-2023

Hello micheus,

I wasn't sure if wings' palette .wpal would be inside or outside of the submenu, but I can add it inside too, at the top with a separator.

Maybe something like this?
Code:
"Clear All"
"Compact"
"Scan Colors"
separator,
"Import"
    "Wings3D Palette (.wpal)"
    separator,
    "From swatch (.png|.tif)"
    "Text files (.txt|.css)"
    ...
"Export"
    "Wings3D Palette (.wpal)"
    separator,
    "SVG swatch (.svg)"
    "EPS swatch (.eps)"
    ...



RE: New plugins: color tools - micheus - 05-26-2023

Yeah. It can look better this way.

So the user will see the main options Import and Export and after that will find all options available.