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

Extend logo image elements to have a file for scale 2 #65

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

Rinzwind
Copy link
Contributor

This pull request extends the <img> elements for the logo on the index page and navigation bar to have a file for scale 2. I used the snippet below to generate the PNG files, it’s based on the one I used in Pharo pull request #16305. Note that the small logo had some padding which the newly generated file doesn’t have. The SVG file could perhaps also just be used directly in place of the PNG files. With Pharo 12 having better ‘Retina display’ support (see Pharo pull request #15647) it would in any case be nice for the website to have that too.

Metacello new
	baseline: 'AthensSVG';
	repository: 'github://pharo-contributions/Athens-SVG/src';
	load.
svgRoot := (Smalltalk at: #AthensSVGConverter) fromURL: 'https://files.pharo.org/media/logo/Pharo%20Logo%20SVG/Pharo_Logo_v3.0.svg'.
flarePath := (svgRoot instVarNamed: 'ids') at: 'flare'.
flarePath fill_opacity: (flarePath fill_opacity * flarePath opacity) asString.
#(('pharo' 471) ('pharo-logo-small' 100)) do: [ :arguments |
	arguments bind: [ :name :width |
		extent := width @ (svgRoot height value * (width / svgRoot width value)) rounded.
		#('' '-2x') keysAndValuesDo: [ :scale :suffix |
			| surface surfaceForm convertedForm |
			surface := AthensCairoSurface extent: extent * scale.
			surface drawDuring: [ :canvas |
				canvas pathTransform scaleBy: surface extent / (svgRoot width value @ svgRoot height value).
				svgRoot renderOn: canvas viewportExtent: surface extent ].
			surfaceForm := surface asForm.
			convertedForm := Form extent: surfaceForm extent depth: 32.
			0 to: convertedForm width do: [ :x |
				0 to: convertedForm height do: [ :y |
					| color |
					color := surfaceForm colorAt: x@y.
					convertedForm colorAt: x@y put:
						(color alpha > 0 ifTrue: [ color / color alpha ] ifFalse: [ color ]) ] ].
			PNGReadWriter putForm: convertedForm onFileNamed: FileLocator imageDirectory / (name , suffix , '.png') ] ] ]

…d ‘navbar’ templates to have a file for scale 2.
@estebanlm estebanlm merged commit 6caf6af into pharo-project:main Apr 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants