Skip to content

Latest commit

 

History

History
184 lines (146 loc) · 5.42 KB

ps-operators-s1.md

File metadata and controls

184 lines (146 loc) · 5.42 KB

Operators: S (1)

  1. save: Saves the current graphics state on the graphics state stack.

    save  % Saves the current state for later restoration
  2. scale: Scales the current coordinate system by sx and sy.

    2 2 scale  % Doubles the size of the coordinate system
  3. scalefont: Scales a font to a specified size.

    /Helvetica findfont 12 scalefont setfont  % Scales Helvetica to 12 points
  4. scheck: Checks if an object is a shared object.

    /x 42 def x scheck  % Returns false unless x is declared in a shared environment
  5. search: Searches for a substring in a string and returns a boolean and the index.

    (World) (Hello, World!) search  % Returns true, the index of "World" in "Hello, World!", and the substrings before and after "World"
  6. selectfont: Combines findfont and scalefont in one step, selecting a font and scale.

    /Helvetica 12 selectfont  % Selects and sets Helvetica at 12 points
  7. serialnumber: Returns the serial number of the device.

    serialnumber  % Might return 123456789
  8. setbbox: Sets the bounding box for a path.

    0 0 100 100 setbbox  % Sets the bounding box from (0,0) to (100,100)
  9. setblackgeneration: Sets the procedure used to generate black in color separation.

    /myBlackGen { ... } def setblackgeneration
  10. setcachedevice: Sets the character cache device.

    0 0 10 10 300 300 setcachedevice  % Sets cache device parameters for character
  11. setcachelimit: Sets the maximum number of entries in the font cache.

    100 setcachelimit  % Limits cache to 100 entries
  12. setcacheparams: Sets parameters for the font cache.

    /MaxCache 1000 setcacheparams  % Sets the maximum cache size to 1000
  13. setcharwidth: Sets the character width for the font being defined.

    500 0 setcharwidth  % Sets character width to 500 units
  14. setcmykcolor: Sets the current color using CMYK color model values.

    0 0 0 1 setcmykcolor  % Sets the color to black
  15. setcolor: Sets the current color using the specified color object.

    [1 0 0] setcolor  % Sets the color to red in an RGB color space
  16. setcolorrendering: Sets the color rendering dictionary.

    /myCRD { ... } def setcolorrendering
  17. setcolorscreen: Sets the halftone screen for color printing.

    /myScreen { ... } def setcolorscreen
  18. setcolorspace: Sets the current color space.

    /DeviceRGB setcolorspace  % Sets color space to RGB
  19. setcolortransfer: Sets the color transfer function.

    /myTransfer { ... } def setcolortransfer
  20. setdash: Sets the line dash pattern.

    [10 5] 0 setdash  % Sets a dash pattern of 10 units on, 5 off
  21. setdevparams: Sets device parameters.

    << /PageSize [612 792] >> setdevparams  % Sets page size for device
  22. setfileposition: Sets the position within a file.

    file 100 setfileposition  % Sets the file position to byte 100
  23. setflat: Sets the flatness tolerance.

    0.5 setflat  % Sets flatness to 0.5

setfont: Sets the current font to use. postscript /Helvetica findfont 12 scalefont setfont % Sets Helvetica at 12 points as the current font

  1. setglobal: Sets the global allocation mode (true for global, false for local).

    true setglobal  % Allocates storage in global VM
  2. setgray: Sets the current color to a shade of gray.

    0.5 setgray  % Sets the color to a medium gray
  3. setgstate: Sets the graphics state using a dictionary.

    /myGState gstate def setgstate  % Restores graphics state from myGState
  4. sethalftone: Sets the halftone parameters.

    /myHalftone { ... } def sethalftone
  5. sethalftonephase: Sets the phase of the halftone screen.

    << /Phase [10 10] >> sethalftonephase  % Sets halftone phase to (10,10)
  6. sethsbcolor: Sets the current color using HSB model values.

    0.5 1 1 sethsbcolor  % Sets the color to bright pure green
  7. setlinecap: Sets the style of line caps for drawing lines.

    1 setlinecap  % Sets line cap style to round
  8. setlinejoin: Sets the style of line joints for drawing lines.

    1 setlinejoin  % Sets line join style to round
  9. setlinewidth: Sets the width of lines drawn from here on.

    2 setlinewidth  % Sets line width to 2 units
  10. setmatrix: Replaces the current transformation matrix.

    [1 0 0 1 0 0] setmatrix  % Resets transformation matrix to identity
  11. setmiterlimit: Sets the miter limit for line joins.

    10 setmiterlimit  % Sets miter limit to 10
  12. setobjectformat: Sets the format for storing objects.

    3 setobjectformat  % Sets object format to level 3