Skip to content

Commit 8015a1c

Browse files
authored
Merge pull request #282 from boydm/v0.11
V0.11
2 parents 42eabb2 + f260247 commit 8015a1c

File tree

16 files changed

+123
-92
lines changed

16 files changed

+123
-92
lines changed

guides/getting_started.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
This guide will walk you through installing the new project generator, then
44
building your first Scenic application.
55

6-
Some initial setup is required for windows. You'll need
7-
windows services for linux (WSL) and VcXsrv,
8-
[Jeffrey Borchert's article details these steps.](https://medium.com/@jeffborch/running-the-scenic-elixir-gui-framework-on-windows-10-using-wsl-f9c01fd276f6)
9-
You'll come back here to finish.
6+
## Install Dependencies
7+
8+
See [Install Dependencies](install_dependencies.html)
109

1110
## Install `scenic.new`
1211

guides/install_dependencies.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ The design of Scenic goes to great lengths to minimize its dependencies to just
44
the minimum. Namely, it needs Erlang/Elixir and OpenGL.
55

66
Rendering your application into a window on your local computer (MacOS, Ubuntu
7-
and others) is done by the `scenic_driver_glfw` driver. It uses the GLFW and
8-
GLEW libraries to connect to OpenGL.
7+
and others) is done by the
8+
[`scenic_driver_local`](https://github.com/ScenicFramework/scenic_driver_local)
9+
driver. It uses the GLFW and GLEW libraries to connect to OpenGL.
910

1011
The instructions below assume you have already installed Elixir/Erlang. If you
1112
need to install Elixir/Erlang there are instructions on the [elixir-lang
@@ -22,7 +23,13 @@ brew install glfw3 glew pkg-config
2223
```
2324

2425
Once these components have been installed, you should be able to build the
25-
`scenic_driver_glfw` driver.
26+
`scenic_driver_local` driver.
27+
28+
## On Windows
29+
30+
Some initial setup is required for windows. You'll need windows services for
31+
linux (WSL) and VcXsrv, [Jeffrey Borchert's article details these
32+
steps.](https://medium.com/@jeffborch/running-the-scenic-elixir-gui-framework-on-windows-10-using-wsl-f9c01fd276f6)
2633

2734
## On Ubuntu 16
2835

guides/upgrading_to_v0.11.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ defmodule MyDevice.Scene.Example do
208208

209209
# display any received events
210210
def handle_event(event, _, %{assigns: %{graph: graph}} = scene) do
211-
graph = Graph.modify( graph, :text, &text(&1, inspect(event))
211+
graph = Graph.modify( graph, :text, &text(&1, inspect(event)))
212212

213213
scene =
214214
scene

lib/scenic/color.ex

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ defmodule Scenic.Color do
156156
yellow_green: {0x9A, 0xCD, 0x32}
157157
}
158158

159+
@g :color_g
160+
@ga :color_ga
161+
@rgb :color_rgb
162+
@rgba :color_rgba
163+
@hsv :color_hsv
164+
@hsl :color_hsl
165+
159166
@moduledoc """
160167
APIs to create and work with colors.
161168
@@ -180,15 +187,15 @@ defmodule Scenic.Color do
180187
For HSL and HSV, h is a float between 0 and 360, while the s, v and l values
181188
are floats between 0 and 100.
182189
183-
| Format | Implicit | Explicit |
184-
|---------------|------------------------|-----------|
185-
| Named Color | *na* | See the Named Color Table |
186-
| Grayscale | `g` | `{:g, g}` |
187-
| Gray, Alpha | `{g, a}` | `{:g, {g, a}}` |
188-
| Red, Green, Blue | `{r, g, b}` | `{:rgb, {r, g, b}}` |
189-
| Red, Green, Blue, Alpha | `{r, g, b, a}` | `{:rgba, {r, g, b, a}}` |
190-
| Hue, Saturation, Value | *na* | `{:hsv, {h, s, v}}` |
191-
| Hue, Saturation, Lightness | *na* | `{:hsl, {h, s, l}}` |
190+
| Format | Implicit | Explicit |
191+
|----------------------------|----------------|-----------------------------|
192+
| Named Color | *na* | See the Named Color Table |
193+
| Grayscale | `g` | `{:#{@g}, g}` |
194+
| Gray, Alpha | `{g, a}` | `{:#{@ga}, {g, a}}` |
195+
| Red, Green, Blue | `{r, g, b}` | `{:#{@rgb}, {r, g, b}}` |
196+
| Red, Green, Blue, Alpha | `{r, g, b, a}` | `{:#{@rgba}, {r, g, b, a}}` |
197+
| Hue, Saturation, Value | *na* | `{:#{@hsv}, {h, s, v}}` |
198+
| Hue, Saturation, Lightness | *na* | `{:#{@hsl}, {h, s, l}}` |
192199
193200
194201
## Named Colors
@@ -204,26 +211,29 @@ defmodule Scenic.Color do
204211
205212
## Additional Named Colors
206213
207-
| Name | Value |
208-
|---------------|------------------------|
209-
| `:clear` | `{0x80, 0x80, 0x80, 0x00}` |
214+
| Name | Value |
215+
|---------------|-----------------------------|
216+
| `:clear` | `{0x80, 0x80, 0x80, 0x00}` |
210217
| `:transparent` | `{0x80, 0x80, 0x80, 0x00}` |
211218
212219
## Converting Between Color Formats
213220
214-
By using the functions `to_g`, `to_ga`, `to_rgb`, `to_rgb`, `to_hsl`, and `to_hsv`
215-
you can convert between any implicit or explicit color type to any explicit color type.
221+
By using the functions `to_g/1`, `to_ga/1`, `to_rgb/1`, `to_rgb/1`,
222+
`to_hsl/1`, and `to_hsv/1` you can convert between any implicit or explicit
223+
color type to any explicit color type.
216224
"""
217225

218-
# import IEx
219-
220226
@g :color_g
221227
@ga :color_ga
222228
@rgb :color_rgb
223229
@rgba :color_rgba
224230
@hsv :color_hsv
225231
@hsl :color_hsl
226232

233+
# Epsilon value from JS
234+
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON
235+
@epsilon 2.22044e-16
236+
227237
@type implicit ::
228238
atom
229239
| {name :: atom, a :: integer}
@@ -534,9 +544,9 @@ defmodule Scenic.Color do
534544
l = (max + min) / 2
535545

536546
s =
537-
case delta do
538-
0 -> 0
539-
d -> d / (1 - abs(2 * l - 1))
547+
cond do
548+
delta < @epsilon -> 0.0
549+
true -> delta / (1 - abs(2 * l - 1))
540550
end
541551

542552
{h, s * 100, l * 100}

lib/scenic/component.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,8 @@ defmodule Scenic.Component do
210210
# --------------------------------------------------------
211211
defoverridable add_to_graph: 3
212212
end
213-
214-
# quote
215213
end
216214

217-
# defmacro
218-
219215
@filter_out [
220216
:cap,
221217
:fill,
@@ -240,7 +236,6 @@ defmodule Scenic.Component do
240236
# prepare the list of opts to send to a component as it is being started up
241237
# the main task is to remove styles that have already been consumed or don't make
242238
# sense, while leaving any opts/styles that are intended for the component itself.
243-
# also, add the viewport as an option.
244239
@doc false
245240
@spec filter_opts(opts :: Keyword.t()) :: Keyword.t()
246241
def filter_opts(opts) when is_list(opts) do

lib/scenic/driver.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,11 @@ defmodule Scenic.Driver do
887887
name: [type: :atom]
888888
]
889889

890-
@doc false
890+
@doc """
891+
Validate driver configuration
892+
893+
Used primarily for dynamic view port creation
894+
"""
891895
def validate([]), do: {:ok, []}
892896

893897
def validate(drivers) do

lib/scenic/graph.ex

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ defmodule Scenic.Graph do
6868
that new primitives added to it are inserted into the new group instead of the
6969
root of the graph.
7070
71-
Finally, when the group is finished, a translation matrix and a `:text_align` style
72-
are added to it. These properties are _inherited_ by the primitives in the group.
71+
Finally, when the group is finished, a translation matrix and a `:text_align`
72+
style (see `Scenic.Primitive.Style.TextAlign`) are added to it. These
73+
properties are _inherited_ by the primitives in the group.
7374
7475
## Inheritance
7576
@@ -575,15 +576,13 @@ defmodule Scenic.Graph do
575576
576577
Pass in a function that accepts a primitive and returns a boolean.
577578
578-
Returns a list of tuples containing the matching id at the primitive.
579-
580-
`[{id, primitive}]`
579+
Returns a list of primitives.
581580
582581
__Warning:__ This function crawls the entire graph and is thus slower than
583582
accessing items via a fully-specified id.
584583
"""
585584

586-
@spec find(graph :: t(), (any -> as_boolean(term()))) :: list({any, Primitive.t()})
585+
@spec find(graph :: t(), (any -> as_boolean(term()))) :: list(Primitive.t())
587586
def find(graph, finder)
588587

589588
# pass in an atom based id, and it will transform all mapped uids

lib/scenic/primitive.ex

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ defmodule Scenic.Primitive do
2020
## How to use primitives
2121
2222
By far, the easiest way to use primitives is to import the helper functions in
23-
[`Scenic.Primitives`](Scenic.Primitives.html). These helpers can both add primitives to
23+
`Scenic.Primitives`. These helpers can both add primitives to
2424
a scene you are building and modify later as you react to events.
2525
2626
```elixir
2727
import Scenic.Primitives
2828
2929
@graph Scenic.Graph.build()
30-
|> rect( {100, 50}, stroke: {1, :yellow} )
31-
|> rectangle( {100, 50}, stroke: {1, :yellow} )
30+
|> rect({100, 50}, stroke: {1, :yellow})
31+
|> rectangle({100, 50}, stroke: {1, :yellow})
3232
```
3333
3434
Once you get a primitive out of a graph via functions such as `Graph.modify`, or `Graph.get`,
@@ -44,21 +44,20 @@ defmodule Scenic.Primitive do
4444
4545
| Helper | Primitive Module | Description |
4646
|---|---|---|
47-
| [`arc/3`](Scenic.Primitives.html#arc/3) | `Scenic.Primitive.Arc` | Draw an arc around a circle |
48-
| [`circle/3`](Scenic.Components.html#circle/3) | `Scenic.Primitive.Circle` | Draw a full circle |
49-
| [`component/3`](Scenic.Primitives.html#component/3) | `Scenic.Primitive.Component` | Start a child component |
50-
| [`ellipse/3`](Scenic.Primitives.html#ellipse/3) | `Scenic.Primitive.Ellipse` | Draw an ellipse |
51-
| [`group/3`](Scenic.Primitives.html#group/3) | `Scenic.Primitive.Group` | Create a group |
52-
| [`line/3`](Scenic.Primitives.html#line/3) | `Scenic.Primitive.Line` | Draw a line |
53-
| [`path/3`](Scenic.Primitives.html#path/3) | `Scenic.Primitive.Path` | Draw a complicated path |
54-
| [`quad/3`](Scenic.Primitives.html#quad/3) | `Scenic.Primitive.Quad` | Draw a quad |
55-
| [`rect/3`](Scenic.Primitives.html#rect/3) | `Scenic.Primitive.Rectangle` | Draw a rectangle |
56-
| [`rrect/3`](Scenic.Primitives.html#rrect/3) | `Scenic.Primitive.RoundedRectangle` | Draw a rounded rectangle |
57-
| [`script/3`](Scenic.Primitives.html#script/3) | `Scenic.Primitive.Script` | Run a referenced draw script |
58-
| [`sector/3`](Scenic.Primitives.html#sector/3) | `Scenic.Primitive.Sector` | A boolean toggle control. |
59-
| [`sprites/3`](Scenic.Primitives.html#sprites/3) | `Scenic.Primitive.Sprites` | Draw a sector |
60-
| [`text/3`](Scenic.Primitives.html#text/3) | `Scenic.Primitive.Text` | Draw a string of text |
61-
| [`triangle/3`](Scenic.Primitives.html#triangle/3) | `Scenic.Primitive.Triangle` | Draw a triangle |
47+
| [`arc/3`](`Scenic.Primitives.arc/3`) | `Scenic.Primitive.Arc` | Draw an arc around a circle |
48+
| [`circle/3`](`Scenic.Primitives.circle/3`) | `Scenic.Primitive.Circle` | Draw a full circle |
49+
| [`ellipse/3`](`Scenic.Primitives.ellipse/3`) | `Scenic.Primitive.Ellipse` | Draw an ellipse |
50+
| [`group/3`](`Scenic.Primitives.group/3`) | `Scenic.Primitive.Group` | Create a group |
51+
| [`line/3`](`Scenic.Primitives.line/3`) | `Scenic.Primitive.Line` | Draw a line |
52+
| [`path/3`](`Scenic.Primitives.path/3`) | `Scenic.Primitive.Path` | Draw a complicated path |
53+
| [`quad/3`](`Scenic.Primitives.quad/3`) | `Scenic.Primitive.Quad` | Draw a quad |
54+
| [`rect/3`](`Scenic.Primitives.rect/3`) | `Scenic.Primitive.Rectangle` | Draw a rectangle |
55+
| [`rrect/3`](`Scenic.Primitives.rrect/3`) | `Scenic.Primitive.RoundedRectangle` | Draw a rounded rectangle |
56+
| [`script/3`](`Scenic.Primitives.script/3`) | `Scenic.Primitive.Script` | Run a referenced draw script |
57+
| [`sector/3`](`Scenic.Primitives.sector/3`) | `Scenic.Primitive.Sector` | A boolean toggle control. |
58+
| [`sprites/3`](`Scenic.Primitives.sprites/3`) | `Scenic.Primitive.Sprites` | Draw a sector |
59+
| [`text/3`](`Scenic.Primitives.text/3`) | `Scenic.Primitive.Text` | Draw a string of text |
60+
| [`triangle/3`](`Scenic.Primitives.triangle/3`) | `Scenic.Primitive.Triangle` | Draw a triangle |
6261
"""
6362

6463
alias Scenic.Graph
@@ -145,12 +144,8 @@ defmodule Scenic.Primitive do
145144
contains_point?: 2,
146145
default_pin: 1
147146
end
148-
149-
# quote
150147
end
151148

152-
# defmacro
153-
154149
# ============================================================================
155150
# build and add
156151

@@ -163,7 +158,7 @@ defmodule Scenic.Primitive do
163158
Generic builder to create a new primitive.
164159
165160
This function is used internally. You should almost always use the helpers in
166-
[Scenic.Primitives](Scenic.Primitives.html) instead.
161+
`Scenic.Primitives` instead.
167162
168163
Parameters:
169164
* `module` - The module of the primitive you are building
@@ -501,8 +496,8 @@ defmodule Scenic.Primitive do
501496
@doc """
502497
Put primitive-specific data onto the primitive.
503498
504-
Like many of the functions in the Scenic.Primitive module, you are usually better
505-
off using the helper functions in [`Scenic.Primitives`](Scenic.Primitives.html) instead.
499+
Like many of the functions in the `Scenic.Primitive` module, you are usually better
500+
off using the helper functions in `Scenic.Primitives` instead.
506501
507502
Parameters:
508503
* `primitive` - The primitive

lib/scenic/primitive/component.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ defmodule Scenic.Primitive.Component do
77
@moduledoc """
88
Add a child component to a graph.
99
10-
When a scene pushes a graph containing a Component to it's ViewPort,
10+
When a scene pushes a graph containing a Component to its ViewPort,
1111
a new scene, containing the component, is created and added as a child
1212
to the scene that created it.
1313
1414
Any events the new component creates are sent up the parent. The parent
15-
can use functions in the Scenic.Scene module to manage it's children,
15+
can use functions in the `Scenic.Scene` module to manage its children,
1616
send them messages and such.
1717
1818
The standard components, such as button, slider, etc. have wrapper functions
1919
making them very easy to add to a graph. However, if you have a custom
20-
component you can add it to any graph manually using the add_to_graph
20+
component you can add it to any graph manually using the `add_to_graph/3`
2121
function.
2222
23-
You typically want to give components an :id. This will be used to identify
23+
You typically want to give components an `:id`. This will be used to identify
2424
events coming from that components back to your scene.
2525
2626
```elixir
2727
import Components # contains the button helper
2828
2929
graph
30-
|> button( "Press Me", id: :press_me )
31-
|> MyComponent.add_to_graph( {"Some data", 123}, id: :my_component )
30+
|> button("Press Me", id: :press_me)
31+
|> MyComponent.add_to_graph({"Some data", 123}, id: :my_component)
3232
```
3333
3434
"""

lib/scenic/primitive/style/text_align.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Scenic.Primitive.Style.TextAlign do
1111
1212
```elixir
1313
graph
14-
|> text( "Some Text", text_align: :center_middle )
14+
|> text("Some Text", text_align: :center)
1515
```
1616
1717
### Data Format

0 commit comments

Comments
 (0)