This material creates seamless spiral stripes, entirely from variables and maths functions. In figure 1 I've used it to create a red and white pattern, similar to the one found on some sticks of rock (a type of candy).

Fig 1: Diagonal Stripes

Our material is based on the U and V nodes. This means that the direction of the stripes will depend on the UV mapping of our model. In this case, we are using the Poser primitive cylinder. U is wrapped around the cylinder, while V runs from top to bottom. Different models will produce different results.

Fig 2: Shader tree for Diagonal Stripes

Because we want our stripes to spiral up around our cylinder, we need to combine our U and V nodes. To do this, create an Add maths node, plug U into Value_1 and V into Value_2. The angle of the stripe will depend on the numbers we use in Value_1 and Value_2. Here I have used 0.3 for Value_1 (the U node), and 0.7 for Value_2 (the V node), producing stripes that are raised slightly from the horizontal. To get diagonal stripes, set both Value_1 and Value_2 to 0.5.

Now we have our slope, we need our stripes. At the moment our output runs from 0 at the bottom left, smoothly up to 1 at the top right. We need to make this pattern repeat as many times as we want stripes. To do that, we are going to use a Mod maths node. This function divides Value1 by Value2 and returns the remainder. Plug the output from our Add node into Value_1 of the Mod node. Set Value_1 to 10 (or the number of stripes you desire) and set Value_2 to 1. The output of the mod function can never be equal to or higher than Value_2, so what we have done here is to multiply our smooth gradient by 10, and then discarded the whole numbers. We now have ten smooth stripes.

Finally, we need to turn our smooth slopes into sharp stripes. We are going to use the step maths function for this. This compares Value_1 and Value_2, returning white if Value_2 is higher, and black if it is not. Plug the output of the Mod node into Value_2 of the step node. Set Value_2 of the step node to 1, and Value_1 to 0.5. Remember, each of our ten smooth stripes run from 0 at the bottom, to 1 at the top. The step function compares this gradient to 0.5 (Value_1), and produces black wherever the stripe is less than 0.5, and white wherever it is above it.

To get thinner white stripes, increase Value_1 of the Step node, keeping it under 1. Go above this and the white stripe will disappear. To get thicker stripes, decrease Value_1, staying above zero, or the black gaps will go.