Code Hightlighter

code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
window.onload = function() {
     canvas = document.createElement("canvas");
     canvas.width = 400;
     canvas.height = 400;
     canvasContext = canvas.getContext("2d");
     document.body.appendChild(canvas);
     setInterval(gameCanvas, 1000/10);
}
function gameCanvas() {
     canvasContext.fillStyle = "black";
     canvasContext.fillRect(0, 0, canvas.width, canvas.height);
     canvasContext.fillStyle = "cyan";
     canvasContext.fillRect(0, 330, 20, 70);
     canvasContext.fillStyle = "orange";
     canvasContext.fillRect(380, 330, 20, 70);
     canvas.addEventListener("click", function() {
          canvasContext.fillStyle = "yellow";
          canvasContext.fillRect(25, 360, 15, 7);
     });
     canvasContext.fillStyle = "darkblue";
     canvasContext.fillRect(0, 0, canvas.width, 100);
     canvasContext.fillStyle = "red";
     canvasContext.fillRect(0, 100, canvas.width, 100);
     canvasContext.fillStyle = "gray";
     canvasContext.fillRect(30, 80, 80, 30);
     canvasContext.fillStyle = "gray";
     canvasContext.fillRect(200, 150, 80, 30);
     canvasContext.fillStyle = "gray";
     canvasContext.fillRect(250, 50, 80, 30);
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from typing import Iterator

# This is an example
class Math:
    @staticmethod
    def fib(n: int) -> Iterator[int]:
        """Fibonacci series up to n."""
        a, b = 0, 1
        while a < n:
            yield a
            a, b = b, a + b

result = sum(Math.fib(42))
print("The answer is {}".format(result))
// Some comments
line 1 of code
line 2 of code
line 3 of code