spiro 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84d28bbf80c2fe0eb5bcbe8fe82a60109bfa2425
4
- data.tar.gz: 1d989e78b0aa54e1738e8ea321cd6d66e0734e95
3
+ metadata.gz: d7ea81ccb6dc0f98c003f24d474ba3b34f246601
4
+ data.tar.gz: 8d0f682b693e55e32acfe428aef0ca6dc0338b7c
5
5
  SHA512:
6
- metadata.gz: 33f6c9af30e379a5390f2ecd549189a5b9f3f2e19ed8e84f806e91a9495b32fc208fb3735d1cdd69137b2383dc6c817c872395682fe392e87a21a4fc14a28972
7
- data.tar.gz: 3cb174eac9af018d16b5f520c5efb068b3ab765b5bf0f6c66845c16f0c5119b79bfb0682275f468eb85e025c67d6b0812fcb6f09e0fb053c0190536cecfcfa90
6
+ metadata.gz: cc6f2f0a04843331562b99cf8eb5733671c8993215a61ee911ccb1affd3b642f37e71a7c4dba8371dca4b0390c3b46df9d60c807eae66453ac5873f7e0d138d9
7
+ data.tar.gz: 363483c7472837abf2d1dd8197b453e780e287a63433542567dd4f450eb3e20396808b79fd8bb90e57d33fe507ade009c458609cce6efbcbf6136ad26dfe44fb
data/README.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Spiro
2
2
 
3
- TODO: Write a gem description
3
+ A Ruby wrapper for [libspiro](https://github.com/fontforge/libspiro), which is itself a bundling of [Spiro](http://levien.com/spiro/) by Raph Levien.
4
+
5
+ Spiro makes drawing beautiful curves easy.
6
+
7
+ Usually Bézier splines are used for curves. These require off-curve points which "bend" the line towards them. As these points aren't on the line they are quite unintuitive and it's hard to imagine where the line will end up without a GUI.
8
+
9
+ Raph Levien's Spiro splines only use on-curve points and so are easier to use and more intuitive to the artist. They make it easy to maintain constant curvature as well as constant slope. Such curves will simply look nicer.
10
+
11
+ This library will take an array of Spiro control points and convert them into a series of Bézier splines which can then be used in the myriad of ways the world has come to use Béziers.
12
+
13
+ It was created for the design as code tool [Vector Salad](https://github.com/sfcgeorge/vector_salad).
14
+
4
15
 
5
16
  ## Installation
6
17
 
@@ -18,9 +29,30 @@ Or install it yourself as:
18
29
 
19
30
  $ gem install spiro
20
31
 
32
+
21
33
  ## Usage
22
34
 
23
- TODO: Write usage instructions here
35
+ ```ruby
36
+ # takes an array of spiro points and returns an array of bezier points
37
+ # (this will potentially contain both cubic and quadratic beziers)
38
+ splines = Spiro.spiros_to_splines(
39
+ [[0, 0, :node], [100, 50, :g2], [-50, 300, :node]],
40
+ true # the path is closed
41
+ )
42
+ ```
43
+
44
+ ### Node types:
45
+
46
+ * :node, a standard non curved point
47
+ * :g2, a node with g2 curvature
48
+ * :g4, a node with g4 curvature
49
+ * :left, used to connect a curved line to a straight one
50
+ * :right, used to connect a straight line to a curved one. If you have a contour which is drawn clockwise, and you have a straight segment at the top, then the left point of that straight segment should be a left constraint, and the right point should be a right constraint.
51
+
52
+ It's often best to just experiment with the above until you get the desired result.
53
+
54
+ If it fails to produce a curve, then try switching between g2 and g4 points, and generally experimenting with moving nodes around.
55
+
24
56
 
25
57
  ## Contributing
26
58
 
data/lib/spiro.rb CHANGED
@@ -2,5 +2,4 @@ require 'spiro/version'
2
2
  require 'spiro/spiro'
3
3
 
4
4
  module Spiro
5
- # Your code goes here...
6
5
  end
data/lib/spiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spiro
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
data/test/test_spiro.rb CHANGED
@@ -31,12 +31,12 @@ class TestSpiro < Minitest::Test
31
31
  def test_spiros_to_splines_returns_array
32
32
  splines = Spiro.spiros_to_splines(
33
33
  [[0, 0, :node], [100, 50, :g2], [-50, 300, :node]],
34
- true)
34
+ true
35
+ )
35
36
  assert_kind_of Array, splines
36
37
  end
37
38
 
38
39
  #def test_spiros_to_splines_with_random_data_stress_test
39
- ## It will crash after a while, see below
40
40
  #while true do
41
41
  #path = Random.rand(5..50).times.map{rand_n}
42
42
  #p path
@@ -44,26 +44,4 @@ class TestSpiro < Minitest::Test
44
44
  #assert_includes [Array, NilClass], splines.class
45
45
  #end
46
46
  #end
47
-
48
- def test_this_one_crashes
49
- # I sometimes get "pointer being freed was not allocated" but it takes a while.
50
- # I thought it might be some nodes that Spiro doesn't like, but these are fine
51
- # sometimes, it's only after running several times that it crashes.
52
- # There must be a bad bit of memory management somewhere :-/
53
- #
54
- # Other times I get "Segmentation fault".
55
- #
56
- # It can crash very quickly, or it can take several seconds. So I'm guessing
57
- # that there a piece of memory is being freed when it shouldn't somewhere,
58
- # and it depends where that memory is whether it hurts anything. Not good.
59
- #
60
- # Anyway, I don't really know C and because all of the Ruby stacktrace
61
- # thrown in I can't figure out if the problem is in my code or Spiro.
62
- # Does anyone know C well enough to fix this?
63
- path = [[-39, -57, :g2], [-59, 20, :right], [37, -14, :g2], [-67, -40, :g2], [-83, 20, :g2], [56, -87, :left], [-11, 86, :left], [11, 29, :left], [-87, 54, :left]]
64
- while true do
65
- splines = Spiro.spiros_to_splines(path, true)
66
- assert_includes [Array, NilClass], splines.class
67
- end
68
- end
69
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raph Levien
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-05 00:00:00.000000000 Z
13
+ date: 2015-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler