File:Gosper curve 4.svg

From testwiki
Jump to navigation Jump to search
Original file (SVG file, nominally 640 × 640 pixels, file size: 24 KB)

This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

Summary

Description
English: Gosper curve of degree 4.
Date
Source Own work
Author Autopilot

Source

The SVG file is produced by the following Perl script, which is based on the Logo implementation at Gosper-Kurve.

#!/bin/perl
use Math::Trig;
# SVG Gosper curve generator by Blotwell
# Released under GFDL

my $x=500, $y=2500, $a=90;
my $ln=100;

printf <<HEREDOC, $x,$y;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
	width="640px" height="640px"
>
<polyline
	stroke="red"
	stroke-width="10"
	fill="none"
	transform="scale(0.1)"
	points="%i,%i
HEREDOC

rg(4);
print <<HEREDOC;
"/>
</svg>
HEREDOC

sub p {printf " %i,%i",$x,$y;}
sub fd {my $n=shift; $x+=$n*cos(deg2rad($a)); $y-=$n*sin(deg2rad($a)); p();}
sub tl {$a+=shift;}
sub rt {$a-=shift;}

sub gl {
	my $st=-1+shift;
	if ($st<0) {
		fd($ln);
		return
	}

	tl(60);  rg($st);
	rt(60);  gl($st); gl($st);
	rt(120); gl($st);
	rt(60);  rg($st);
	tl(120); rg($st);
	tl(60);  gl($st);
}

sub rg {
	my $st=-1+shift;
	if ($st<0) {
		fd($ln);
		return;
	}

	rg($st);
	rt(60);  gl($st);
	rt(120); gl($st);
	tl(60);  rg($st);
	tl(120); rg($st); rg($st);
	tl(60);  gl($st);
	rt(60);
}

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Gosper curve of degree 4.

Items portrayed in this file

depicts

30 September 2024

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current18:18, 30 September 2024Thumbnail for version as of 18:18, 30 September 2024640 × 640 (24 KB)wikimediacommons>Autopilotwithout background element

The following page uses this file: