{"id":8985,"date":"2022-09-16T15:24:35","date_gmt":"2022-09-16T09:54:35","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/"},"modified":"2022-09-16T15:24:35","modified_gmt":"2022-09-16T09:54:35","slug":"solved-question-about-setting-opacity-property","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/","title":{"rendered":"[Solved] question about setting &#8216;opacity&#8217; property"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-73408206\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"73408206\" data-parentid=\"73350544\" data-score=\"0\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>I managed to solve the example to get the SCREEN color of div2:<br \/>\nfirst we apply the simple alpha compositing formula:<\/p>\n<blockquote>\n<p>co = Cs x as + Cb x ab x (1 &#8211; as) ; ao = as + ab (1-as)<\/p>\n<\/blockquote>\n<p>here :<br \/>\n{div2} Cs = (100\/255, 200\/255, 50\/255)  ; as = 0.5<br \/>\n{div1} Cb = (22\/255, 177\/255, 200\/255)  ; ab = 0.4<br \/>\n&#8230;.<\/p>\n<p>co = ( 0.213 ,  0.53 ,  0.25 )<br \/>\nao = 0.7<\/p>\n<p><strong>NOW WE APPLY the opacity. In my example I set it to 0.7 , (it&#8217;s the same value as the result of ao but it&#8217;s a coincidence)<\/strong><br \/><strong>and that&#8217;s what I was looking for: how to apply opacity in color calculation formulas<\/strong><\/p>\n<blockquote>\n<p>co = co * 0.7<br \/>\nao = ao * 0.7<\/p>\n<\/blockquote>\n<p>In my question I gave the link:<br \/><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.w3.org\/TR\/css-color-3\/#transparency\">https:\/\/www.w3.org\/TR\/css-color-3\/#transparency<\/a><br \/>\nand an excerpt from the passage that I did not understand<br \/>\non this site:<\/p>\n<p><em>&#8220;If the object has children, then the effect is as if the children were blended against the current background using a mask where the value of each pixel of the mask is alphavalue&#8221;<\/em><\/p>\n<p>i understand now the : &#8220;using a mask&#8221; means doing this :  multiply RGBA,( co and ao), by opacity<\/p>\n<hr>\n<p>co = ( 0.213  * <strong>0.7<\/strong> ,  0.53 * <strong>0.7<\/strong> ,  0.25 * <strong>0.7<\/strong> )  ; ao = 0.7 * <strong>0.7<\/strong><br \/>\nco= (0.15, 0.37, 0.18)<br \/>\nao = 0.49<\/p>\n<p>the rest is the calculation of the color obtained after &#8220;opacity&#8221; on the background :<\/p>\n<p>We compose with the color of the background:<br \/>\n(note <em><strong>co is premultiplied<\/strong><\/em>, so we apply :<\/p>\n<blockquote>\n<p>= Cs + Cb * ab * (1-as)<br \/>\nCs is the color calculated previously (premultiplied) : (0.15 0.37<br \/>\n0.18)<br \/>\nCb is the background color (77\/255 , 100\/255 , 150\/255) ab=1<br \/>\n= ( 0.30 , 0.57 , 0.48 )<\/p>\n<\/blockquote>\n<p><strong>a screenshot of div2 gives the same color<\/strong><\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved question about setting &#8216;opacity&#8217; property <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] I managed to solve the example to get the SCREEN color of div2: first we apply the simple alpha compositing formula: co = Cs x as + Cb x ab x (1 &#8211; as) ; ao = as + ab (1-as) here : {div2} Cs = (100\/255, 200\/255, 50\/255) ; as = 0.5 {div1} &#8230; <a title=\"[Solved] question about setting &#8216;opacity&#8217; property\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\" aria-label=\"More on [Solved] question about setting &#8216;opacity&#8217; property\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[464],"class_list":["post-8985","post","type-post","status-publish","format-standard","hentry","category-solved","tag-css"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] question about setting &#039;opacity&#039; property - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] question about setting &#039;opacity&#039; property - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] I managed to solve the example to get the SCREEN color of div2: first we apply the simple alpha compositing formula: co = Cs x as + Cb x ab x (1 &#8211; as) ; ao = as + ab (1-as) here : {div2} Cs = (100\/255, 200\/255, 50\/255) ; as = 0.5 {div1} ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-16T09:54:35+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] question about setting &#8216;opacity&#8217; property\",\"datePublished\":\"2022-09-16T09:54:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\"},\"wordCount\":241,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"css\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\",\"name\":\"[Solved] question about setting 'opacity' property - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-16T09:54:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] question about setting &#8216;opacity&#8217; property\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] question about setting 'opacity' property - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] question about setting 'opacity' property - JassWeb","og_description":"[ad_1] I managed to solve the example to get the SCREEN color of div2: first we apply the simple alpha compositing formula: co = Cs x as + Cb x ab x (1 &#8211; as) ; ao = as + ab (1-as) here : {div2} Cs = (100\/255, 200\/255, 50\/255) ; as = 0.5 {div1} ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/","og_site_name":"JassWeb","article_published_time":"2022-09-16T09:54:35+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] question about setting &#8216;opacity&#8217; property","datePublished":"2022-09-16T09:54:35+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/"},"wordCount":241,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["css"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/","url":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/","name":"[Solved] question about setting 'opacity' property - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-16T09:54:35+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-question-about-setting-opacity-property\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] question about setting &#8216;opacity&#8217; property"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=8985"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/8985\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=8985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=8985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=8985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}