Jump to content

Barnsley fern: Difference between revisions

m
syntax highlighting fixup automation
(Barnsley fern in BASIC256)
m (syntax highlighting fixup automation)
Line 29:
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
<langsyntaxhighlight lang=Action!>INCLUDE "H6:REALMATH.ACT"
 
BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6
Line 119:
ValR("30",scale)
Fern(scale)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Barnsley_fern.png Screenshot from Atari 8-bit computer]
Line 125:
=={{header|Ada}}==
{{libheader|SDLAda}}
<langsyntaxhighlight lang=Ada>with Ada.Numerics.Discrete_Random;
 
with SDL.Video.Windows.Makers;
Line 218:
Window.Finalize;
SDL.Finalise;
end Barnsley_Fern;</langsyntaxhighlight>
 
=={{header|ALGOL 68}}==
Line 224:
 
This program generates a [https://en.wikipedia.org/wiki/Netpbm_format PBM file].
<langsyntaxhighlight lang=algol68>
BEGIN
INT iterations = 300000;
Line 281:
leave: SKIP
END
</syntaxhighlight>
</lang>
 
=={{header|Applesoft BASIC}}==
<langsyntaxhighlight lang=ApplesoftBasic> 100 LET YY(1) = .16
110 XX(2) = .85:XY(2) = .04
120 YX(2) = - .04:YY(2) = .85
Line 308:
330 HPLOT X% * 2 + 1,Y%
340 NEXT
</syntaxhighlight>
</lang>
 
=={{header|BASIC256}}==
<langsyntaxhighlight lang=BASIC256># adjustable window altoght
# call the subroutine with the altoght you want
# it's possible to have a window that's large than your display
Line 347:
# remove comment (#) in next line to save window as .png file
# imgsave("Barnsley_fern.png")
end subroutine</langsyntaxhighlight>
{{out}}
[https://www.dropbox.com/s/8rkgguj3ol57771/Barnsley_fern_BASIC256.png?dl=0 Barnsley fern BASIC256 image]
Line 354:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang=bbcbasic> GCOL 2 : REM Green Graphics Color
X=0 : Y=0
FOR I%=1 TO 100000
Line 367:
PLOT 1000 + X * 130 , Y * 130
NEXT
END</langsyntaxhighlight>
 
=={{header|C}}==
This implementation requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library. Iteration starts from (0,0) as required by the task however before plotting the point is translated and scaled as negative co-ordinates are not supported by the graphics window, scaling is necessary as otherwise the fern is tiny even for large iterations ( > 1000000).
<syntaxhighlight lang=C>
<lang C>
#include<graphics.h>
#include<stdlib.h>
Line 434:
return 0;
}
</syntaxhighlight>
</lang>
 
=={{header|C sharp|C#}}==
 
<langsyntaxhighlight lang=csharp>using System;
using System.Diagnostics;
using System.Drawing;
Line 482:
}
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
[[File:BFCpp.png|200px|thumb|right]]
<langsyntaxhighlight lang=cpp>
#include <windows.h>
#include <ctime>
Line 617:
fern f; f.draw(); return 0;
}
</syntaxhighlight>
</lang>
 
===Cross-Platform Alternative===
Line 623:
This version uses the QImage class from the Qt toolkit as an easy way to save an image in PNG format.
It also uses the C++ 11 random number library. Built and tested on macOS 10.15.4 with Qt 5.12.5.
<langsyntaxhighlight lang=cpp>#include <iostream>
#include <random>
#include <vector>
Line 680:
}
return EXIT_SUCCESS;
}</langsyntaxhighlight>
 
{{out}}
Line 687:
=={{header|Common Lisp}}==
This code uses the <code>opticl</code> package for generating an image and saving it as a PNG file.
<langsyntaxhighlight lang=lisp>(defpackage #:barnsley-fern
(:use #:cl
#:opticl))
Line 734:
(set-pixel image x y)
(multiple-value-setq (x y) (funcall (choose-transform) x y)))
(write-png-file filespec image)))</langsyntaxhighlight>
 
