{"id":19468666,"url":"https://github.com/pharo-graphics/iconfactory","last_synced_at":"2025-04-15T05:37:48.446Z","repository":{"id":113718306,"uuid":"400285583","full_name":"pharo-graphics/IconFactory","owner":"pharo-graphics","description":" IconFactory is a utility for importing PNG images from a directory into a class (originally developed by P. Uhnak)","archived":false,"fork":false,"pushed_at":"2024-04-16T06:24:59.000Z","size":346,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-15T05:37:43.583Z","etag":null,"topics":["graphics","pharo"],"latest_commit_sha":null,"homepage":"","language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pharo-graphics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-26T19:37:09.000Z","updated_at":"2024-08-29T07:54:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5c6900c-7192-4071-96ad-b30208069a4b","html_url":"https://github.com/pharo-graphics/IconFactory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-graphics%2FIconFactory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-graphics%2FIconFactory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-graphics%2FIconFactory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pharo-graphics%2FIconFactory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pharo-graphics","download_url":"https://codeload.github.com/pharo-graphics/IconFactory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016306,"owners_count":21198828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphics","pharo"],"created_at":"2024-11-10T18:43:10.340Z","updated_at":"2025-04-15T05:37:48.414Z","avatar_url":"https://github.com/pharo-graphics.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IconFactory \nIconFactory is a utility for importing PNG images from a directory into a class developed by Peter Uhnak and maintained by Stéphane Ducasse.\n\n## Principle\nEach file will be compiled into the **class-side** of the target class as `\u003cfileName\u003eIcon` selector in base64 format. (Icon suffix will not be duplicated.).\n\nThis enables you to distribute the images directly with your source code.\nOnce imported, you can access the `Form` (Pharo's image representation) by sending the appropriate selector, e.g. `MyIcons myCoolIcon`.\nOnly PNG files are currently supported.\n\n## Installation\n\n```smalltalk\nMetacello new\n    baseline: #IconFactory;\n    repository: 'github://pharo-graphics/IconFactory/repository';\n    load\n```\n\n## Loading images into a class\n\nIf `MyIcons` class doesn't exist, it will be created in a category of the same name.\nThis method will install all images not present in #MyIcons and remove all selectors representing images that are not longer present in the directory. \n\n```smalltalk\nIconFactory\n\tsyncDirectory: '/home/some/path/myIcons'\n\tintoClass: #MyIcons\n```\n\nNote that the paths below can also be given as file reference. For example, if you want to load all the png in your working directory.\n\n```smalltalk\nIconFactory\n\tsyncDirectory: FileSystem workingDirectory\n\tintoClass: #MyIcons\n```\n\nYou can use a bit of GUI too.\n\n```smalltalk\nd := UIManager default chooseDirectory.\nIconFactory syncDirectory: d intoClass: #MyIcons\n```\n\nIt effectively combines the following two options.\n\n## Add only images\n\nAdd all images from the directory into the class.\n\n```smalltalk\nIconFactory\n\tloadDirectory: 'd:\\some\\path\\myIcons'\n\tintoClass: #MyIcons\n```\n\n## Remove old selectors\n\nRemove all selectors (images) from the class that are not present in the directory.\n\n```smalltalk\nIconFactory\n\tremoveFromClass: #MyIcons\n\tnotInDirectory: 'd:\\some\\path\\myIcons'\n```\n\n## Creating icon for a single file\n\nThere are private methods that you can use at your own risk. Adding manually images one by one suggests a flaw in a workflow (that was the case for me anyway); but feel free to open a issue with your use case.\n\n## Performance note\n\nThe data is stored as base64 in one `\u003cname\u003eIconContents` method and is converted to `Form` in `\u003cname\u003eIcon`. Because the conversion is slow, it is automatically cached by a Dictionary.\n\nDepending on the size of the image (tested on 24x24) it can easily be 1000x times faster.\n\n```smalltalk\n\"Without dictionary\"\n[ BormEditorIcons personIcon ] bench. \"'2,271 per second'\"\n\n\"With dictionary\"\n[ BormEditorIcons personIcon ] bench. \"'3,228,827 per second'\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpharo-graphics%2Ficonfactory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpharo-graphics%2Ficonfactory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpharo-graphics%2Ficonfactory/lists"}