text outlines

This commit is contained in:
Gavin McDonald
2025-05-06 15:39:48 -04:00
parent 2d5dbd4140
commit 92f469c982
4 changed files with 23 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ defmodule LabelmakerWeb.Constants do
label: "64 character maximum",
font: "Helvetica",
color: "black",
outline: "none",
size: "24"
}
@@ -24,6 +25,8 @@ defmodule LabelmakerWeb.Constants do
@max_label_length 64
@outlines ~w(none white black gray)
@sizes 8..72
|> Enum.to_list()
|> Enum.take_every(4)
@@ -35,6 +38,7 @@ defmodule LabelmakerWeb.Constants do
def fonts, do: @fonts
def font_count, do: @fonts |> length()
def max_label_length, do: @max_label_length
def outlines, do: @outlines
def permitted_keys, do: @permitted_keys
def sizes, do: @sizes
end

View File

@@ -43,6 +43,18 @@ defmodule LabelmakerWeb.LabelController do
filepath
]
args =
if options.outline != "none" do
[
"-stroke",
options.outline,
"-strokewidth",
"1"
] ++ args
else
args
end
{_, 0} = System.cmd("magick", args)
end
end

View File

@@ -8,7 +8,7 @@ defmodule LabelmakerWeb.Home do
:ok,
assign(
socket,
Enum.to_list(Constants.defaults())
Enum.to_list(%{Constants.defaults() | label: ""})
)
}
end
@@ -42,6 +42,11 @@ defmodule LabelmakerWeb.Home do
<option value={color} selected={@color == color}>{color}</option>
<% end %>
</select>
<select name="outline" value={@outline}>
<%= for outline <- Constants.outlines() do %>
<option value={outline} selected={@outline == outline}>{outline}</option>
<% end %>
</select>
<select name="size" value={@size}>
<%= for size <- Constants.sizes() do %>
<option value={size} selected={@size == size}>{size}</option>

View File

@@ -11,6 +11,7 @@ defmodule LabelmakerWeb.Tools do
:color -> v in Constants.colors()
:font -> v in Constants.fonts()
:label -> String.length(v) <= Constants.max_label_length()
:outline -> v in Constants.outlines()
:size -> v in Constants.sizes()
_ -> true
end