Squeak Class Documentation category index | class index  
 
Pen
  category: Graphics-Primitives
  superclass: BitBlt
  subclasses: PenPointRecorder

My instances can scribble on the screen or some other Form, drawing and printing at any angle. Since I am a BitBlt, the drawing can be done with an arbitary source Form.

instance methods
  accessing
  direction
location

  geometric designs
  dragon:
filberts:side:
hilbert:side:
hilberts:
mandala:
spiral:angle:
web

  initialize-release
  defaultNib:
roundNib:
squareNib:

  operations
  arrowHead
arrowHeadFrom:to:
color:
down
fill:color:
go:
goto:
home
north
place:
print:withFont:
turn:
up

  private
  location:direction:penDown:
sourceForm:

class methods
  examples
  example

  instance creation
  new
newOnForm:

  tablet drawing examples
  feltTip:cellSize:
inkBrush
simplePressurePen
tabletScaleFactor
testMouseTracking
testTabletTracking

instance methods
  accessing top  
 

direction

Answer the receiver's current direction. 0 is towards the top of the
screen.


 

location

Answer where the receiver is currently located.


  geometric designs top  
 

dragon:

Display restoreAfter: [Display fillWhite. Pen new dragon: 10].


 

filberts:side:

Display restoreAfter: [Pen new filberts: 4 side: 5]


 

hilbert:side:

Draw an nth level Hilbert curve with side length s in the center of the
screen. Write directly into the display's bitmap only. A Hilbert curve is
a space-filling curve.


 

hilberts:

Display restoreAfter: [Display fillWhite. Pen new hilberts: 5]


 

mandala:

Display restoreAfter: [Pen new mandala: 30]


 

spiral:angle:

Draw a double squiral (see Papert, MindStorms), where each design is made
by moving the receiver a distance of n after turning the amount + or -a.


 

web

Display restoreAfter: [Pen new web]


  initialize-release top  
 

defaultNib:

Nib is the tip of a pen. This sets up the pen, with a nib of width widthInteger. You can also set the shape of the pen nib using:
roundNib: widthInteger, or
squareNib: widthInteger, or
sourceForm: aForm


 

roundNib:

Makes this pen draw with a round dot of the given diameter.


 

squareNib:

Makes this pen draw with a square nib of the given width.


  operations top  
 

arrowHead

Put an arrowhead on the previous pen stroke


 

arrowHeadFrom:to:

Put an arrowhead on the pen stroke from oldPt to newPt


 

color:

Set the pen to the given color or to a color chosen from a fixed set of colors.


 

down

Set the state of the receiver's pen to down (drawing).


 

fill:color:


 

go:

Move the pen in its current direction a number of bits equal to the
argument, distance. If the pen is down, a line will be drawn using the
receiver's form source as the shape of the drawing brush.


 

goto:

Move the receiver to position aPoint. If the pen is down, a line will be
drawn from the current position to the new one using the receiver's
form source as the shape of the drawing brush. The receiver's set
direction does not change.


 

home

Place the receiver at the center of its frame.


 

north

Set the receiver's direction to facing toward the top of the display screen.


 

place:

Set the receiver at position aPoint. No lines are drawn.


 

print:withFont:

Print the given string in the given font at the current heading


 

turn:

Change the direction that the receiver faces by an amount equal to the
argument, degrees.


 

up

Set the state of the receiver's pen to up (no drawing).


  private top  
 

location:direction:penDown:


 

sourceForm:

Set the receiver's source form to be the argument, aForm.


class methods
  examples top  
 

example

Draw a spiral with a pen that is 2 pixels wide.


  instance creation top  
 

new

Answer a new instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable.


 

newOnForm:


  tablet drawing examples top  
 

feltTip:cellSize:

Warning: This example potentially uses a large amount of memory--it creates a Form with cellSize squared bits for every Display pixel.


 

inkBrush

Similar to simplePressurePen, but this example uses the average of the recent pen pressure values. The effect is that of a Japanese ink brush that comes up gradually off the paper as the brush is lifted, causing end (and beginning) of each stroke to taper. Requires the optional tablet support primitives which may not be supported on all platforms. Works best in full screen mode. Shift-mouse to exit.


 

simplePressurePen

An example of using a pressure sensitive pen to control the thickness of the pen. This requires the optional tablet support primitives which may not be supported on all platforms. Works best in full screen mode. Shift-mouse to exit.


 

tabletScaleFactor

Answer a Point that scales tablet coordinates to Display coordinates, where the full extent of the tablet maps to the extent of the entire Display.


 

testMouseTracking

A very simple example of drawing using the mouse. Compare the tracking speed of this example with that of testTabletTracking. Mouse down to draw a stroke, shift-mouse to exit.


 

testTabletTracking

A very simple example of drawing using the pen of a digitizing tablet such as a Wacom ArtZ tablet. This requires the optional tablet support primitives which may not be supported on all platforms. Compare the tracking speed of this example with that of testMouseTracking. On a Macintosh, the tablet primitives provide roughly 120 samples/second versus only 60 mouse samples/second, and the difference is noticable. Works best in full screen mode. Mouse down to draw a stroke, shift-mouse to exit.