• Remix
  • Share
  • New Entry

on 26 Oct 2021
  • 10
  • 162
  • 0
  • 0
  • 278
% Sweet Lightning : A speckled breed of pumpkin
% This script updates the og pumpkin script, and adds a discrete
% colormap and color speckles, much like the real version of the
% Sweet Lightning pumpkin.
% This particular breed is quite small and decorative, but
% auto-scale limits make it look the same size as the og pumpkin
% script.
% This computes ridges around the pumpkin.
% Normally I'd do this inline with the surf command, but I need to
% use the values twice, once in surf, and once to compute the color c.
% Several pumpkin breeds with speckles have a different color in
% the dents than on the ridges. To start off, set the CData of the
% surface to be == distance from center iff the pumpkin were round.
% Thus, c is for round (inclusive of ridges) and we squish it into
% a pumpkin shape below in the Z component of the surf call.
% To add speckles, add scaled random noise which will only be
% visible near the boundary of the two colors.
% This command is a bit shorter than specifying the face and edge
% colors in the surface command.
shading interp
% As we build the stem, we need to specify CData even though it
% isn't used. That forces the automatic CLim of the axes to be
% specified in a way we control. The alternative would be to add
% a command like: caxis([.8 1]) or some-such to force the
% boundary between the discrete colors to work correctly for the
% speckles. Saves about 13 chars. In this case, our 2 color
% colormap would have the boundary right in the middle, but we want
% to sink it back into the ridges, so extend the clim downwards here.
% Use a discreet colormap so that we can simulate speckles.
% Looks like the RGB version is shorter than using validatecolor
% like this:
% colormap(validatecolor({'#ff7518' '#ffffbb'},'multiple'))
colormap([1 .4 .1
1 1 .7])
axis equal off
% The lighting Model
% Pumpkin lights matter, but this speckled punkin looks ok 'flat' lit
% which is the default, so that, and not specifying all the material
% parameters saves a bunch of characters which were needed to make room for
% the speckle logic.
% lighting g
material([.6 1 .3])
Remix Tree