=={{header|D}}==
{{trans|Raku}}
{{libheader|dlib}}
<langsyntaxhighlight lang=d>#!/usr/bin/env dub
/+ dub.sdl:
dependency "dlib" version="~>0.21.0"
Line 795:
}
img.saveImage(`barnsley_dlib.png`);
}</langsyntaxhighlight>
 
=={{header|Delphi}}==
{{trans|Java}}
Hint: After putting a TPaintBox on the main form align it to alClient. Client width / height of the main form should be no less than 640 x 480.
<langsyntaxhighlight lang=delphi>unit Unit1;
 
interface
Line 863:
end;
 
end.</langsyntaxhighlight>
 
=={{header|EasyLang}}==
Line 869:
[https://easylang.online/apps/barnsley-fern.html Run it]
 
<syntaxhighlight lang=text>color 060
for i range 200000
r = randomf
Line 889:
move 50 + x * 15 100 - y * 10
rect 0.3 0.3
.</langsyntaxhighlight>
 
=={{header|Emacs Lisp}}==
<langsyntaxhighlight lang=lisp>; Barnsley fern
 
(defun make-array (size)
Line 945:
(barnsley-show arr size)))
 
(barnsley 400 35 100000)</langsyntaxhighlight>
 
=={{header|F sharp|F#}}==
 
<langsyntaxhighlight lang=fsharp>
open System.Drawing
 
Line 977:
|> Seq.fold (fun (b:Bitmap) (x,y) -> b.SetPixel(x-1,y-1,Color.ForestGreen); b) emptyBitmap // add pixels to bitmap
bitmap.Save("BFFsharp.png")
</syntaxhighlight>
</lang>
 
{{Out|Use}}
<langsyntaxhighlight lang=fsharp>
BarnsleyFern.run 720 720
</syntaxhighlight>
</lang>
 
=={{header|Forth}}==
Line 992:
Traditionaly, Forth use Fixed-Point Arithmetic (here with a 1000 scale). For transformation function choice, a formula is used to pick coefficients in a matrix.
 
<langsyntaxhighlight lang=forth>
s" SDL2" add-lib
\c #include <SDL2/SDL.h>
Line 1,049:
;
 
fern</langsyntaxhighlight>
 
===Floating Point and Multiple Functions solution===
Forth may use a dedicated Floating Point Stack. For transformation, a pointer to one of the 4 functions is used to be be called at the end of the loop.
 
<langsyntaxhighlight lang=forth>
s" SDL2" add-lib
\c #include <SDL2/SDL.h>
Line 1,121:
;
 
fern</langsyntaxhighlight>
 
 
 
=={{header|Fortran}}==
<langsyntaxhighlight lang=fortran>
!Generates an output file "plot.dat" that contains the x and y coordinates
!for a scatter plot that can be visualized with say, GNUPlot
Line 1,176:
close(1)
end program BarnsleyFern
</syntaxhighlight>
</lang>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang=freebasic>' version 10-10-2016
' compile with: fbc -s console
 
Line 1,232:
Windowtitle "hit any key to end program"
Sleep
End</langsyntaxhighlight>
 
=={{header|Frink}}==
<langsyntaxhighlight lang=Frink>
g = new graphics
g.backgroundColor[0,0,0] // black
Line 1,272:
 
g.show[]
</syntaxhighlight>
</lang>
 
=={{header|Fōrmulæ}}==
Line 1,283:
 
=={{header|G'MIC}}==
<syntaxhighlight lang=c>
<lang c>
# Put this into a new file 'fern.gmic' and invoke it from the command line, like this:
# $ gmic fern.gmic -barnsley_fern
Line 1,306:
)"}
-r 40%,40%,1,1,2
</syntaxhighlight>
</lang>
 
=={{header|gnuplot}}==
Line 1,313:
[[File:BarnsleyFernGnu.png|right|thumb|Output BarnsleyFernGnu.png]]
 
<langsyntaxhighlight lang=gnuplot>
## Barnsley fern fractal 2/17/17 aev
reset
Line 1,338:
set output
unset print
</langsyntaxhighlight>
{{Output}}
<pre>
Line 1,346:
 
=={{header|Go}}==
<langsyntaxhighlight lang=go>package main
 
import (
Line 1,417:
log.Fatal(err)
}
}</langsyntaxhighlight>
 
=={{header|Groovy}}==
Line 1,423:
{{libheader|JavaFX}}
 
<langsyntaxhighlight lang=Groovy>import javafx.animation.AnimationTimer
import javafx.application.Application
import javafx.scene.Group
Line 1,483:
}
}
</syntaxhighlight>
</lang>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang=haskell>import Data.List (scanl')
import Diagrams.Backend.Rasterific.CmdLine
import Diagrams.Prelude
Line 1,529:
main = do
rand <- getStdGen
mainWith $ drawFern (randomRs (0, 1) rand)</langsyntaxhighlight>
 
=={{header|IS-BASIC}}==
<langsyntaxhighlight lang=IS-BASIC>100 PROGRAM "Fern.bas"
110 RANDOMIZE
120 SET VIDEO MODE 1:SET VIDEO COLOR 0:SET VIDEO X 40:SET VIDEO Y 27
Line 1,553:
290 LET X=NX:LET Y=NY
300 PLOT X*96+600,Y*96
310 NEXT</langsyntaxhighlight>
 
=={{header|J}}==
[[File:jfern.png|200px|thumb|right]]
<langsyntaxhighlight lang=j>require 'plot'
f=: |: 0 ". ];._2 noun define
Line 1,574:
plotFern=: 'dot;grids 0 0;tics 0 0;labels 0 0;color green' plot ;/@|:
plotFern getPoints 0 0</langsyntaxhighlight>
 
=={{header|Java}}==
[[File:barnsley_fern.png|200px|thumb|right]]
{{works with|Java|8}}
<langsyntaxhighlight lang=java>import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
Line 1,646:
});
}
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
Line 1,652:
[[File:BarnsleyFernjs.png|right|thumb|Output BarnsleyFernjs.png]]
 
