Skip to content
Browse files

Turn up the sampling rate, increase resolution, and add circles where…

… the polynomial overlap begins and ends.
  • Loading branch information...
1 parent f729e1a commit 3dd74513f5f08c96ce93674c4af50a6ea381328e SF committed Nov 27, 2009
Showing with 21 additions and 8 deletions.
  1. +21 −8 svg.pl
View
29 svg.pl
@@ -8,7 +8,7 @@
sub MakePath($curve, Range $range, SVGPad $pad)
{
- my @points = RangeOfSize($range.from, $range.to, 10).map({$pad.xy2mn($curve.evaluate($_))});
+ my @points = RangeOfSize($range.from, $range.to, 40).map({$pad.xy2mn($curve.evaluate($_))});
my $start = @points.shift;
my $path = "M {$start.coordinates[0]} {$start.coordinates[1]}";
for @points -> $v
@@ -32,21 +32,34 @@ ($curve, Range $range, SVGPad $pad)
my Polynomial $poly3 = $nubs.evaluate(2.5, Polynomial.new(0.0, 1.0));
my $pad = SVGPad.new(Vector2.new(-2.5, -2.5), Vector2.new(2.5, 2.5),
- Vector2.new(0, 0), Vector2.new(400, 400));
+ Vector2.new(0, 0), Vector2.new(700, 700));
+my @dot_points = (-1, 1, 2, 3).map({$pad.xy2mn($nubs.evaluate($_))});
my $svg = svg => [
- :width(400), :height(400),
- path => [
- :d(MakePath($nubs, -1..3, $pad)), :stroke("blue"), :stroke-width(2), :fill("none")
+ :width(700), :height(700),
+ circle => [
+ :cx(@dot_points[0].coordinates[0]), :cy(@dot_points[0].coordinates[1]), :r(4)
+ ],
+ circle => [
+ :cx(@dot_points[1].coordinates[0]), :cy(@dot_points[1].coordinates[1]), :r(4)
+ ],
+ circle => [
+ :cx(@dot_points[2].coordinates[0]), :cy(@dot_points[2].coordinates[1]), :r(4)
+ ],
+ circle => [
+ :cx(@dot_points[3].coordinates[0]), :cy(@dot_points[3].coordinates[1]), :r(4)
],
path => [
- :d(MakePath($poly1, -2..2, $pad)), :stroke("green"), :stroke-width(1), :fill("none")
+ :d(MakePath($nubs, -1..3, $pad)), :stroke("black"), :stroke-width(3), :fill("none")
],
path => [
- :d(MakePath($poly2, 0..3, $pad)), :stroke("red"), :stroke-width(1), :fill("none")
+ :d(MakePath($poly1, -2..2, $pad)), :stroke("red"), :stroke-width(1), :fill("none")
],
path => [
- :d(MakePath($poly3, 1..4, $pad)), :stroke("white"), :stroke-width(1), :fill("none")
+ :d(MakePath($poly2, 0..3, $pad)), :stroke("green"), :stroke-width(1), :fill("none")
],
+ path => [
+ :d(MakePath($poly3, 1..4, $pad)), :stroke("blue"), :stroke-width(1), :fill("none")
+ ]
];
say SVG.serialize($svg);

0 comments on commit 3dd7451

Please sign in to comment.
Something went wrong with that request. Please try again.