Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Jun 7, 2009

Drawing a Dot With 2 Anchors

I often draw a dot with 2 anchors.
To draw this, drawing a horizontal line and set the width of it to zero, then set the stroke cap type to the Round Cap.


This method enables to seve the number of anchors as compared with drawing a circle with 4 anchors.
Additionally, if you set Resize tool's option to keep the stroke width, you can adjust the density of dots without scaling each of them.

To use the dot, I usually drag it into Brush palette, and register as a scatter brush.
Then I drag on the artboard.


... Looks dirty. Let's clean it by removing the overlapped dots with a script.


Now looks OK.

Before using the following script, you must expand the brush and then ungroup it so that every item is appeared as <Path> in the Layers palette. (You may have to ungroup twice after expand it.)
Then remove useless path (the track of the brush).

If I write a script for general purpose, I'll automate this ungroup process, and insert the error handling to avoid baffling abending.
But this time, I wrote this for one-time use and for my own use.
I often write small scripts like this to automate the boring part of daily work.

// removes overlapped dots
var sel = activeDocument.selection;
var j;
var vb = sel[0].visibleBounds;
var w = vb[2] - vb[0]; // right - left
w *= 1.25; // adds margin
w *= w; // for comparison of squared distance

for(var i = sel.length - 1; i > 0; i--){
for(j = i - 1; j >= 0; j--){
if( dist2(sel[i].pathPoints[0].anchor,
sel[j].pathPoints[0].anchor) <= w ){
sel[i].remove();
break;
}
}
}
// -------
function dist2(p, q){
return Math.pow(p[1] - q[1], 2)
+ Math.pow(p[0] - q[0], 2);
}

Jun 1, 2009

Ultra Fast Way to Draw Primitive Solids

... with Adobe Illustrator.


Cylinder
  1. Select the bottom anchor, and press Ctrl-X.
  2. Press Ctrl-F, and drag it downward with Shift key pressed.
  3. Select the right side anchors and press Ctrl-J. Do the same for the left side.
  4. Press Ctrl-F again.

Box
  1. Draw a rectangle.
  2. Drag the right side segment. Then select whole shape and press Ctrl-C.
    Then press Ctrl-F twice.
  3. Drag the left side segment.
  4. Drag the lower side segment.
  5. Select marked anchors, then drag one anchor to be snapped.
  6. Colorize as you prefer.

Cone
  1. Draw an oval.
  2. Drag with Alt key pressed to duplicate. Snap the lower anchor to the center.
  3. Drag the upper box of the bounding box with Shift key pressed, so that the shape is enlarged with keeping the aspect ratio.
  4. Draw a path with Pen tool to connect the intersection points and the upper anchor.
    -- These 2 lines are exactly tangential to the oval. (To be accurate, these are almost tangential because the oval is an approximated one by the bezier curve.)
  5. Unite with pathfinder if it needs.