I'm Trying to draw a drinking straw on illustrator, with stripe pattern. I've tried using pen tool, converting the line into outline stroke and setting pattern from swatches but the straw pattern is not correct because it doesn't follow the line.
Make a pattern brush, and apply it to a path.
In the screenshot at the bottom you can see the pattern brush I made, consisting of a white filled rectangle, overlaid with a skewed pink filled rectangle. I then clicked and dragged it into the Brushes panel, then I chose the option to make a "Pattern Brush".
Next, I drew the straw as a single path, using the Pen Tool, then I clicked on the brush I made to apply it to the path.
If you disregard the bend in the straw you could use Illustrator's 3D effect...
- Create a set of skewed rectangles
- Convert those to a symbol
- Draw a long thin rectangle
Effect > 3D > Revolve
- Adjust Effect options to create the "tube" aspect
- Click the Map Art button
- Assign your Symbol to the correct side
- Scale the symbol to encompass the art entirely
- Click Okay
This will yield a striped "tube".
You could then use an Envelope Distortion, or Puppet Warp in newer Illustrator versions, to possibly create the bend...
This is all quick and dirty to show the methodology. It could absolutely be refined more for final artwork.
This is done in 2D
1-2. Draw a square and an as high but 50% less wide rectangle. Draw a diagonal line from corner to corner in the square. Have smart guides and snap to point ON for easy placements.
- With the anchor type tool make the diagonal curved so that the ends are horizontal
Now practice a little how to select a shape with the normal selection tool and dragging it from a node with the direct selection tool to make the node to snap perfectly with another shape.You need it soon.
Make a few copies of the shapes, arrange them to be together one repeating section in the straw. Be sure to fit the corners exactly with snapping.
Select the parts, combine the parts with the Shape builder, set the fill colors as shown and remove the stroke. The result is 3 adjacent filled areas. With the shape builder you can drag over the stroke to combine 2 adjacent shapes.
Make a small enough copy of the combined shape, drag it to the Brushes collection and define it to be a pattern brush. Let the reduced size shape have a certain easy to remember height, for ex. 6 millimeters. You must be able to make exactly as high parts in step 9.
Draw a straw as single stroke. I used the Pen and smoothed 2 corners with the anchor type tool.
Apply the new pattern brush to the straw stroke
Plausible shading to make it look round is tricky. I jumped over where the fence is lowest. I made a new pattern brush which has a gradient. I applied it to a copy of the straw stroke. My legacy Illustrator doesn't have transversal gradient along a path.The gradient was expanded to 64 steps to make it work as a brush. If you try it, release the clipping mask before you make the brush.
The straw with gradient fill is placed on the colored version Blending mode Hard light and reduced opacity creates the shading.
Your example has much more complex shading. It varies along the straw. To get the same in 2D you can expand the appearance of the colored straw (=8), ungroup and combine those parts which can have same fill gradient. Combine them by making a compound path. Then find a good gradient for each zone. The curve needs radial gradient or gradient mesh. As I said: It's tricky, far from trivial! The details are out of the scope of this answer.
The pattern brush isn't the only way to solve the case in 2D. The repeating stripe pattern can be made also with blending:
1-2. One stripe part is darawn, duplicated, movedt to the right and a blend is made to generate equally spaced copies. The blend is expanded and ungrouped for easier editing.
- A solid color rectangle is inserted to the bottom
4-5. A rectangle with gradient fill is inserted on the top. With reduced opacity and blending mode =Hard light it makes an elementary shading which can be seen as roundness.
6-7. The bend can be inserted by envelope distorting a section of the straw. Here two vertical lines are drawn and Object > Path > Divide objects below is applied to make two cuts. The separated sections are grouped to keep their parts together.
Gradient bending didn't work in my legacy Illustrator. For that reason in the mid section the gradient was temporarily returned to blending mode = Normal and Opacity = 100%. The Gradient was rasterized to 300 DPI, the opacity was reduced again and the blending mode was changed again to Hard Light.
8.The mid section got Object > Envelope Distortion > Make with Warp > Arc 25% bend. The straight sections are rotated +22,5 degrees and -22,5 degrees to make them to fit with the 45 degree arc (bend = 25% means 25% of 180 degrees).
9.The parts are placed. They snap with the direct selection tool. There's one hitch: The section borders are anti-aliased and the rasterized gradient makes it even coarser. The seams are transparent. This is fixed easily by bringing the straight parts to top and stretching them 1...2 pixel widths.
In real straws the bent section is often corrugated. It can be approximated with mesh envelope distortion (+expanding it) before applying the arc warping:
The resulted straw:
This can still be developed. If one makes a straight straw with corrugated section, the whole straw can be used as an Art Brush. Apply it to a curve which has a bend in the place of the corrugated section:
ADD: Only for a comparison here are two 3D versions - a straight one and the same as bended.The coloring came out with zero effort.
3D programs render the result generally as raster images. If you export the model as 2D vector drawing, it will not have shading, only outlines and solid fill colors at best. But it can have proper perspective and different views are possible with no effort.
Note: The used 3D program (=Moi3D) is very simple, it doesn't have ray-tracing rendering nor realistic materials. For shiny metal foil look you need more complex software.