Skip to content

Instantly share code, notes, and snippets.

@shahryarjb
Created April 23, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahryarjb/7c57db5ca4e61ff940c6252f69360d62 to your computer and use it in GitHub Desktop.
Save shahryarjb/7c57db5ca4e61ff940c6252f69360d62 to your computer and use it in GitHub Desktop.
# my blog : https://trangell.com/fa/
# public : http://iranonrails.ir
defmodule Canvas do
@defaults [ fg: "black", bg: "white", font: "Merriweather" ]
def draw_text(text, options \\ []) do
options = Keyword.merge(@defaults, options)
IO.puts "Drawing text #{inspect(text)}"
IO.puts "Foreground: #{options[:fg]}"
IO.puts "Background: #{Keyword.get(options, :bg)}"
IO.puts "Font: #{Keyword.get(options, :font)}"
IO.puts "Pattern: #{Keyword.get(options, :pattern, "solid")}"
IO.puts "Style: #{inspect Keyword.get_values(options, :style)}"
end
end
Canvas.draw_text("hello", fg: "red", style: "italic", style: "bold")
# Drawing text "hello"
# Foreground: red
# Background: white
# Font: Merriweather
# Pattern: solid
# Style: ["italic", "bold"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment