stream
{ 360 mul sin
2 div
exch 360 mul sin
2 div
add
}
endstream
Can someone please explain this syntax to me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This doesn’t look like PDF to me:
streamandendstreamare PDF keywords, yes.But the rest rather looks like PostScript.
So
streamandendstreamcould also be PostScript variables or functions, defined elsewhere (before) in the same code…As PostScript, the code means:
{and}are just separators that structure the code into blocks360 mul sin: multiply by 360 (multiply what? => the value that’s topmost on the stack), compute the sinus value for the result, and put this as topmost on the stack.2 div: divide the topmost value on the stack by 2.exch 360 mul sin: swap the 2 topmost items on the stack, multiply the item that’s now topmost by 360, compute the sinus of it and put it back on the stack.2 div: divide the topmost value on the stack by 2.add: add the 2 topmost values on the stack.Update:
Ouch!
I had completely forgotten about the details of the (very limited) PostScript function objects which the PDF spec allows inside PDF documents. These represent self-contained and static numerical transformations.
So my above explanation of the PostScript code as a calculator function is still valid, and it looks to me like describing a ‘spot function’ for a halftone screen. (However,
streamandendstreamin this context of course do keep their original meanings as PDF keywords, and the curly braces{and}are required to enclose the function definition.)Since the PDF spec for these PostScript function objects does not allow the use of arrays, variables, names or strings, but only integers, reals and booleans as values, the processing of these code segments doesn’t require a fully fledged PostScript interpreter, and this statement in the spec:
does still apply and makes still the PDF language very different from PostScript (which is a programming language, and PS files are programs).
Keeping in mind, that PostScript is a stack-based language, and understanding its code by thinking of a pocket calculator that uses ‘reverse Polish notation’ conventions will help you wrapping your mind around this topic…