Skip to content

Commit

Permalink
[Text] Apply parentAlpha when rendering text (#2336)
Browse files Browse the repository at this point in the history
Fixes #2317
  • Loading branch information
gpeal authored Jul 16, 2023
1 parent 387b7c7 commit cd30afd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
.idea/codeStyleSettings.xml
.idea/compiler.xml
.idea/androidTestResultsUserPreferences.xml
.idea/appInsightsSettings.xml
.idea/migrations.xml

# Gradle
.idea/**/gradle.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void drawLayer(Canvas canvas, Matrix parentMatrix, int parentAlpha) {
canvas.save();
canvas.concat(parentMatrix);

configurePaint(documentData, parentMatrix);
configurePaint(documentData, parentAlpha);

if (lottieDrawable.useTextGlyphs()) {
drawTextWithGlyphs(documentData, parentMatrix, font, canvas);
Expand All @@ -139,7 +139,7 @@ void drawLayer(Canvas canvas, Matrix parentMatrix, int parentAlpha) {
canvas.restore();
}

private void configurePaint(DocumentData documentData, Matrix parentMatrix) {
private void configurePaint(DocumentData documentData, int parentAlpha) {
if (colorCallbackAnimation != null) {
fillPaint.setColor(colorCallbackAnimation.getValue());
} else if (colorAnimation != null) {
Expand All @@ -156,7 +156,7 @@ private void configurePaint(DocumentData documentData, Matrix parentMatrix) {
strokePaint.setColor(documentData.strokeColor);
}
int opacity = transform.getOpacity() == null ? 100 : transform.getOpacity().getValue();
int alpha = opacity * 255 / 100;
int alpha = opacity * 255 / 100 * parentAlpha / 255;
fillPaint.setAlpha(alpha);
strokePaint.setAlpha(alpha);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.10.2","fr":25,"ip":0,"op":107,"w":796,"h":972,"nm":"Simple Logo Reveal","ddd":0,"assets":[{"id":"comp_0","nm":"_Main Text Placeholder","fr":25,"layers":[{"ddd":0,"ind":1,"ty":5,"nm":"Text 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[498.57,80.748,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[50,50,100],"ix":6,"l":2}},"ao":0,"t":{"d":{"k":[{"s":{"s":173,"f":"Nunito-Black","t":"SAMPLE TEXT","ca":1,"j":2,"tr":0,"lh":207.600006103516,"ls":0,"fc":[1,0.69,0]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":250.25025025025,"st":0,"ct":1,"bm":0}]}],"fonts":{"list":[{"fName":"Nunito-Black","fFamily":"Nunito","fStyle":"Black","ascent":71.8994140625}]},"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"_Main Text Placeholder","refId":"comp_0","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.927],"y":[0.689]},"o":{"x":[1],"y":[0.007]},"t":60,"s":[13]},{"t":74,"s":[99]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.038,"y":1},"o":{"x":0.766,"y":0},"t":60,"s":[396,888,0],"to":[0,-54,0],"ti":[0,54,0]},{"t":78,"s":[396,564,0]}],"ix":2,"l":2},"a":{"a":0,"k":[500,50,0],"ix":1,"l":2},"s":{"a":0,"k":[55,55,100],"ix":6,"l":2}},"ao":0,"w":1000,"h":100,"ip":-3,"op":107,"st":-3,"bm":0}],"markers":[],"chars":[{"ch":"S","size":173,"style":"Black","w":66.7,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-4.923,-4.524],[-8.699,0],[-5.635,3.418],[0,7.943],[4.416,3.353],[4.7,1.107],[0,0],[1.861,1.042],[0,3.516],[-2.403,2.409],[-5.493,0],[-2.84,-3.743],[-0.468,-3.841],[0,0],[5.116,3.63],[7.317,0],[4.34,-4.134],[0,-6.445],[-4.415,-2.995],[-6.149,-1.432],[0,0],[-2.397,-1.627],[0,-3.906],[5.582,-2.018],[3.512,0],[3.104,4.753],[0.22,4.07]],"o":[[-0.098,7.748],[4.92,4.558],[7.46,0],[5.635,-3.418],[0,-6.38],[-2.554,-1.92],[0,0],[-6.561,-1.562],[-2.839,-1.627],[0,-3.19],[2.403,-2.409],[6.803,0],[1.529,2.051],[0,0],[0,-7.975],[-5.116,-3.629],[-7.951,0],[-4.34,4.134],[0,5.957],[2.554,1.726],[0,0],[5.109,1.205],[2.365,1.66],[0,5.209],[-2.885,1.042],[-7.839,0],[-1.63,-2.539],[0,0]],"v":[[4.834,-23.145],[12.072,-4.736],[32.5,2.1],[52.143,-3.027],[60.596,-20.068],[53.972,-34.668],[43.091,-39.209],[33.345,-41.504],[20.713,-45.41],[16.455,-53.125],[20.059,-61.523],[31.904,-65.137],[46.369,-59.521],[49.365,-50.684],[58.496,-50.684],[50.822,-68.091],[32.172,-73.535],[13.736,-67.334],[7.227,-51.465],[13.849,-38.037],[26.904,-33.301],[36.317,-31.104],[47.575,-26.855],[51.123,-18.506],[42.751,-7.666],[33.155,-6.104],[16.74,-13.232],[13.965,-23.145]],"c":true},"ix":2},"nm":"S","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"S","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":"A","size":173,"style":"Black","w":66.7,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[21.973,-29.395],[33.545,-61.084],[44.434,-29.395]],"c":true},"ix":2},"nm":"A","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[1.465,0],[11.426,0],[19.189,-21.484],[47.559,-21.484],[54.834,0],[65.479,0],[39.453,-71.729],[28.467,-71.729]],"c":true},"ix":2},"nm":"A","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"A","np":5,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":"M","size":173,"style":"Black","w":83.3,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0.098,3.597],[0,1.758],[0,0],[0,0],[0,0],[0,0],[0.065,-3.385],[0,-1.465],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,-1.692],[-0.098,-3.596],[0,0],[0,0],[0,0],[0,0],[0,3.874],[-0.066,3.386],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[7.373,0],[16.65,0],[16.65,-42.334],[16.504,-50.269],[16.357,-58.301],[16.357,-60.498],[37.032,0],[46.66,0],[67.139,-60.498],[67.041,-49.609],[66.943,-42.334],[66.943,0],[76.221,0],[76.221,-71.729],[62.398,-71.729],[41.919,-11.084],[21.294,-71.729],[7.373,-71.729]],"c":true},"ix":2},"nm":"M","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"M","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":"P","size":173,"style":"Black","w":66.7,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[-3.482,4.15],[0,5.599],[3.902,3.597],[6.345,0],[0,0]],"o":[[0,0],[0,0],[0,0],[7.175,0],[3.481,-4.15],[0,-6.51],[-3.902,-3.596],[0,0],[0,0]],"v":[[8.545,0],[18.262,0],[18.262,-30.322],[40.659,-30.322],[56.643,-36.548],[61.865,-51.172],[56.013,-66.333],[40.643,-71.729],[8.545,-71.729]],"c":true},"ix":2},"nm":"P","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,-5.273],[2.699,-1.855],[4.33,0],[0,0],[0,0],[0,0],[-2.133,-1.009]],"o":[[0,4.688],[-2.699,1.855],[0,0],[0,0],[0,0],[3.716,0],[3.878,1.888]],"v":[[52.051,-51.123],[48.003,-41.309],[37.459,-38.525],[18.262,-38.525],[18.262,-63.379],[37.459,-63.379],[46.233,-61.865]],"c":true},"ix":2},"nm":"P","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"P","np":5,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":"L","size":173,"style":"Black","w":55.62,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[7.617,0],[53.32,0],[53.32,-8.545],[17.334,-8.545],[17.334,-71.729],[7.617,-71.729]],"c":true},"ix":2},"nm":"L","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"L","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":"E","size":173,"style":"Black","w":66.7,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[8.545,0],[61.328,0],[61.328,-8.545],[18.018,-8.545],[18.018,-32.861],[57.373,-32.861],[57.373,-41.162],[18.018,-41.162],[18.018,-62.939],[60.596,-62.939],[60.596,-71.729],[8.545,-71.729]],"c":true},"ix":2},"nm":"E","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"E","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":" ","size":173,"style":"Black","w":27.78,"data":{},"fFamily":"Nunito"},{"ch":"T","size":173,"style":"Black","w":61.08,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[1.611,-71.729],[1.611,-63.184],[25.781,-63.184],[25.781,0],[35.596,0],[35.596,-63.184],[59.766,-63.184],[59.766,-71.729]],"c":true},"ix":2},"nm":"T","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"T","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"},{"ch":"X","size":173,"style":"Black","w":66.7,"data":{"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[33.3,-29.492],[52.411,0],[64.429,0],[39.481,-36.799],[63.266,-71.729],[51.735,-71.729],[33.782,-44.287],[15.685,-71.729],[3.57,-71.729],[27.367,-36.798],[1.981,0],[13.657,0]],"c":true},"ix":2},"nm":"X","mn":"ADBE Vector Shape - Group","hd":false}],"nm":"X","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}]},"fFamily":"Nunito"}]}

0 comments on commit cd30afd

Please sign in to comment.