[MAKE] Boot Logo for a Laptop
[MAKE] Boot Logo for a Laptop
Author: Silvia Hao
For ThinkPad T440s, the boot logo is customizable through BIOS Update Utility, as long as we follow certain constraints:
1
.image format: GIF
2
.image dimensions: < 768×432
3
.image file size: < 30KiB
So to make my custom logo, I did this.
Generate the vector drawing
Generate the vector drawing
/13/18 15:41:50 In[24]:=
vectorgraph=ExportString[Style["iea",100,Bold,FontFamily"Constantia"]//Echo,"PDF"]//ImportString[#,"PDF"]〚1〛&
I want a low-poly style, so I’m using a large MaxCellMeasure.
/13/18 15:48:42 In[29]:=
bregionInit=vectorgraph//BoundaryDiscretizeGraphics[#,MaxCellMeasure10]&
same reason, a large MaxCellMeasure. But I want somewhat regular triangle pieces, so a high MeshQualityGoal.
But due to the file size restriction, we can’t have too many triangles, so by trial&error I chose MeshQualityGoal0.7.
/13/18 15:52:51 In[35]:=
mesh=TriangulateMesh[bregionInit,MeshQualityGoal.7,MaxCellMeasure200]
/13/18 15:52:51 Out[35]=
Now we have our triangles and their positions collected here.
/13/18 16:01:40 In[44]:=
polys=MeshPrimitives[mesh,2];centers=PropertyValue[{mesh,2},MeshCellCentroid];polys//Shortcenters//Short
/13/18 16:01:40 Out[46]//Short=
{Polygon[{{2.115,19.2363},{4.8094,19.2363},{1.94625,20.9013}}],367,Polygon[1]}
/13/18 16:01:40 Out[47]//Short=
{{2.95688,19.7913},367,{58.7516,38.3716}}
I want a less boring logo, some color could be helpful.
One possible way to paint my triangles is to shade them according to their heights.
We extract the heights and rescale them to get a percentage λ so those near the central horizontal line have values near 0, and those furthest have values near 1. It will serve like a “gradient mask” for latter use.
/13/18 16:55:17 In[110]:=
λs=centers〚;;,2〛//RightComposition[branch[Identity,Mean],Apply[Subtract]/*Abs/*Rescale];
To paint the triangles I chose “StarryNightColors”.
/13/18 16:58:40 In[118]:=
polysNew=MapThread[Function[{p,c,λ},{FaceForm[ColorData["StarryNightColors"][2λ]],p}],{polys,centers,λs},1];polysNew//Shallow/*Short
/13/18 16:58:40 Out[119]//Short=
{{FaceForm[1],Polygon[1]},{FaceForm[1],Polygon[1]},7,{FaceForm[1],Polygon[1]},359}
/13/18 16:58:41 In[120]:=
logo=Graphics[{polysNew},BackgroundBlack,PlotRangePadding0]
/13/18 16:58:41 Out[120]=
Now this is nice, but not good/striking enough for me to insert into my booting routine sequence.
Bear in mind the file size restriction, one of the possible variations we can try is some geometric transformations.
Bear in mind the file size restriction, one of the possible variations we can try is some geometric transformations.
/13/18 16:58:48 In[121]:=
polysNew=MapThreadFunction[{p,c,λ},{FaceForm[ColorData["StarryNightColors"][2λ]],MapAt[(1-λ)#+λc&,{1,;;}]@p}],polys,centers,λs//Functionx,,1;logo=Graphics[{polysNew},BackgroundBlack,PlotRangePadding0]
1-
3
Cosx
π
2
2
/13/18 16:58:48 Out[122]=
Now for me it looks better, except the central pieces are way too dark. One choice is to add some bright edge for them.
/13/18 17:04:57 In[136]:=
polysNew=MapThreadFunction[{p,c,λ},{If[λ>.3,{},EdgeForm@{GrayLevel[1-],AbsoluteThickness[0]}],FaceForm[ColorData["StarryNightColors"][2λ]],MapAt[(1-λ)#+λc&,{1,;;}]@p}],polys,centers,λs//Functionx,,1;logo=Graphics[{polysNew},BackgroundBlack,PlotRangePadding0]
.5
λ
1-
3
Cosx
π
2
2
/13/18 17:04:57 Out[137]=
Now I think we are good to go :D
Generate the raster image
Generate the raster image
Further reduce the file size
Further reduce the file size
Unfortunately, despite our very carefully tuning, the resulting GIF may still exceeds the file size restriction, which is 30KiB for my ThinkPad T440s.
To reduce the file size, one of many tools that can be used is Gifsicle.
gifsicle -k 50 -O3 --no-extensions --no-comments < logoImg.gif > LOGO2.gif
Flash the boot logo to BIOS firmware
Flash the boot logo to BIOS firmware
Finally we follow the instruction from the BIOS Update Utility VERY carefully. The customized boot logo should have been installed.