function barnsli(rez, iter)
% rez - broj tacaka
% iter - broj iteracija
% radimo rez+iter iteracija od cega se prvih iter preskace a narednih rez
% crta
% barnsli(10000, 1000)

pts = zeros(rez,2);
x = rand(1);
y = rand(1);
for j = 1:rez+iter
        p = rand(1);
        if p < 0.77
            xn = 0.85*x+0.04*y+0.075;
            yn = -0.04*x+0.85*y+0.18;
            x = xn;
            y = yn;
        elseif p < 0.89
            xn = 0.2*x-0.26*y+0.4;
            yn = 0.23*x+0.22*y+0.045;
            x = xn;
            y = yn;
        elseif p < 0.99
            xn = -0.15*x+0.28*y+0.575;
            yn = 0.26*x+0.24*y-0.086;
            x = xn;
            y = yn;
        else
            xn = 0.5;
            yn = 0.16*x;
            x = xn;
            y = yn;
        end

    pts(j,1) = x;
    pts(j,2) = y;
end

xs = pts(iter:end,1);
ys = pts(iter:end,2);
plot(xs,ys,'.g')
