Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SingleGlass page type #162

Closed
jdaw1 opened this issue Jul 2, 2022 · 2 comments
Closed

SingleGlass page type #162

jdaw1 opened this issue Jul 2, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jdaw1
Copy link
Owner

jdaw1 commented Jul 2, 2022

Nice to post online might be a GIF animation of all the glass circles (second image).

20220705_SingleGlass  20220705_SingleGlass

The natural way to proceed is to have the software make single-glass pages. For each page, width = height = 2 × radius, with the circle centred. GIFing is then easy, such as via GraphicConverter’s File > New > Animation using all Pages of the multipage Document (TIFF,PDF).

Currently the PostScript part can be done by using PrologueCode to inject code (software version ≥ 04 July 2022). For a few goes this will be the method, to allow learning. If/when in the software, some of the functionality would move into the existing ShowPage routine, and the mark … /OUT pdfmark would also be separated.

Questions:

  • Should the TypeOfPagesBeingRendered be named ‘SingleGlass’?
  • Will there be a need for multiple new parameters, or would it be acceptable to re-use PrePourShowBackgroundTexts and PrePourShowDroplets?
  • Do people agree that it should be controlled by a Boolean, rather than a …NumCopies integer?
  • There is a Boolean BottleWrapSuppressOtherPageTypes. This page type needs similar. But the two would interact non-intuitively. What should be done?
% From https://github.com/jdaw1/placemat/issues/162
/PrologueCode
{
	/TestingSuppressPageTypes [ /Glasses 0  /TastingNotes 0  /VoteRecorder 0  /DecantingNotes 0  /Accounts 0  /CorkDisplay 0  /NeckTags 0  /PrePour 0  /PlaceName 0  /DecanterLabels 0  /BottleWrap 0  /StickyLabels 0  /DistillerLog ] store
	0 SheetLengths {add} forall  dup 0 gt
	{
		17 dict begin
		mark   /Count 3 -1 roll    /Action << >>    /F 0    /Title (Single-circle extracts)    /OUT pdfmark
		0  1  NumSheets 1 sub
		{
			/SheetNum exch def
			//false //false //false //false PaperType Orientation SetPaperSize   //true DefStoreMgns
			0  1  SheetLengths SheetNum get 1 sub
			{
				WithinPage-WithinTitles-def
				CircleNonEmpty SheetNum get WithinPage get
				{
					<< /PageSize [Radii SheetNum get 2 mul  dup] >> setpagedevice
					Radii SheetNum get  dup  translate  newpath
					/MatrixGlasses matrix currentmatrix def
					0  0  Radii SheetNum get  0  360  arc  1 setgray fill

					PrePourShowBackgroundTexts   Droplets {PrePourShowDroplets or} if
					{
						ClipSave  newpath  0  0  Radii SheetNum get  0  360  arc  clip  newpath
						/TypeOfPagesBeingRendered /Glasses store
						GlassPositions SheetNum get WithinPage get {neg} forall translate
						/MatrixGlassesPage matrix currentmatrix def
						BackgroundTextsGlasses PrePourShowBackgroundTexts and {BackgroundTextsGlassesForms SheetNum get execform} if
						Droplets PrePourShowDroplets and
						{
							SheetNum
							GSave  newpath
							MatrixGlasses setmatrix
							Radii SheetNum get dup   dup dup neg  dup dup  dup 4 index  moveto lineto lineto lineto
							MatrixGlassesPage setmatrix   pathbbox	GRestore
							WithinPage  0.0  DropletsPaint
						} if  % Droplets PrePourShowDroplets and
						ClipRestore
					} if  % PrePourShowBackgroundTexts ...PrePourShowDroplets or
					MatrixGlasses setmatrix

					/TypeOfPagesBeingRendered /Glasses store
					OutlineTitles
					{
						OutlineForms SheetNum get WithinPage get   execform
					} if  % OutlineTitles ...

					Spirals {SpiralForms SheetNum get WithinPage get execform} if
					CrossHatchingInside {CrossHatchingInsideForms SheetNum get WithinPage get  execform} if

					/PaintBackgroundInsideGlassCircles load dup length 0 gt
					{
						/TypeOfPagesBeingRendered /TastingNotes store
						GSave newpath  0 0 Radii SheetNum get 0 360 arc  clip newpath
						execU   GRestore /TypeOfPagesBeingRendered /Glasses store
					} {pop} ifelse  % PaintBackgroundInsideGlassCircles ... length 0 gt
					TitleAboveBelowOverForms SheetNum get WithinPage get  execform  AnnotateGlass
					CirclearrayForms SheetNum get WithinPage get   execform

					/PageDestName  mark (SingleCircle_) SheetNum (_) WithinPage ConcatenateToMark cvn  def
					mark /Dest PageDestName  /View [/Fit]   /DEST  pdfmark
					mark
						/Action /GoTo    /Dest PageDestName    /F 0
						/Title mark ()
							[ Titles  Belowtitles  Abovetitles  Overtitles  FillTitles {FillTexts} if ]
								{WithinTitles get PDFDocEncodingify TrimSpaces dup length 0 gt {(, )} {pop} ifelse}
							forall pop ConcatenateToMark TruncateTo255
							dup length 0 eq {pop mark WithinTitles (=WithinTitles) ConcatenateToMark} if
					/OUT pdfmark
					showpage
				} if  % CircleNonEmpty ...
			} for  % WithinPage, WithinTitles
		} bind for  % SheetNum
		end
	} {pop} ifelse  % any glasses
} bind def  % /PrologueCode, which executed once, just before painting pages
@jdaw1 jdaw1 added enhancement New feature or request good first issue Good for newcomers labels Jul 2, 2022
jdaw1 added a commit that referenced this issue Jul 4, 2022
An implicit constant in DropletsPaint has become into a parameter, for use in the functionality heralded in issue #162.
@jdaw1
Copy link
Owner Author

jdaw1 commented Jul 4, 2022

Code in first post updated, mostly so that its call to DropletsPaint includes the new LengthsDistance parameter, but also with other tidyings.

@jdaw1
Copy link
Owner Author

jdaw1 commented Jul 13, 2022

Closed by commit b86f29b

The code at the top had an error: the CircleNonEmpty test worked for pages, but the first mark /Count … /OUT pdfmark assumed all were non-empty. Happily, ShowPage effectively handles this.

@jdaw1 jdaw1 closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant