Add Custom Guides

I’ve tried. It was easy :smiley:

here’s the script. If you have script manager place it into say guides dir and have a go:

--[[
  Custom dynamic symmetry guide for darktable

  copyright (c) 2021  Hubert Kowalski
  
  darktable is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  darktable is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with darktable.  If not, see <http://www.gnu.org/licenses/>.
]]

--[[
DYNAMIC SYMMETRY GUIDE
guide based on custom symmetry from Sandy Adriadi
https://discuss.pixls.us/t/add-custom-guides/26288/5?u=johnny-bit

INSTALLATION
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
* add the following line in the file $CONFIGDIR/luarc
  require "dynamic_symmetry"


USAGE
* when using the cropping tool, select "dynamic symmetry" as guide
]]

local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext

du.check_min_api_version("2.0.0", "dynamic_symmetry") 

-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("dynamic_symmetry",dt.configuration.config_dir.."/lua/locale/")

local function _(msgid)
  return gettext.dgettext("dynamic_symmetry", msgid)
end

dt.guides.register_guide("dynamic symmetry",
-- draw
function(cairo, x, y, width, height, zoom_scale)
  cairo:save()

  cairo:translate(x, y)
  cairo:scale(width, height)


  cairo:move_to(0,0)
  cairo:line_to(1, 0.5)
  cairo:line_to(0.5, 1)
  cairo:line_to(0,0)
  cairo:line_to(1, 1)
  cairo:line_to(0.5, 0)
  cairo:line_to(0, 0.5)
  cairo:line_to(1, 1)

  cairo:move_to(1, 0)
  cairo:line_to(0, 0.5)
  cairo:line_to(0.5, 1)
  cairo:line_to(1, 0)
  cairo:line_to(0, 1)
  cairo:line_to(0.5, 0)
  cairo:line_to(1, 0.5)
  cairo:line_to(0, 1)

  cairo:move_to(0,0.5)
  cairo:line_to(1,0.5)
  cairo:move_to(0.5,0)
  cairo:line_to(0.5,1)

  cairo:restore()
end,
-- gui
function()
  return dt.new_widget("label"){label = _("dynamic symmetry"), halign = "start"}
end
)
5 Likes