• New Entry

Rose with faux lighting

Eric Ludlam on 25 Oct 2021
  • 19
  • 162
  • 3
  • 0
  • 273
% A Fancy Rose
% I originally found the code on the MW Facebook feed.
% I also saw a version on Paul Nylander's math artwork page.
% Lastly, I remixed from JR's "somewhere it's spring", but had
% acutally started from scratch before I saw that contribution.
% Thus - I have different and more aggressive chracter
% optimizations to make room for the extra work coloring the rose.
% This colonop will be used again for the colormap
% Crunched up algorithm from the online post. Find the original
% for a more legible version of this mess.
% I shrank this down mostly by factoring out pi so it showed up
% less often, using colonop instead of linspace, and taking
% advantage of operator precidence to remove parenthisis.
x=1-(5/4*(1-mod(3.6*T, 2)).^2-1/4).^2/2;
% Geom for Z needed x.* - but to save 2 chars on the parens
% do it inline in the surf command, but NOT for the color array.
% The color array looked close enough without it.
% Display the arrays with colors starting black inside the rose
% so we don't need to spend chars on using lights.
shading interp
axis equal off
% This bit of trickery recycles 'm' from above which happened to
% be the same colonop needed for the colormap.
% Use this trick to quickly add the g,b as 0 to the red colormap.
Remix Tree
Load full remix tree