Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Click on Non-transparent Part of an Image Date: Sun, 2 Apr 2023 12:08:02 +0200 Lines: 40 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net /HhM0eAjDamPq6UDu2Mi1wNHLxD/NZ9+dytx4PBmSaxauspO44 Cancel-Lock: sha1:Jq5I+djYO7yLSvojUqUEM1OeghY= Content-Language: de-DE In-Reply-To: Xref: csiph.com comp.lang.javascript:41256 Andrew Poulos, 2023-04-02 01:16: > On Thursday, 30 March 2023 at 03:40:33 UTC+11, Michael Haufe (TNO) > wrote: >> On Sunday, March 26, 2023 at 5:43:12 PM UTC-5, Andrew Poulos wrote: >> >>> Is there a way to detect a click only on the non-transparent part >>> of an image? >>> >>> That is, a click on a transparent part works as if pointer-events >>> is set to none and a click on a non-transparent part works as if >>> pointer-events is set to auto. >> You can use css clip-path to define clickable areas. >> >> >> >> Example usage: >> >> >> >> clicking on the clipped areas will not trigger an alert but the >> visible portions will > > Thanks for the replies. Alas the image doesn't have regular shaped > transparent parts and using a secondary canvas won't work as well as > I'd like. clip-path can also be a complex path: For example: clip-path: path('M 0 200 L 0,75 A 5,5 0,0,1 150,75 L 200 200 z'); Also see -- Arno Welzel https://arnowelzel.de