Skip to content
Snippets Groups Projects
Select Git revision
  • 429423113648c1e6f9e01786beab3958f90515a5
  • master default protected
2 results

castle.ml

  • castle.ml 4.99 KiB
    let grays =
      let open Colors in
      Combinator.gradient
        ~n:100
        Pure.silver
        Pure.gray
    
    let blues =
      let open Colors in
      Combinator.gradient
        ~n:100
        Pure.cornflowerblue
        Pure.steelblue
    
    
    let browns =
      let open Colors in
      Combinator.gradient
        ~n:100
        Pure.saddlebrown
        Pure.maroon
    
    
    let brick =
      let open Generator in
      sample grays @@ fun color ->
      block ~width:2 ~height:1 |> color
    
    let hbrick =
      let open Generator in
      sample grays @@ fun color ->
      block ~width:1 ~height:1 |> color
    
    let tile =
      let open Generator in
      sample blues @@ fun color ->
      block ~width:1 ~height:1 |> color
    
    let wall_layer ~width =
      let open Generator in
      if width = 1 then
        hbrick
      else if width mod 2 = 0 then
        pack_horizontally ~n:(width/2) brick
      else
        pack_horizontally ~n:(width/2) brick |> left_of hbrick
    
    let shifted_wall_layer ~width =
      let open Generator in 
      if width = 1 then
        hbrick
      else
        hbrick |> left_of (wall_layer ~width:(width-1))
    
    
    let rec wall ~width ~height =
      let open Generator in 
      if height = 1 then
        wall_layer ~width
      else if height mod 2 = 0 then
        shifted_wall_layer ~width
        |> above (wall_layer ~width)
        |> pack_vertically ~n:(height/2)
      else
        wall_layer ~width
        |> above (wall ~width ~height:(height-1))
    
    
    let crenellation ~width =
      let open Generator in