MCPcopy Create free account
hub / github.com/codrops/RainEffect / init

Function init

src/index.js:84–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82loadTextures();
83
84function init(){
85 canvas=document.querySelector('#container');
86
87 let dpi=window.devicePixelRatio;
88 canvas.width=window.innerWidth*dpi;
89 canvas.height=window.innerHeight*dpi;
90 canvas.style.width=window.innerWidth+"px";
91 canvas.style.height=window.innerHeight+"px";
92
93 raindrops=new Raindrops(
94 canvas.width,
95 canvas.height,
96 dpi,
97 dropAlpha,
98 dropColor,{
99 trailRate:1,
100 trailScaleRange:[0.2,0.45],
101 collisionRadius : 0.45,
102 dropletsCleaningRadiusMultiplier : 0.28,
103 }
104 );
105
106 textureFg = createCanvas(textureFgSize.width,textureFgSize.height);
107 textureFgCtx = textureFg.getContext('2d');
108 textureBg = createCanvas(textureBgSize.width,textureBgSize.height);
109 textureBgCtx = textureBg.getContext('2d');
110
111 generateTextures(textureRainFg,textureRainBg);
112
113 renderer = new RainRenderer(canvas, raindrops.canvas, textureFg, textureBg, null,{
114 brightness:1.04,
115 alphaMultiply:6,
116 alphaSubtract:3,
117 // minRefraction:256,
118 // maxRefraction:512
119 });
120
121 setupEvents();
122}
123
124function setupEvents(){
125

Callers 1

loadTexturesFunction · 0.70

Calls 3

createCanvasFunction · 0.70
generateTexturesFunction · 0.70
setupEventsFunction · 0.70

Tested by

no test coverage detected