potracer 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/ext/potracer/potracer.c +23 -16
  2. metadata +2 -2
@@ -151,32 +151,39 @@ trace_trace (VALUE obj, VALUE bitmap, VALUE params)
151
151
  static VALUE
152
152
  trace_as_array (VALUE klass)
153
153
  {
154
+ VALUE rpath, rparts;
154
155
  VALUE result = rb_ary_new();
155
- potrace_path_t *p;
156
- int i, n, *tag;
156
+ potrace_path_t *path;
157
+ int i, num_segments, *tag;
157
158
  potrace_dpoint_t (*c)[3];
158
159
  potrace_state_t *trace = NULL;
159
160
  Data_Get_Struct(klass, potrace_state_t, trace);
160
161
 
161
162
  if (trace->status == POTRACE_STATUS_OK) {
162
- p = trace->plist;
163
- while (p != NULL) {
164
- n = p->curve.n;
165
- tag = p->curve.tag;
166
- c = p->curve.c;
167
- MOVE_TO(result, c[n-1][2]);
168
- for (i = 0; i < n; i++) {
163
+ path = trace->plist;
164
+ while (path != NULL) {
165
+ rparts = rb_ary_new();
166
+ num_segments = path->curve.n;
167
+ tag = path->curve.tag;
168
+ c = path->curve.c;
169
+ MOVE_TO(rparts, c[num_segments-1][2]);
170
+ for (i = 0; i < num_segments; i++) {
169
171
  switch (tag[i]) {
170
172
  case POTRACE_CORNER:
171
- LINE_TO(result, c[i][1]);
172
- LINE_TO(result, c[i][2]);
173
- break;
174
- case POTRACE_CURVETO:
175
- CURVE_TO(result, c[i]);
176
- break;
173
+ LINE_TO(rparts, c[i][1]);
174
+ LINE_TO(rparts, c[i][2]);
175
+ break;
176
+ case POTRACE_CURVETO:
177
+ CURVE_TO(rparts, c[i]);
178
+ break;
177
179
  }
178
180
  }
179
- p = p->next;
181
+ rpath = rb_hash_new();
182
+ rb_hash_aset(rpath, STRSYM("area"), rb_int_new(path->area));
183
+ rb_hash_aset(rpath, STRSYM("sign"), rb_str_new2(path->area == '+' ? "+" : "-"));
184
+ rb_hash_aset(rpath, STRSYM("parts"), rparts);
185
+ rb_ary_push(result, rpath);
186
+ path = path->next;
180
187
  }
181
188
  }
182
189
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-03 00:00:00.000000000 Z
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Ruby bindings for the potrace library.
15
15
  email: k.parnell@gmail.com