Skip to content

Commit abfdf4e

Browse files
committed
clean up and add changelog notes
1 parent a3a00b1 commit abfdf4e

File tree

2 files changed

+56
-32
lines changed

2 files changed

+56
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
* Much improved testing
55
* Simplify rules around user-closing a viewport
66
* Fix bug where captured positional inputs were not casting the transformed location
7-
* Deprecate Graph.get_root(). Use Graph.get!(graph, :\_root\_) instead.
7+
* Deprecated Graph.get_root(). Use Graph.get!(graph, :\_root\_) instead.
88
* Renamed Primitive.put_opts to Primitive.merge_opts
9+
* Deprecated Primitive.put_style(w/list). Use Primitive.merge_opts(...) instead.
10+
* Deprecated Primitive.put_transform(w/list). Use Primitive.merge_opts(...) instead.
911

1012

1113
## 0.8.0

lib/scenic/primitive.ex

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ defmodule Scenic.Primitive do
179179
[Scenic.Primitives](Scenic.Primitives.html) instead.
180180
181181
Parameters:
182-
`module` - The module of the primitive you are building
183-
`data` - the primitive-specific data being set into the primitive
184-
`opts` - a list of style and transform options to apply to the primitive
182+
* `module` - The module of the primitive you are building
183+
* `data` - the primitive-specific data being set into the primitive
184+
* `opts` - a list of style and transform options to apply to the primitive
185185
186186
Returns the built primitive.
187187
"""
@@ -298,7 +298,7 @@ defmodule Scenic.Primitive do
298298
Get the styles map from a primitive.
299299
300300
Parameters:
301-
`primitive` - The primitive
301+
* `primitive` - The primitive
302302
303303
Returns the a map of styles set directly onto this primitive. This does
304304
not include any inherited styles.
@@ -314,8 +314,8 @@ defmodule Scenic.Primitive do
314314
Update the styles map in a primitive.
315315
316316
Parameters:
317-
`primitive` - The primitive
318-
`styles` - The new styles map
317+
* `primitive` - The primitive
318+
* `styles` - The new styles map
319319
320320
Returns the primitive with the updated styles.
321321
"""
@@ -337,9 +337,9 @@ defmodule Scenic.Primitive do
337337
If the style is not set, it returns default
338338
339339
Parameters:
340-
`primitive` - The primitive
341-
`type` - atom representing the style to get.
342-
`default` - default value to return if the style is not set.
340+
* `primitive` - The primitive
341+
* `type` - atom representing the style to get.
342+
* `default` - default value to return if the style is not set.
343343
344344
Returns the value of the style.
345345
"""
@@ -352,9 +352,9 @@ defmodule Scenic.Primitive do
352352
Update the value of a specific style set on the primitive.
353353
354354
Parameters:
355-
`primitive` - The primitive
356-
`type` - atom representing the style to get.
357-
`data` - the value to set on the style.
355+
* `primitive` - The primitive
356+
* `type` - atom representing the style to get.
357+
* `data` - the value to set on the style.
358358
359359
Returns the updated primitive.
360360
"""
@@ -371,6 +371,7 @@ defmodule Scenic.Primitive do
371371
|> (&put_styles(p, &1)).()
372372
end
373373

374+
@deprecated "Use Primitive.merge_opts instead"
374375
def put_style(%Primitive{} = p, list) when is_list(list) do
375376
Enum.reduce(list, p, fn {type, data}, acc ->
376377
put_style(acc, type, data)
@@ -383,8 +384,8 @@ defmodule Scenic.Primitive do
383384
Does nothing if the style is not set.
384385
385386
Parameters:
386-
`primitive` - The primitive
387-
`type` - atom representing the style to delete.
387+
* `primitive` - The primitive
388+
* `type` - atom representing the style to delete.
388389
389390
Returns the updated primitive.
390391
"""
@@ -404,7 +405,7 @@ defmodule Scenic.Primitive do
404405
Get the transforms map from a primitive.
405406
406407
Parameters:
407-
`primitive` - The primitive
408+
* `primitive` - The primitive
408409
409410
Returns the a map of transforms set directly onto this primitive. This does
410411
not include any inherited transforms.
@@ -420,8 +421,8 @@ defmodule Scenic.Primitive do
420421
Update the transforms map in a primitive.
421422
422423
Parameters:
423-
`primitive` - The primitive
424-
`transforms` - The new transforms map
424+
* `primitive` - The primitive
425+
* `transforms` - The new transforms map
425426
426427
Returns the primitive with the updated transforms.
427428
"""
@@ -444,9 +445,9 @@ defmodule Scenic.Primitive do
444445
If the transform is not set, it returns default
445446
446447
Parameters:
447-
`primitive` - The primitive
448-
`type` - atom representing the transform to get.
449-
`default` - default value to return if the transform is not set.
448+
* `primitive` - The primitive
449+
* `type` - atom representing the transform to get.
450+
* `default` - default value to return if the transform is not set.
450451
451452
Returns the value of the transform.
452453
"""
@@ -459,9 +460,9 @@ defmodule Scenic.Primitive do
459460
Update the value of a specific transform set on the primitive.
460461
461462
Parameters:
462-
`primitive` - The primitive
463-
`type` - atom representing the transform to get.
464-
`data` - the value to set on the transform.
463+
* `primitive` - The primitive
464+
* `type` - atom representing the transform to get.
465+
* `data` - the value to set on the transform.
465466
466467
Returns the updated primitive.
467468
"""
@@ -478,6 +479,7 @@ defmodule Scenic.Primitive do
478479
|> (&put_transforms(p, &1)).()
479480
end
480481

482+
@deprecated "Use Primitive.merge_opts instead"
481483
def put_transform(%Primitive{} = p, tx_list) when is_list(tx_list) do
482484
Enum.reduce(tx_list, p, fn {k, v}, acc ->
483485
put_transform(acc, k, v)
@@ -491,8 +493,8 @@ defmodule Scenic.Primitive do
491493
Does nothing if the transform is not set.
492494
493495
Parameters:
494-
`primitive` - The primitive
495-
`type` - atom representing the transform to delete.
496+
* `primitive` - The primitive
497+
* `type` - atom representing the transform to delete.
496498
497499
Returns the updated primitive.
498500
"""
@@ -512,7 +514,7 @@ defmodule Scenic.Primitive do
512514
Get the value of the primitive-specific data.
513515
514516
Parameters:
515-
`primitive` - The primitive
517+
* `primitive` - The primitive
516518
517519
Returns the value of the primitive-specific data.
518520
"""
@@ -528,7 +530,7 @@ defmodule Scenic.Primitive do
528530
@spec put_opts(primitive :: Primitive.t(), opts :: keyword) :: Primitive.t()
529531
def put_opts(primitive, opts)
530532

531-
def put_opts(%Primitive{} = p, opts) when is_list(opts) do
533+
def put_opts(%Primitive{}, opts) when is_list(opts) do
532534
raise "Primitive.put_opts has been deprecated. Use Primitive.merge_opts instead."
533535
end
534536

@@ -540,7 +542,7 @@ defmodule Scenic.Primitive do
540542
more of a merge. The supplied list of styles and transforms
541543
542544
Parameters:
543-
`primitive` - The primitive
545+
* `primitive` - The primitive
544546
545547
Returns the value of the primitive-specific data.
546548
"""
@@ -558,9 +560,9 @@ defmodule Scenic.Primitive do
558560
off using the helper functions in [`Scenic.Primitives`](Scenic.Primitives.html) instead.
559561
560562
Parameters:
561-
`primitive` - The primitive
562-
`data` - The data to set
563-
`opts` - A list of style/transform options to merge
563+
* `primitive` - The primitive
564+
* `data` - The data to set
565+
* `opts` - A list of style/transform options to merge
564566
565567
Returns the updated primitive.
566568
"""
@@ -645,6 +647,26 @@ defmodule Scenic.Primitive do
645647
defp mprim_add_transforms(min_p, _), do: min_p
646648

647649
# --------------------------------------------------------
650+
@doc """
651+
Determines if a point is contained within a primitive.
652+
653+
The supplied point must already be projected into the local coordinate space
654+
of the primitive. In other words, this test does NOT take into account any
655+
transforms that have been applied to the primitive.
656+
657+
The input mechanism takes care of this for you by projecting incoming points
658+
by the inverse-matrix of a primitive before calling this function...
659+
660+
Note that some primitives, such as Group, do not inherently have a notion of
661+
containing a point. In those cases, this function will always return false.
662+
663+
Parameters:
664+
* `primitive` - The primitive
665+
* `point` - The point to test
666+
667+
Returns `true` or `false`.
668+
"""
669+
648670
@spec contains_point?(primitive :: Primitive.t(), point :: Scenic.Math.point()) :: map
649671
def contains_point?(%Primitive{module: mod, data: data}, point) do
650672
mod.contains_point?(data, point)

0 commit comments

Comments
 (0)