lib/glimmer/libui/shape/polybezier.rb in glimmer-dsl-libui-0.5.2 vs lib/glimmer/libui/shape/polybezier.rb in glimmer-dsl-libui-0.5.3
- old
+ new
@@ -37,9 +37,21 @@
::LibUI.draw_path_bezier_to(path_proxy.libui, alternating_x_y_array[point_alternating_x_y_index + 2], alternating_x_y_array[point_alternating_x_y_index + 3], alternating_x_y_array[point_alternating_x_y_index + 4], alternating_x_y_array[point_alternating_x_y_index + 5], alternating_x_y_array[point_alternating_x_y_index + 6], alternating_x_y_array[point_alternating_x_y_index + 7])
end
end
super
end
+
+ def perfect_shape
+ perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
+ if perfect_shape_dependencies != @perfect_shape_dependencies
+ point_array = @perfect_shape_dependencies = perfect_shape_dependencies
+ path_shapes = [point_array.first]
+ bezier_shape_points = point_array.drop(1).each.with_index.to_a.group_by {|pair| pair.last/3}.values.map {|arr| arr.map(&:first)}
+ path_shapes += bezier_shape_points.map { |points| PerfectShape::CubicBezierCurve.new(points: points) }
+ @perfect_shape = PerfectShape::Path.new(closed: false, shapes: path_shapes)
+ end
+ @perfect_shape
+ end
end
end
end
end