Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Superellipse/Sidef/superellipse.sidef
Normal file
34
Task/Superellipse/Sidef/superellipse.sidef
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
const (
|
||||
a = 200,
|
||||
b = 200,
|
||||
n = 2.5,
|
||||
)
|
||||
|
||||
# y in terms of x
|
||||
func y(x) { b * (1 - abs(x/a)**n -> root(n)) -> int }
|
||||
|
||||
func pline(q) {
|
||||
<<-"EOT";
|
||||
<polyline points="#{q.join(' ')}"
|
||||
style="fill:none; stroke:black; stroke-width:3" transform="translate(#{a}, #{b})" />
|
||||
EOT
|
||||
}
|
||||
|
||||
# Generate an SVG image
|
||||
say <<-"EOT"
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg height="#{b*2}" width="#{a*2}" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
EOT
|
||||
|
||||
# find point pairs for one quadrant
|
||||
var q = { |x| (x, y(x)) }.map(0..200 `by` 2)
|
||||
|
||||
[
|
||||
pline(q),
|
||||
pline(q »*« [ 1,-1]), # flip and mirror
|
||||
pline(q »*« [-1,-1]), # for the other
|
||||
pline(q »*« [-1, 1]), # three quadrants
|
||||
].each { .print }
|
||||
|
||||
say '</svg>'
|
||||
Loading…
Add table
Add a link
Reference in a new issue