From 63b27a8388ed3ca24739e94336374d6ac517153d Mon Sep 17 00:00:00 2001 From: Ju Liu Date: Sun, 3 Mar 2019 11:30:20 +0000 Subject: [PATCH] run formatter and add a squiggly line --- .formatter.exs | 4 ++++ .gitignore | 28 ++++++++++++++++++++++++++ README.md | 4 ++++ config/config.exs | 25 +++++++++++++++++++++++ lib/scenes/home.ex | 47 ++++++++++++++++++++++++++++++++++++++++++++ lib/scenic_escher.ex | 17 ++++++++++++++++ mix.exs | 30 ++++++++++++++++++++++++++++ mix.lock | 5 +++++ 8 files changed, 160 insertions(+) create mode 100644 .formatter.exs create mode 100644 .gitignore create mode 100644 README.md create mode 100644 config/config.exs create mode 100644 lib/scenes/home.ex create mode 100644 lib/scenic_escher.ex create mode 100644 mix.exs create mode 100644 mix.lock diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d943287 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where 3rd-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +foo-*.tar + + +# Ignore scripts marked as secret - usually passwords and such in config files +*.secret.exs +*.secrets.exs diff --git a/README.md b/README.md new file mode 100644 index 0000000..8739df8 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Readme text goes here + + +From template \ No newline at end of file diff --git a/config/config.exs b/config/config.exs new file mode 100644 index 0000000..dca5180 --- /dev/null +++ b/config/config.exs @@ -0,0 +1,25 @@ +# This file is responsible for configuring your application +# and its dependencies with the aid of the Mix.Config module. +use Mix.Config + +# Configure the main viewport for the Scenic application +config :scenic_escher, :viewport, %{ + name: :main_viewport, + size: {700, 600}, + default_scene: {ScenicEscher.Scene.Home, nil}, + drivers: [ + %{ + module: Scenic.Driver.Glfw, + name: :glfw, + opts: [resizeable: false, title: "scenic_escher"] + } + ] +} + +# It is also possible to import configuration files, relative to this +# directory. For example, you can emulate configuration per environment +# by uncommenting the line below and defining dev.exs, test.exs and such. +# Configuration from the imported file will override the ones defined +# here (which is why it is important to import them last). +# +# import_config "prod.exs" diff --git a/lib/scenes/home.ex b/lib/scenes/home.ex new file mode 100644 index 0000000..c0912e5 --- /dev/null +++ b/lib/scenes/home.ex @@ -0,0 +1,47 @@ +defmodule ScenicEscher.Scene.Home do + use Scenic.Scene + + alias Scenic.Graph + + import Scenic.Primitives + # import Scenic.Components + + @note """ + This is a very simple starter application. + + If you want a more full-on example, please start from: + + mix scenic.new.example + """ + + @graph Graph.build(font: :roboto, font_size: 24) + |> group( + fn g -> + g + |> text(@note, translate: {20, 60}) + |> path( + [ + :begin, + {:move_to, 0, 0}, + {:bezier_to, 0, 20, 0, 50, 40, 50}, + {:bezier_to, 60, 50, 60, 20, 80, 20}, + {:bezier_to, 100, 20, 110, 0, 120, 0}, + {:bezier_to, 140, 0, 160, 30, 160, 50} + ], + stroke: {2, :red}, + translate: {355, 230}, + rotate: 0.5 + ) + end, + translate: {15, 20} + ) + + # ============================================================================ + # setup + + # -------------------------------------------------------- + def init(_, _) do + push_graph(@graph) + {:ok, @graph} + end +end diff --git a/lib/scenic_escher.ex b/lib/scenic_escher.ex new file mode 100644 index 0000000..45f9867 --- /dev/null +++ b/lib/scenic_escher.ex @@ -0,0 +1,17 @@ +defmodule ScenicEscher do + @moduledoc """ + Starter application using the Scenic framework. + """ + + def start(_type, _args) do + # load the viewport configuration from config + main_viewport_config = Application.get_env(:scenic_escher, :viewport) + + # start the application with the viewport + children = [ + {Scenic, viewports: [main_viewport_config]} + ] + + Supervisor.start_link(children, strategy: :one_for_one) + end +end diff --git a/mix.exs b/mix.exs new file mode 100644 index 0000000..2acd1ab --- /dev/null +++ b/mix.exs @@ -0,0 +1,30 @@ +defmodule ScenicEscher.MixProject do + use Mix.Project + + def project do + [ + app: :scenic_escher, + version: "0.1.0", + elixir: "~> 1.7", + build_embedded: true, + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + mod: {ScenicEscher, []}, + extra_applications: [] + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + {:scenic, "~> 0.9"}, + {:scenic_driver_glfw, "~> 0.9", targets: :host} + ] + end +end diff --git a/mix.lock b/mix.lock new file mode 100644 index 0000000..bd469e3 --- /dev/null +++ b/mix.lock @@ -0,0 +1,5 @@ +%{ + "elixir_make": {:hex, :elixir_make, "0.5.2", "96a28c79f5b8d34879cd95ebc04d2a0d678cfbbd3e74c43cb63a76adf0ee8054", [:mix], [], "hexpm"}, + "scenic": {:hex, :scenic, "0.9.0", "129594f918b4e2dd97465b95b4fb3582294ac6bb3e931f12edd09913743964eb", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm"}, + "scenic_driver_glfw": {:hex, :scenic_driver_glfw, "0.9.1", "b64d345929007186c6b2ca603aec21b1fdde758d3eb32f8467a236e58ccd6a19", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:scenic, "~> 0.9", [hex: :scenic, repo: "hexpm", optional: false]}], "hexpm"}, +}