mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 18:12:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			42 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|     test(() => {
 | |
|         let testCounter = 1;
 | |
|         function testPart(part) {
 | |
|             println(`${testCounter++}. ${JSON.stringify(part())}`);
 | |
|         }
 | |
| 
 | |
|         const canvas = document.createElement("canvas");
 | |
|         const context = canvas.getContext("2d");
 | |
| 
 | |
|         // 1. Integers
 | |
|         testPart(() => {
 | |
|             context.fillStyle = "rgb(0,255,0)";
 | |
|             return context.fillStyle;
 | |
|         });
 | |
| 
 | |
|         // 2. Decimals
 | |
|         testPart(() => {
 | |
|             context.fillStyle = "rgb(0.28813966673057,254.56022744510793,0.2973971574794)";
 | |
|             return context.fillStyle;
 | |
|         });
 | |
| 
 | |
|         // 3. Clamp numbers between 0-255
 | |
|         testPart(() => {
 | |
|             context.fillStyle = "rgba(-50,500,-50,1)";
 | |
|             return context.fillStyle;
 | |
|         });
 | |
| 
 | |
|         // 4. Percentages
 | |
|         testPart(() => {
 | |
|             context.fillStyle = "rgb(0%,100%,0%)";
 | |
|             return context.fillStyle;
 | |
|         });
 | |
| 
 | |
|         // 5. Percentages
 | |
|         testPart(() => {
 | |
|             context.fillStyle = "rgb(0,calc(infinity),0)";
 | |
|             return context.fillStyle;
 | |
|         });
 | |
|     });
 | |
| </script>
 | 
