{"id":24304606,"url":"https://github.com/montefra/mimic_alpha","last_synced_at":"2026-03-16T01:20:53.259Z","repository":{"id":3986643,"uuid":"5082581","full_name":"montefra/mimic_alpha","owner":"montefra","description":"Python implementation of the algorithm from http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb?rq=1 to mimic RGBA colors with RGB","archived":false,"fork":false,"pushed_at":"2015-12-13T08:05:16.000Z","size":14,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-03-22T13:43:50.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"divio/django-cms","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/montefra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-17T13:58:48.000Z","updated_at":"2022-04-30T11:51:37.000Z","dependencies_parsed_at":"2022-09-24T02:42:58.417Z","dependency_job_id":null,"html_url":"https://github.com/montefra/mimic_alpha","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montefra%2Fmimic_alpha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montefra%2Fmimic_alpha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montefra%2Fmimic_alpha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montefra%2Fmimic_alpha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/montefra","download_url":"https://codeload.github.com/montefra/mimic_alpha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234300372,"owners_count":18810607,"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":[],"created_at":"2025-01-17T01:41:01.908Z","updated_at":"2025-09-26T09:30:27.358Z","avatar_url":"https://github.com/montefra.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"mimic_alpha\n===========\n\nThe function `colorAlpha_to_rgb` returns a list of RGB color that mimic \na RGBA on a given background.\nThe code implements the algorithm from \n[this stackoverflow post](http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb?rq=1y%)\n\nThe code has not been much tested. \nA by eye comparison between a pdf image with alpha channel and \na few values for the input color/alpha on white background shows that this approach is 'good enough'.\n\nDependances:\n  Numpy\n  Matplotlib\n\nWorks with python 2.7 and 3.2 (and likely 3.3)\n\nLicence:\n  This a free sofware and come without any warranty.\n  It can be freely used, modified and redistributed, \n  with the only requirement that the author (Francesco Montesano) \n  and the inspiration for the algorithm\n  (http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb?rq=1)\n  are aknowledged.\n\nversion 0.21\nauthor: \"Francesco Montesano (franz.bergesund@gmail.com)\"\n\n\nexample\n-------\n\n    import mimic_alpha as ma\n\n    print(ma.colorAlpha_to_rgb('r', 0.5))\n    \u003e\u003e\u003e [array([ 1. ,  0.5,  0.5])]\n    print(ma.colorAlpha_to_rgb(['r', 'g'], 0.5)) \n    \u003e\u003e\u003e [array([ 1. ,  0.5,  0.5]), array([ 0.5 ,  0.75,  0.5 ])]\n    print(ma.colorAlpha_to_rgb(['r', 'g'], [0.5, 0.3])) \n    \u003e\u003e\u003e [array([ 1. ,  0.5,  0.5]), array([ 0.7 ,  0.85,  0.7 ])]\n    print(ma.colorAlpha_to_rgb(['r', [1,0,0]], 0.5)) \n    \u003e\u003e\u003e [array([ 1. ,  0.5,  0.5]), array([ 1. ,  0.5,  0.5])]\n    print( ma.colorAlpha_to_rgb([[0,1,1], [1,0,0]], 0.5) ) \n    \u003e\u003e\u003e [array([ 0.5,  1. ,  1. ]), array([ 1. ,  0.5,  0.5])]\n    print(ma.colorAlpha_to_rgb(np.array([[0,1,1], [1,0,0]]), 0.5)) \n    \u003e\u003e\u003e [array([ 0.5,  1. ,  1. ]), array([ 1. ,  0.5,  0.5])]\n    print(ma.colorAlpha_to_rgb(np.array([[0,1,1], [1,0,0]]), 0.5, bg='0.5')) \n    \u003e\u003e\u003e [array([ 0.25,  0.75,  0.75]), array([ 0.75,  0.25,  0.25])]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmontefra%2Fmimic_alpha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmontefra%2Fmimic_alpha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmontefra%2Fmimic_alpha/lists"}