GIMP Chat
http://gimpchat.com/

New G'MIC filter "Color Wheel"
http://gimpchat.com/viewtopic.php?f=28&t=20728
Page 1 of 1

Author:  cli345 [ Thu Jan 25, 2024 7:35 am ]
Post subject:  New G'MIC filter "Color Wheel"

Hello and happy new year 2024! :)

Inspired by this thread, I intend to propose a new G'MIC filter "Color Wheel".

With default parameters, it would give:
Attachment:
colorWheel1.jpg
colorWheel1.jpg [ 31.3 KiB | Viewed 1077 times ]

With default parameters except that "Internal Circle Radius Percentage = 1, Type = Opponent Model", it would give:
Attachment:
colorWheel_1_1_OM.jpg
colorWheel_1_1_OM.jpg [ 29.21 KiB | Viewed 1077 times ]

With default parameters except that "Internal Circle Radius Percentage = 50, Parts = x3, Type = Red-Yellow-Blue Model", it would give:
Attachment:
colorWheel_50_3_RYB.jpg
colorWheel_50_3_RYB.jpg [ 34.72 KiB | Viewed 1077 times ]

Here is its code:
#@gui Color Wheel (prerelease): cl_colorWheel_prerelease, cl_colorWheel_prerelease(0)
#@gui : note = note("Warning: This is an enormously gross approximation of the color models.")
#@gui : note = note("<b>Dimension:</b>")
#@gui : External Circle Radius = float(200, 10, 1000)
#@gui : Internal Circle Radius Percentage = float(80, 1, 99)
#@gui : Parts = choice[0, "x1", "x2", "x3", "x4", "Continuous"]
#@gui : sep = separator()
#@gui : note = note("<b>Colors:</b>")
#@gui : Type = choice[0, "Red-Green-Blue Model", "Red-Yellow-Blue Model", "Opponent Model"]
#@gui : sep = separator()
#@gui : note = note("<b>Rotation:</b>")
#@gui : Inverse Order = bool(0)
#@gui : Rotation = float(0, 0, 360)
#@gui : sep = separator()
#@gui : note = note("<small>Author: <i>Claude Lion</i>. Latest Update: <i>2024/01/23</i>.</small>")

cl_colorWheel_prerelease:
   
   extCircle,intCirclePercent,parts,type,invert,rot=$*
   
   wid={$extCircle*2.5}
   hig=$wid
   intCircle={$extCircle*$intCirclePercent/100}
   
   if $type==2
      base=2
   else
      base=3
   fi
   
   if $parts<=3
      mult={$parts+1}
   else
      mult=60
   fi
   
   nbParts={$base*$mult}

   if $type==0
      formula="ang"
   elif $type==1
      formula="if(ang<120,ang/2,if(ang<180,ang-60,if(ang<240,ang*2-240,ang)))"
   elif $type==2
      formula="if(ang<180,ang*2/3,ang*4/3-120)"
   fi

   $wid,$hig,1,1
   
   local.
      fill. "r = sqrt((x-w/2)^2+ (y-h/2)^2);
         ang=atan2(y-h/2,x-w/2);
         "angd=((1-2*$invert)*ang-$rot*pi/180+pi);"
         "ang=(angd/2/pi-floor(angd/2/pi))*2*pi-pi;"
         "angp=$nbParts*ang/pi+0.5;"
         "rnd=floor(angp);"
         "frc=angp-rnd;"
         "ang=(rnd-1+cut(frc*r*pi/$nbParts,0,1))*pi/$nbParts;"
         ang=180*ang/pi+180;
         "ang=$formula;"
         "($intCircle<r&&r<$extCircle)*ang"
      "
      $wid,$hig,1,1,1
      $wid,$hig,1,1,1
      $wid,$hig,1,1,1
      fill. "r = sqrt((x-w/2)^2+ (y-h/2)^2);
         "cut(r-$intCircle,0,1)*cut($extCircle-r,0,1)*255"
      "
      a c
      hsv2rgb.
   done
   mv[-1] 0


Installation:
  • Copy and paste the above code into the file "~/.gmic" on Linux or the file "%APPDATA%\user.gmic" on Windows.
  • The new filter appears in "Filters -> G'MIC -> Rendering -> Color Wheel (prerelease)".

Have fun! :)

Author:  grosood [ Thu Jan 25, 2024 3:45 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

That looks like fun!
Planning on moving it into gmic-community/include/claude_lion.gmic?

Author:  cli345 [ Thu Jan 25, 2024 3:52 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Yes! Thanks for your kind comment! :)

Author:  Reptorian [ Fri Jan 26, 2024 4:19 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Reminds me of a lot of this filter I made called "Color Harmonies":

Image

It probably needs refactoring like the other filters I am refactoring slowly over time as in I only do G'MIC stuff on the weekend.

Author:  cli345 [ Fri Jan 26, 2024 4:50 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Your filter seems excellent to me :bigthup. Maybe, it would be better placed in the "Colors" category! :)

Author:  Reptorian [ Tue Jan 30, 2024 3:05 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Just checking in, how's the filter going so far?

Author:  cli345 [ Sun Feb 25, 2024 10:51 am ]
Post subject:  Re: New G'MIC filter "Color Wheel"

For me, it works well: I get the various related colors to make a color harmony. :)

Author:  Reptorian [ Sun Feb 25, 2024 8:02 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

cli345 wrote:
For me, it works well: I get the various related colors to make a color harmony. :)

Great! When you make a pull request, I'm be sure to approve it.

Author:  PixLab [ Tue Mar 12, 2024 11:35 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Nice wheel cli345 :clap
I added this code below on top of your code, as I have some code before in my "~/.gmic" and your wheel was in "Deformations" due to the code above :hehe
#@gui ____<b>Colors</b>
#------------------
#@gui Color Wheel (prerelease): cl_colorWheel_prerelease, cl_colorWheel_prerelease(0)
#@blablabla....

If I may, the only thing is that the result does not respect the size of the canvas, that would be a plus+ if the result would be on a layer of the canvas size (G'MIC 3.3.5 / GIMP 2.10.36 ), anyway it's very nice, thank you :tyspin

EDIT: forget what I said about the canvas size, I moved the External Circle Radius slider... and result get bigger :bigthup (sorry, I was asleep :oops: )
Attachment:
screenshot_20240313-122725.jpg
screenshot_20240313-122725.jpg [ 67.5 KiB | Viewed 611 times ]

Author:  cli345 [ Wed Mar 13, 2024 1:28 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Thank you, PixLab :). Indeed, I've forgotten to include the category.

As it builds a new stuff, I believed that the best category is "Rendering" but maybe I should put it into "Colors".

What do you think about it? "Rendering" or "Colors"?

Author:  Reptorian [ Wed Mar 13, 2024 11:30 pm ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Rendering because filters within Colors still retain spatial structure. Retaining spatial structure means you can see the earlier image.

Author:  PixLab [ Thu Mar 14, 2024 4:00 am ]
Post subject:  Re: New G'MIC filter "Color Wheel"

Hi cli345,
Um... now that you mention "Rendering" (which it does), I don't know, because it's color.... but rendered :hehe
In the end Reptorian and You are right IMHO, "Rendering" is certainly the best category :bigthup

Author:  cli345 [ Fri Mar 15, 2024 9:08 am ]
Post subject:  Re: New G'MIC filter "Color Wheel"

OK, Thanks. I'm going to make the pull request.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/