Documentation ¶
Overview ¶
Package ps implements a small subset of the postscript language used in PDF for type 4 functions. Only objects are integers, real numbers, and boolean values only.
Index ¶
- Constants
- Variables
- func PSObjectArrayToFloat64Array(objects []PSObject) ([]float64, error)
- type PSBoolean
- type PSExecutor
- type PSInteger
- type PSObject
- type PSOperand
- func (this *PSOperand) Abs(stack *PSStack) error
- func (this *PSOperand) Add(stack *PSStack) error
- func (this *PSOperand) And(stack *PSStack) error
- func (this *PSOperand) Atan(stack *PSStack) error
- func (this *PSOperand) Bitshift(stack *PSStack) error
- func (this *PSOperand) Ceiling(stack *PSStack) error
- func (this *PSOperand) Copy(stack *PSStack) error
- func (this *PSOperand) Cos(stack *PSStack) error
- func (this *PSOperand) Cvi(stack *PSStack) error
- func (this *PSOperand) Cvr(stack *PSStack) error
- func (this *PSOperand) DebugString() string
- func (this *PSOperand) Div(stack *PSStack) error
- func (this *PSOperand) Dup(stack *PSStack) error
- func (this *PSOperand) Duplicate() PSObject
- func (this *PSOperand) Eq(stack *PSStack) error
- func (this *PSOperand) Exch(stack *PSStack) error
- func (this *PSOperand) Exec(stack *PSStack) error
- func (this *PSOperand) Exp(stack *PSStack) error
- func (this *PSOperand) Floor(stack *PSStack) error
- func (this *PSOperand) Ge(stack *PSStack) error
- func (this *PSOperand) Gt(stack *PSStack) error
- func (this *PSOperand) IDiv(stack *PSStack) error
- func (this *PSOperand) If(stack *PSStack) error
- func (this *PSOperand) IfElse(stack *PSStack) error
- func (this *PSOperand) Index(stack *PSStack) error
- func (this *PSOperand) Le(stack *PSStack) error
- func (this *PSOperand) Ln(stack *PSStack) error
- func (this *PSOperand) Log(stack *PSStack) error
- func (this *PSOperand) Lt(stack *PSStack) error
- func (this *PSOperand) Mod(stack *PSStack) error
- func (this *PSOperand) Mul(stack *PSStack) error
- func (this *PSOperand) Ne(stack *PSStack) error
- func (this *PSOperand) Neg(stack *PSStack) error
- func (this *PSOperand) Not(stack *PSStack) error
- func (this *PSOperand) Or(stack *PSStack) error
- func (this *PSOperand) Pop(stack *PSStack) error
- func (this *PSOperand) Roll(stack *PSStack) error
- func (this *PSOperand) Round(stack *PSStack) error
- func (this *PSOperand) Sin(stack *PSStack) error
- func (this *PSOperand) Sqrt(stack *PSStack) error
- func (this *PSOperand) String() string
- func (this *PSOperand) Sub(stack *PSStack) error
- func (this *PSOperand) Truncate(stack *PSStack) error
- func (this *PSOperand) Xor(stack *PSStack) error
- type PSParser
- type PSProgram
- type PSReal
- type PSStack
- func (this *PSStack) DebugString() string
- func (stack *PSStack) Empty()
- func (stack *PSStack) Pop() (PSObject, error)
- func (stack *PSStack) PopInteger() (int, error)
- func (stack *PSStack) PopNumberAsFloat64() (float64, error)
- func (stack *PSStack) Push(obj PSObject) error
- func (this *PSStack) String() string
Constants ¶
const TOLERANCE = 0.000001
Tolerance for comparing real values.
Variables ¶
var ErrRangeCheck = errors.New("Range check error")
var ErrStackOverflow = errors.New("Stack overflow")
var ErrStackUnderflow = errors.New("Stack underflow")
Common errors.
var ErrTypeCheck = errors.New("Type check error")
var ErrUndefinedResult = errors.New("Undefined result error")
Functions ¶
Types ¶
type PSExecutor ¶
type PSExecutor struct { Stack *PSStack // contains filtered or unexported fields }
A PSExecutor has its own execution stack and is used to executre a PS routine (program).
func NewPSExecutor ¶
func NewPSExecutor(program *PSProgram) *PSExecutor
type PSObject ¶
type PSObject interface { Duplicate() PSObject DebugString() string // Only for debugging. String() string }
func MakeInteger ¶
type PSOperand ¶
type PSOperand string
Operand.
func MakeOperand ¶
func (*PSOperand) And ¶
And operation. if bool: returns the logical "and" of the inputs bool1 bool2 and -> bool3 if int: returns the bitwise "and" of the inputs int1 int2 and -> int3
func (*PSOperand) Ceiling ¶
Ceiling of number. num1 ceiling -> num2 The type of the result is the same as of the operand.
func (*PSOperand) DebugString ¶
func (*PSOperand) Exp ¶
base exponent exp -> base^exp Raises base to exponent power. The result is a real number.
func (*PSOperand) IfElse ¶
If else conditional bool proc1 proc2 ifelse -> execute proc1() if bool is true, otherwise proc2()
func (*PSOperand) Index ¶
Add a copy of the nth object in the stack to the top. any_n ... any_0 n index -> any_n ... any_0 any_n index from 0
func (*PSOperand) Not ¶
Logical/bitwise negation bool1 not -> bool2 (logical) int1 not -> int2 (bitwise)
func (*PSOperand) Or ¶
OR logical/bitwise operation. bool1 bool2 or -> bool3 (logical or) int1 int2 or -> int3 (bitwise or)
func (*PSOperand) Roll ¶
Roll stack contents (num dir roll) num: number of elements, dir: direction 7 8 9 3 1 roll -> 9 7 8 7 8 9 3 -1 roll -> 8 9 7 n j roll
type PSParser ¶
type PSParser struct {
// contains filtered or unexported fields
}
func NewPSParser ¶
Create a new instance of the PDF Postscript parser from input data.
type PSProgram ¶
type PSProgram []PSObject
A Postscript program is a series of PS objects (arguments, commands, programs etc).
func NewPSProgram ¶
func NewPSProgram() *PSProgram
func (*PSProgram) DebugString ¶
type PSStack ¶
type PSStack []PSObject
func NewPSStack ¶
func NewPSStack() *PSStack
func (*PSStack) DebugString ¶
func (*PSStack) PopInteger ¶
func (*PSStack) PopNumberAsFloat64 ¶
Pop and return the numeric value of the top of the stack as a float64. Real or integer only.