Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 2.63 KB

ps-operators-a.md

File metadata and controls

55 lines (40 loc) · 2.63 KB

Operators: A

  1. abs: The abs operator returns the absolute value of a number. For example:

    -5 abs    % Result: 5
    3 abs     % Result: 3
    
  2. add: The add operator adds the top two numbers on the operand stack and pushes the result onto the stack. For example:

    3 4 add    % Result: 7
    
  3. aload: The aload operator loads an element from an array onto the operand stack. For example:

    [1 2 3] 1 aload    % Result: 2
    
  4. anchorsearch: The anchorsearch operator searches for an anchor point within a string. It's commonly used in text layout operations but doesn't have a simple example without a larger context.

  5. and: The and operator performs a bitwise AND operation on the top two integers on the operand stack. For example:

    5 3 and    % Result: 1 (because 101 AND 011 = 001)
    
  6. arc: The arc operator draws a circular arc. It requires parameters specifying the center, radius, start angle, and end angle of the arc. For example:

    100 100 50 0 90 arc    % Draws a quarter circle from 0 to 90 degrees with center at (100, 100) and radius 50
    
  7. arcn: Similar to arc, the arcn operator draws a circular arc but in the opposite direction (clockwise). Example usage is similar to arc.

  8. arct: The arct operator calculates the tangent of an angle. For example:

    1 1 arct    % Result: 45 (the tangent of 1 radian)
    
  9. arcto: The arcto operator creates a circular arc between two points, using a specified radius. It's used in path construction. An example usage requires specifying more parameters than can be shown here.

  10. array: The array operator creates an array with the specified number of elements. For example:

    3 array    % Result: [null null null]
    
  11. ashow: The ashow operator shows text with individual character spacing. It requires the array of character codes and the array of character advances to be on the stack. Example usage depends on the specifics of the text to be shown.

  12. astore: The astore operator stores elements into an array. It's often used with aload. An example usage would involve populating an array with values.

  13. atan: The atan operator calculates the arctangent of a number. For example:

    1 1 atan    % Result: 45 (the arctangent of 1/1)
    
  14. awidthshow: The awidthshow operator shows text with individual character spacing and width. It requires the array of character codes, the array of character advances, and a width value to be on the stack. Example usage depends on the specifics of the text to be shown.