// SPDX-License-Identifier: MPL-2.0 #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #include #include #include #include #include #include #include #include using namespace std; namespace fs=filesystem; struct point { long double x; long double y; }; struct pixel { uint16_t x; uint16_t y; }; const point AP0={0,0}; const point AP1={0.35,0.05}; const point AP2={0.65,1.0}; const point AP3={1,1}; const point BP0={0,0}; const point BP1={0.1,1.5}; const point BP2={0.3,1.0}; const point BP3={1,1}; long double bezier_1d(long double p0,long double p1,long double p2,long double p3,long double t) { long double u=1.0-t; return (u*u*u)*p0+3*(u*u)*t*p1+3*u*(t*t)*p2+(t*t*t)*p3; } long double find_t(long double p0,long double p1,long double p2,long double p3,long double x_search) { long double low=0.0; long double high=1.0; long double mid; for (int i=0;i<20;i++) { mid=(low+high)/2.0; long double x_mid=bezier_1d(p0,p1,p2,p3,mid); if (x_mid apply_bezier(point start,point p0,point p1,point p2,point p3,point end,int frames) { point vect; vect.x=end.x-start.x; vect.y=end.y-start.y; vector out; out.reserve(frames); for (int frame=0;frame& white_pixels) { vector img(w*h*3,0); for (auto& p:white_pixels) { if (p.xmax) return max; return (uint16_t)v; } int main (int argc,char **argv) { if (argc!=5) { cout<<"[Bootanim] Error: invalid argument."< logopixels(true_w*true_h,0); int offset_x=(true_w-w_image)/2; int offset_y=(true_h-h_image)/2; for (int y=0;y=0 && dst_x=0 && dst_y endco; for (int i=0;i127) { point p; p.x=i%true_w; p.y=i/true_w; endco.push_back(p); } } random_device rd; mt19937 gen(rd()); vector randco; randco.reserve(endco.size()); uniform_real_distribution dist_angle(0.0L,2.0L*M_PI); uniform_real_distribution dist_r1(0.0L,min((long double)true_w,(long double)true_h)/2); uniform_real_distribution dist_r2(min((long double)true_w,(long double)true_h)/2,(max((long double)true_w,(long double)true_h)+300)/2); uniform_int_distribution dist_c(0,1); long double cx=(long double)true_w/2.0; long double cy=(long double)true_h/2.0; for (int i=0;i> codata(301); for (int i=0;i> tempdata1; vector> tempdata2; tempdata1.reserve(endco.size()); tempdata2.reserve(endco.size()); for (int i=0;i> pixeldata(81); for (int i=0;i<80;i++) { for (int y=0;y data(pixeldata.size()*pixeldata[0].size()*sizeof(pixel)); size_t offset=0; for (size_t i=0;i=width-1 || px.x==0) { px.x=0xFFFF; } if (px.y>=height-1 || px.y==0) { px.y=0xFFFF; } memcpy(&data[offset],&px,sizeof(pixel)); offset+=sizeof(pixel); } } ofstream file("bootanim.bin",ios::binary); unsigned char magic[8]={'B','o','o','t','A','n','i','m'}; file.write((char*)magic,8); vector header(4); header[0]=width; header[1]=height; header[2]=pixeldata.size(); header[3]=pixeldata[0].size(); vector headerdata(4*8); memcpy(headerdata.data(),header.data(),headerdata.size()); file.write((char *)headerdata.data(),headerdata.size()); file.write((char *)data.data(),data.size()); file.close(); cout<<"[Bootanim] Successfully build boot animation as bootanim.bin."<