<langsyntaxhighlight lang=javascript>// Barnsley fern fractal
//6/17/16 aev
function pBarnsleyFern(canvasId, lim) {
Line 1,693:
ctx.fillRect(x * 50 + 260, -y * 50 + 540, 1, 1);
} //fend i
}</langsyntaxhighlight>
'''Executing:'''
<langsyntaxhighlight lang=html>
<html>
<head><script src="BarnsleyFern.js"></script></head>
Line 1,703:
</body>
</html>
</langsyntaxhighlight>
{{Output}}
<pre>
Line 1,712:
{{works with|Julia|0.6}}
 
<langsyntaxhighlight lang=julia>function barnsleyfern(n::Integer)
funs = (
(x, y) -> (0, 0.16y),
Line 1,729:
end
return rst
end</langsyntaxhighlight>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang=scala>// version 1.1.0
 
import java.awt.*
Line 1,798:
f.setVisible(true)
}
}</langsyntaxhighlight>
 
=={{header|Lambdatalk}}==
<langsyntaxhighlight lang=scheme>
{def fern
{lambda {:size :sign}
Line 1,821:
{def F {fern 25 1}}
 
</syntaxhighlight>
</lang>
The output can be seen in http://lambdaway.free.fr/lambdawalks/?view=fern
 
=={{header|Liberty BASIC}}==
 
<langsyntaxhighlight lang=lb>nomainwin
WindowWidth=800
WindowHeight=600
Line 1,856:
[q]
close #1
</syntaxhighlight>
</lang>
 
=={{header|Locomotive Basic}}==
{{trans|ZX Spectrum Basic}}
<langsyntaxhighlight lang=locobasic>10 mode 2:ink 0,0:ink 1,18:randomize time
20 scale=38
30 maxpoints=20000: x=0: y=0
Line 1,871:
100 x=nx: y=ny
110 plot scale*x+320,scale*y
120 next</langsyntaxhighlight>
 
=={{header|Lua}}==
Needs L&Ouml;VE 2D Engine
<langsyntaxhighlight lang=Lua>
g = love.graphics
wid, hei = g.getWidth(), g.getHeight()
Line 1,909:
g.draw( canvas )
end
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight lang=Mathematica>
BarnsleyFern[{x_, y_}] := Module[{},
i = RandomInteger[{1, 100}];
Line 1,922:
points = NestList[BarnsleyFern, {0,0}, 100000];
Show[Graphics[{Hue[.35, 1, .7], PointSize[.001], Point[#] & /@ points}]]
</syntaxhighlight>
</lang>
 
=={{header|MiniScript}}==
{{trans|C#}}
{{works with|Mini Micro}}
<langsyntaxhighlight lang=MiniScript>clear
x = 0
y = 0
Line 1,947:
y = 0.26 * xp + 0.24 * y + 0.44
end if
end for</langsyntaxhighlight>
 
=={{header|Nim}}==
<langsyntaxhighlight lang=Nim>
import nimPNG, random
 
Line 2,020:
 
discard savePNG24("fern.png",img.toString, width, height)
</syntaxhighlight>
</lang>
 
=={{header|Oberon-2}}==
[[File:Barnsleyfern-oberon2.png|250px|thumb|right]]
 
<langsyntaxhighlight lang=oberon2>
MODULE BarnsleyFern;
(**
Line 2,079:
Init;Draw
END BarnsleyFern.
</syntaxhighlight>
</lang>
 
=={{header|PARI/GP}}==
Line 2,086:
[[File:BarnsleyFern.png|right|thumb|Output BarnsleyFern.png]]
 
<langsyntaxhighlight lang=parigp>
\\ Barnsley fern fractal
\\ 6/17/16 aev
Line 2,108:
pBarnsleyFern(530,100000); \\ BarnsleyFern.png
}
</langsyntaxhighlight>
{{Output}}
Line 2,119:
=={{header|Perl}}==
[[File:BarnsleyFernPerl.png|250px|thumb|right]]
<langsyntaxhighlight lang=perl>use Imager;
 
my $w = 640;
Line 2,141:
 
$img->flip(dir => 'v');
$img->write(file => 'barnsleyFern.png');</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 2,147:
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/BarnsleyFern.htm here], or see the output [https://imgur.com/a/04ZZZt9 on imgur]
<!--<langsyntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- pwa\phix\BarnsleyFern.exw
Line 2,193:
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</langsyntaxhighlight>-->
 
=={{header|PicoLisp}}==
<langsyntaxhighlight lang=PicoLisp>`(== 64 64)
(seed (in "/dev/urandom" (rd 8)))
(scl 20)
Line 2,229:
(prinl "P1")
(prinl 640 " " 640)
(mapc prinl G) ) )</langsyntaxhighlight>
 
=={{header|Processing}}==
<langsyntaxhighlight lang=java>void setup() {
size(640, 640);
background(0, 0, 0);
Line 2,271:
}
noLoop();
}</langsyntaxhighlight>
 
==={{header|Processing Python mode}}===
 
<langsyntaxhighlight lang=python>size(640, 640)
background(0)
 
Line 2,335:
n = height - round(60 * y)
 
set(m, n, "#00ff00")</langsyntaxhighlight>
 
=={{header|PureBasic}}==
<langsyntaxhighlight lang=PureBasic>EnableExplicit
DisableDebugger
 
Line 2,379:
Repeat : Until WaitWindowEvent(50)=#PB_Event_CloseWindow
EndIf
End</langsyntaxhighlight>
 
=={{header|Python}}==
<langsyntaxhighlight lang=Python>
 
import random
Line 2,426:
fern.fern.show()
 
</syntaxhighlight>
</lang>
 
=={{header|QB64}}==
<langsyntaxhighlight lang=qb64>_Title "Barnsley Fern"
Dim As Integer sw, sh
sw = 400: sh = 600
Line 2,461:
 
Sleep
System</langsyntaxhighlight>
 
 
Line 2,468:
{{trans|PARI/GP}}
[[File:BarnsleyFernR.png|right|thumb|Output BarnsleyFernR.png]]
<langsyntaxhighlight lang=rsplus>## pBarnsleyFern(fn, n, clr, ttl, psz=600): Plot Barnsley fern fractal.
## Where: fn - file name; n - number of dots; clr - color; ttl - plot title;
## psz - picture size.
Line 2,502:
## Executing:
pBarnsleyFern("BarnsleyFernR", 100000, "dark green", "Barnsley Fern Fractal", psz=600)
</langsyntaxhighlight>
 
{{Output}}
Line 2,514:
==='Obvious' solution===
The matrix solution above is a clever approach, but the following solution is more readable if you're unfamiliar with linear algebra. This is very much a blind "just do what the task says" solution. It's so simple that it probably runs unadapted in S. I suspect that there is room for an interesting use of R's ifelse function somewhere, but I couldn't find a clean way.
<langsyntaxhighlight lang=rsplus>fernOfNPoints <- function(n)
{
currentX <- currentY <- newX <- newY <- 0
Line 2,553:
#It will look better if you use a bigger input, but the plot might take a while.
#I find that there's a large delay between RStudio saying that my code is finished running and the plot appearing.
#If your input is truly big, you may want to reduce the two cex parameters (to make the points smaller).</langsyntaxhighlight>
 
=={{header|Racket}}==
[[File:racket-barnsley-fern.png]] : file uploading broken :-(
<langsyntaxhighlight lang=racket>#lang racket
 
(require racket/draw)
Line 2,589:
 
bmp
(send bmp save-file "images/racket-barnsley-fern.png" 'png)</langsyntaxhighlight>
 
=={{header|Raku}}==
Line 2,596:
{{trans|Perl}}
[[File:Barnsley-fern-perl6.png|250px|thumb|right]]
<syntaxhighlight lang=raku perl6lines>use Image::PNG::Portable;
 
my ($w, $h) = (640, 640);
Line 2,615:
}
 
$png.write: 'Barnsley-fern-perl6.png';</langsyntaxhighlight>
 
=={{header|REXX}}==
Line 2,622:
<br>contains the &nbsp; '''X''' &nbsp; and &nbsp; '''Y''' &nbsp; coördinates for a scatter plot that can be
visualized with a plotting program.
<langsyntaxhighlight lang=rexx>/*REXX pgm gens X & Y coördinates for a scatter plot to be used to show a Barnsley fern.*/
parse arg N FID seed . /*obtain optional arguments from the CL*/
if N=='' | N=="," then N= 100000 /*Not specified? Then use the default*/
Line 2,645:
call lineout FID, x","y
end /*#*/ /* [↓] close the file (safe practice).*/
call lineout FID /*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=&nbsp; is generated to an output file: &nbsp; BARNSLEY.DAT &nbsp; which contains the &nbsp; '''X''' &nbsp; and &nbsp; '''Y''' &nbsp; coördinates of a scatter plot.}}<br><br>
 
=={{header|Ring}}==
<langsyntaxhighlight lang=Ring>
 
Load "guilib.ring"
Line 2,765:
return
</syntaxhighlight>
</lang>
 
=={{header|Ruby}}==
{{libheader|RubyGems}}
{{libheader|JRubyArt}}
<langsyntaxhighlight lang=ruby>
MAX_ITERATIONS = 200_000
 
Line 2,813:
size 500, 500
end
</syntaxhighlight>
</lang>
 
=={{header|Run BASIC}}==
<langsyntaxhighlight lang=runbasic>'Barnsley Fern - Run BASIC
'http://rosettacode.org/wiki/Barnsley_fern#Run_BASIC
'copy code and run it at http://www.runbasic.com
Line 2,846:
NEXT n
render #g
#g "flush"</langsyntaxhighlight>
 
=={{header|Rust}}==
Line 2,852:
{{libheader|rand}}
 
<langsyntaxhighlight lang=rust>extern crate rand;
extern crate raster;
 
Line 2,896:
 
raster::save(&image, "fractal.png").unwrap();
}</langsyntaxhighlight>
 
=={{header|Scala}}==
===Java Swing Interoperability===
<langsyntaxhighlight lang=Scala>import java.awt._
import java.awt.image.BufferedImage
 
Line 2,962:
})
 
}</langsyntaxhighlight>
 
=={{header|Scheme}}==
This version creates a list of points, defining the fern, which are then rescaled and output to an eps file.
<langsyntaxhighlight lang=scheme>(import (scheme base)
(scheme cxr)
(scheme file)
Line 3,025:
(display "\n%%EOF")))))
 
(output-fern-as-eps "barnsley.eps" (create-fern 0 0 50000))</langsyntaxhighlight>
 
=={{header|Scilab}}==
{{Works with|Scilab|5.4.0 and above}}
This version creates a list of points, defining the fern, and shows them on a graphic window which can then be saved to a file via the GUI or the console by the user.
<syntaxhighlight lang=text>
iteractions=1.0d6;
 
Line 3,068:
axes.isoview="on";
axes.children.children.mark_foreground=13;
</syntaxhighlight>
</lang>
 
=={{header|SequenceL}}==
'''Tail-Recursive SequenceL Code:'''<br>
<langsyntaxhighlight lang=sequencel>import <Utilities/Math.sl>;
import <Utilities/Random.sl>;
 
Line 3,103:
fern := barnsleyFern(seedRandom(seed), count, [[0.0,0.0]]);
in
scale(fern, width, height);</langsyntaxhighlight>
 
'''C++ Driver Code:'''<br>
{{libheader|CImg}}
<langsyntaxhighlight lang=c>#include "SL_Generated.h"
#include "CImg.h"
 
Line 3,140:
 
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 3,146:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang=ruby>require('Imager')
 
var w = 640
Line 3,168:
 
img.flip(dir => 'v')
img.write(file => 'barnsleyFern.png')</langsyntaxhighlight>
Output image: [https://github.com/trizen/rc/blob/master/img/barnsley-fern-sidef.png Barnsley fern]
 
=={{header|SPL}}==
<langsyntaxhighlight lang=spl>w,h = #.scrsize()
x,y = 0
>
Line 3,185:
f2(x,y) <= 0.85*x+0.04*y, -0.04*x+0.85*y+1.6
f3(x,y) <= 0.2*x-0.26*y, 0.23*x+0.22*y+1.6
f4(x,y) <= -0.15*x+0.28*y, 0.26*x+0.24*y+0.44</langsyntaxhighlight>
 
=={{header|Standard ML}}==
Works with PolyML. Random generator copy from the [[Random_numbers#Standard_ML]] task. Window slimmed down from [[Animation#Standard_ML]].
<langsyntaxhighlight lang=Standard ML>open XWindows ;
open Motif ;
 
Line 3,248:
XtRealizeWidget shell
)
end ; </langsyntaxhighlight>
call
demoWindow () ;
Line 3,255:
Output is viewable in a playground.
 
<langsyntaxhighlight lang=swift>import UIKit
import CoreImage
import PlaygroundSupport
Line 3,298:
}
 
let uiImage = UIImage(cgImage: context.makeImage()!)</langsyntaxhighlight>
 
=={{header|TI-83 BASIC}}==
<langsyntaxhighlight lang=ti83b>ClrDraw
Input "ITERS:",M
[[0,0,1]]→[A]
Line 3,338:
Pxl-On(E,F)
I+1→I
End</langsyntaxhighlight>
 
=={{header|Unicon}}==
{{libheader|graphics}}
<langsyntaxhighlight lang=unicon>
link graphics
 
Line 3,409:
}
end
</syntaxhighlight>
</lang>
 
=={{header|VBA}}==
<langsyntaxhighlight lang=vb>Private Sub plot_coordinate_pairs(x As Variant, y As Variant)
Dim chrt As Chart
Set chrt = ActiveSheet.Shapes.AddChart.Chart
Line 3,445:
Next i
plot_coordinate_pairs x, y
End Sub</langsyntaxhighlight>
/* {{header|Visual Basic .NET}} */ Section added
 
=={{header|Visual Basic .NET}}==
{{works with|Visual Basic .NET|2011}}
<langsyntaxhighlight lang=vbnet>' Barnsley Fern - 11/11/2019
Public Class BarnsleyFern
 
Line 3,483:
End Sub 'Paint
 
End Class 'BarnsleyFern</langsyntaxhighlight>
 
=={{header|Wren}}==
{{trans|Kotlin}}
{{libheader|DOME}}
<langsyntaxhighlight lang=ecmascript>import "graphics" for Canvas, Color
import "dome" for Window
import "random" for Random
Line 3,540:
}
 
var Game = BarnsleyFern.new(640, 640, 200000)</langsyntaxhighlight>
 
=={{header|XPL0}}==
<langsyntaxhighlight lang=XPL0>int N, R;
real NX, NY, X, Y;
[SetVid($12); \set 640x480x4 VGA graphics (on PC or RPi)
Line 3,557:
Point(320+fix(X*40.0), 440-fix(Y*40.0), 2\green\);
]
]</langsyntaxhighlight>
 
=={{header|Yabasic}}==
{{trans|ZX Spectrum Basic}}
Classic style
<langsyntaxhighlight lang=Yabasic>10 REM Fractal Fern
20 LET wid = 800 : LET hei = 600 : open window wid, hei : window origin "cb"
25 backcolor 0, 0, 0 : color 0, 255, 0 : clear window
Line 3,574:
100 LET x=nx: LET y=ny
110 DOT x*wid/12,y*hei/12
120 NEXT n</langsyntaxhighlight>
Modern style <langsyntaxhighlight lang=Yabasic>REM Fractal Fern
wid = 800 : hei = 600 : open window wid, hei : window origin "cb"
backcolor 0, 0, 0 : color 0, 255, 0 : clear window
Line 3,588:
x = nx : y = ny
dot x * wid / 12, y * hei / 12
next</langsyntaxhighlight>
 
=={{header|zkl}}==
Line 3,594:
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl
{{trans|Java}}
<langsyntaxhighlight lang=zkl>fcn barnsleyFern(){
w,h:=640,640;
bitmap:=PPM(w+1,h+1,0xFF|FF|FF); // White background
Line 3,609:
}
bitmap.writeJPGFile("barnsleyFern.jpg");
}();</langsyntaxhighlight>
 
=={{header|ZX Spectrum Basic}}==
{{trans|zkl}}
<langsyntaxhighlight lang=zxbasic>10 REM Fractal Fern
20 PAPER 7: BORDER 7: BRIGHT 1: INK 4: CLS
30 LET maxpoints=20000: LET x=0: LET y=0
Line 3,625:
110 PLOT x*17+127,y*17
120 NEXT n
</syntaxhighlight>
</lang>
It is recommended to run on an emulator that supports running at full speed.
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.