From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Face transparency attribute Date: Mon, 18 Mar 2024 21:50:44 +0800 Message-ID: <87sf0nr6mj.fsf@yahoo.com> References: <87sf2v8lu4.fsf@nixos.mail-host-address-is-not-set> <875xzrw1te.fsf@yahoo.com> <87v85k1myr.fsf@posteo.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9745"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Sebastian =?utf-8?Q?W=C3=A5linder?= , emacs-devel@gnu.org To: Nate Sandy Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 18 14:52:25 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rmDPd-0002Jf-98 for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Mar 2024 14:52:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmDOV-0002BA-44; Mon, 18 Mar 2024 09:51:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmDOO-00027S-AW for emacs-devel@gnu.org; Mon, 18 Mar 2024 09:51:08 -0400 Original-Received: from sonic307-56.consmr.mail.ne1.yahoo.com ([66.163.190.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rmDOJ-0002hB-9W for emacs-devel@gnu.org; Mon, 18 Mar 2024 09:51:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1710769858; bh=wfjCNbMi5msNrAgq6JFMwLorRFI2mpU+HaizfhNST1M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=mfn41WhoVdfnDCurQGibWGvMJufAoV2m6Ltxl4H5oSbqezGjLCHoaVROPIQXEcGcxOAqUZBVtPGcSEEdyOXIAQNBh7ijjhS+1EUUHxOR7k0xt2pRKgXTyVtdFAuzBAv1tDlJN3+oSutlRnWwbxj35A3NKiMohngfi3H5h9csreLeiur8g4vm2dEYlaBtMisj4Ei7CjY6OjcWJlalp+ysQwS4t/w6ltDO7nmIp5OI+F2SiLF8ezyqkDa5T52C9ZQ+x4of2mxytwGLvOCUFuUtzy8bCAhO9QSnMNGzBeKo7QmHAlxPqv2w+A17bGg82HwstSCKFvjE9+LkV8yV2XD2Bw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1710769858; bh=5LM+qSGePmJy4BqAfxyrW8w89rQjnK/k0BVZnqcIpot=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=KP2CNPpIy9GrdkX7/5UidSJPmivNYXw2n/nDEW9vco988h6rYU9IR/kAwGfOm89GNia6+tXwA7Kmr+iu4VtY6KJeWZkPjXQX/msckkNdJDU4Zz9zIeY9eol4/6F/TyXMV01OF2BNUNpi901vcnpV9p4toU4Z9+rbs4W89tw5Y089pgwW5JGcBKbH9o1uZEZkIZDysYEGcLZHO/1SiPJzLhU/yBw/H7lFpDFienYXYopr7US4bP2pmnqHnsXdAppDbFJK0G9KF2Pw+1ssUxHEqbFniGg0cKIGUC017eQxIZcZtE0qGWUkQPyxR6rltSzkXI7+6YBpuk6bR0Vj/EbkrA== X-YMail-OSG: WqF1wZEVM1l.0STmwQmFElkvyv5wQXHsxwP.d0kM9FT1lyh85papTj1QmUnFEQ8 mcirCbUTfc5XZ0jmHiAWwizQDfUkMKsgzhvr1Hi7TGbjdyj9vem5X0dqayQL4SpAlDU4zt842MnI SVyIgcJd1NM3xDry2s_oHKz.k8CH55yUlNaiB.GdcuK2w.YHKyWzozFARqP86FgM6BPK..b3_Mf0 gSedhpT9fmdki6gVMmz8Dl9vgyCVvN0sLqtdipRYy89YnNF06cG1fxG3N3WC_UUR54O9ZjxlG7tA f96.3BfiddZwzbsYqj1N03W1NDRG.kXXeoNJpJ3s90CzdcTvzlNI85hFPSyv4wpHDCL.Q3jtq_b8 K7vUMMBfPl2qB47idHjLAFurj9M0q8nqr00HS79drnihGR_t_6nhCE7DDNX3Hm1itwE59MOiwC3_ c59YPFlB8Uah4_AhyUk4sXreOQChurxXuF6H9kKsYLmUqdoFLNUU69YCaZjHPdK5VXhvWqQAA0Ii m1Cr4lQ6VV4Rb9YloH.o8ABWryLZ9HotSI1GQsVAPsVXK0e2E2Ma_5CT4mQurWOSpp3TBHQ65Olq vrK7krlMNFc8wKsAFBYvF7M0J9J_dT2DC.eM_gBOzdjrw0WZCjOsyMBxaurR6Oe2f7o3wvfQ8LHL ud2pregACgd7_Q5En70uguglxyD0aWIbFCkndqU4PVEg2gnTIjG7zcIaa5CMTioyG79aXrmnTUIG 8M.IclyAyreSNNW83so61OX81G3rEzGxaensmzuO3JEsPr90tM48phCZlrp2VQRBvMaurWi4cSM3 ORqGnNNTrjO7JF83ADUESuWAeEB2ytThS.w3pixalW X-Sonic-MF: X-Sonic-ID: 9cd8127d-24d9-4115-8f7e-ddd5c16bd4d2 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Mon, 18 Mar 2024 13:50:58 +0000 Original-Received: by hermes--production-sg3-6dc75bc8fb-7l9bh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b910648f2769cfc2412315d44bfb8503; Mon, 18 Mar 2024 13:50:51 +0000 (UTC) In-Reply-To: <87v85k1myr.fsf@posteo.de> (Nate Sandy's message of "Sun, 17 Mar 2024 23:02:20 +0000") X-Mailer: WebService/1.1.22129 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.190.31; envelope-from=luangruo@yahoo.com; helo=sonic307-56.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317169 Archived-At: Nate Sandy writes: > Po Lu writes: > >> Neither approach is easy or exceptionally challenging, so interested >> individuals are invited to chose whichever they should find more to >> their liking. > > Hi Po, > > I have written a patch for this for the pgtk backend and went with the > first route - supporting an alpha channel in face colors. I figured it's > nicer since we get alpha channels for all other text decorations as > well. > > The way it works is that when painting a background color (one which > respects alpha-background), we instead compose it with the frame > background color via a re-implementation of CAIRO_OPERATOR_OVER. I > didn't find a way to do this with cairo itself without painting the > surface inbetween. > > I also made sure that this patch integrates with alpha-background, which > is also my primary use case - fully hiding faces which don't respect > alpha-background. > > The only syntax supported for transparency is gtk_parse_rgba's > `rgba(255,255,255,1.0)`. Maybe we would want support for `#ff00ff00` too? > > One interesting quirk is that when changing the opacity of the `default` > face to less than 1, the whole background is fully transparent again. I > am not sure whether this is a fault in my code or because of some extra > logic regarding the `default` face. > > Attached are a screenshot and the patch. I'd very much appreciate > feedback. If necessary I could also try to implement this for X and/or > terminals, however I don't have access to other platforms. I'm not happy with this approach, since it defines the alpha value as an integral component of a face's foreground and background colors, rather than an attribute (or attributes) the face merging process can manage independently to prevent alpha values from being transferred between faces against the user's wishes, and more broadly to enable specifying alpha values separately from face colors, which there is plenty of reason for users to replace that might not apply to transparency in identical circumstances. Furthermore, the transparency implemented in this patch is specified with premultiplied values--premultiplied alpha is more efficient on free systems, but admits of invalid color values whose behavior is undefined across all the systems and toolkits we support. It's already too easy for Emacs users to shoot themselves in the foot, and muddling the waters with the potential for invalid color definitions would be a step in the wrong direction, in my humble estimation, so I would prefer an implementation that exposes straight alpha values to users, converting between those and the suitable alpha format for the toolkit at display time.