My First Honeycomb design using GMIC

For a very long time I wanted to create this design in GIMP, but I didn’t know how to write a script either in Script-Fu or GMIC. Almost after a decade I gave another shot with some help from AI, I figured out how to create one.

Heartfelt thanks for the creators of GMIC and the community, appreciate it very much.

GMIC script:

#@gui _<b>Rajasegar</b>
#@gui Hexagon Grid : fx_hexagon_grid, fx_hexagon_grid
#@gui : Hexagon Radius = int(60,10,200)
#@gui : Color mode = choice("Random", "Patterned")
# Urban Garden color palette
#@gui : Color 1 = ~color(9,70,72)
#@gui : Color 2 = ~color(5,99,98)
#@gui : Color 3 = ~color(75,132,75)
#@gui : Color 4 = ~color(180,178,54)
#@gui : Color 5 = ~color(220,226,192)

fx_hexagon_grid:
    skip ${1=50},${2=0},\
         ${3=2},${4=58},${5=56},\
         ${6=6},${7=88},${8=91},\
         ${9=183},${10=103},${11=174},\
         ${12=255},${13=119},${14=66},\
         ${15=255},${16=200},${17=71}


  # $1 = Hexagon radius (size)
  # $2 = Color mode (0 = Random, 1 = Patterned)

  # 1. Define canvas size based on current image or create a new one
  if {l}==0
    800,600,1,3,255 
  fi

  # 2. Define the 5 predefined colors as a single vector string
  # Format: [R0,G0,B0, R1,G1,B1, ...]
  # palette=[239,71,111,247,141,43,255,209,102,6,214,160,17,138,178]
  # palette=[{$3},{$4},{$5},{$6},{$7},{$8},{$9},{$10},{$11},{$12},{$13},{$14},{$15},{$16},{$17}]

  # getting the palette colors from the arguments
  palette=[${3--1}] # getting all the other arguments except the first two

  # 3. Grid geometry math
  r=$1                          # Outer radius
  h={($r*sqrt(3))/2}            # Half-height of the hexagon
  cx={$r*1.5}                   # Horizontal spacing between columns
  cy={$h*2}                     # Vertical spacing between rows

  # Calculate how many columns/rows we need to fill the canvas
  cols={int(w/$cx)+2}
  rows={int(h/$cy)+2}


  # 4. Loop through the grid
  y=0
  -for $y<$rows
    x=0
    -for $x<$cols

      # Calculate center coordinates for the hexagon
      # Every odd column needs to be shifted vertically by 'h' to interlock
      cen_x={$x*$cx}
      cen_y={($y*$cy)+($x%2?$h:0)}

      # Pick one of the 5 colors
      -if $2==0
        # Mode 0: Completely random choice
        col_index={int(u(0,5))}
      -else
        # Mode 1: Algorithmic pattern based on grid position
        col_index={($x+$y*2)%5}
      -fi

      # Correct G'MIC math parser syntax to extract RGB values from the palette vector
      r_val={val_r=$palette[3*$col_index]}
      g_val={val_g=$palette[3*$col_index+1]}
      b_val={val_b=$palette[3*$col_index+2]}


      # 5. Draw the hexagon using the 'polygon' command (6 vertices)
      # Uses the parametric equation: x + r*cos(a), y + r*sin(a)
      -polygon 6,\
               {$cen_x+$r},\
               $cen_y,\
               {$cen_x+$r*cos(pi/3)},\
               {$cen_y+$r*sin(pi/3)},\
               {$cen_x+$r*cos(2*pi/3)},\
               {$cen_y+$r*sin(2*pi/3)},\
               {$cen_x-$r},\
               $cen_y,\
               {$cen_x+$r*cos(4*pi/3)},\
               {$cen_y+$r*sin(4*pi/3)},\
               {$cen_x+$r*cos(5*pi/3)},\
               {$cen_y+$r*sin(5*pi/3)},\
                1,$r_val,$g_val,$b_val
       x+=1
    -done
    y+=1
  -done

fx_smooth_antialias 5,10,0.8
2 Likes