B-spline: Difference between revisions

m
Automated syntax highlighting fixup (second round - minor fixes)
m (syntax highlighting fixup automation)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 25:
* [https://www.cl.cam.ac.uk/teaching/2000/AGraphHCI/SMEG/node4.html B-splines]
<br><br>
 
 
=={{header|ALGOL 68}}==
{{Trans|Lua}}Which is {{Trans|Wren}}Suppresses unused parts of the plot.
<syntaxhighlight lang="algol68">BEGIN # construct a B-Spline #
 
# mode to hold a B Spline #
Line 222 ⟶ 220:
 
</pre>
 
=={{header|Julia}}==
Choose BSpline D of 2, ie degree 1.
<syntaxhighlight lang="julia">using Graphics, Plots
 
Point(t::Tuple) = Vec2(Float64(t[1]), Float64(t[2]))
Line 232 ⟶ 229:
plt = plot(map(a -> a.x, controlpoints), map(a -> a.y, controlpoints))
savefig(plt, "BSplineplot.png")</syntaxhighlight>
 
=={{header|Lua}}==
 
{{trans|Wren}}
 
<syntaxhighlight lang=Lua"lua">local function Range(from, to)
local range = {}
for n = from, to do table.insert(range, n) end
Line 406 ⟶ 402:
@@@
</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang=Mathematica"mathematica">Graphics[
BSplineCurve[{{171, 171}, {185, 111}, {202, 109}, {202, 189}, {328,
160}, {208, 254}, {241, 330}, {164, 252}, {69, 278}, {139,
Line 415 ⟶ 410:
{{out}}
Outputs a graphical representation of a B-spline.
 
=={{header|Perl}}==
{{trans|Raku}}
<syntaxhighlight lang="perl">use strict;
use warnings;
use Class::Struct;
Line 475 ⟶ 469:
$surf->write_to_png($OUTPUT);</syntaxhighlight>
Output: [https://raw.githubusercontent.com/SqrtNegInf/Rosettacode-Perl-Smoke/master/ref/b-spline.png b-spline.png] (offsite image)
 
=={{header|Phix}}==
{{trans|Wren}}
Line 481 ⟶ 474:
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/bspline.htm here].
<!--<syntaxhighlight lang=Phix"phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\B-spline.exw
Line 569 ⟶ 562:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</syntaxhighlight>-->
 
=={{header|Processing}}==
<syntaxhighlight lang="java">
//Aamrun, 26th June 2022
 
Line 599 ⟶ 591:
 
</syntaxhighlight>
 
=={{header|Raku}}==
A minimal translation of [https://www.cypherpunk.at/download/bspline/bspline_1.1.tbz2 this C program], by [https://github.com/rahra Bernhard R. Fischer].
<syntaxhighlight lang=perl6"raku" line># 20211112 Raku programming solution
 
use Cairo;
Line 676 ⟶ 667:
 
Output: [https://drive.google.com/file/d/1dInRJeecA18meybDF2D0usEaWMGFqoBj/view (Offsite image file) ]
 
=={{header|Wren}}==
{{libheader|DOME}}
Line 682 ⟶ 672:
 
If one uses a value for k of 1, then the script will simply plot the control points as in the Julia example.
<syntaxhighlight lang="ecmascript">import "dome" for Window, Process
import "graphics" for Canvas, Color
 
10,333

edits