Decorate Pascal's Triangle
C (gcc),  157 153 143 139  135 bytes
Saved several bytes thanks to @AlexeyBurdin
Saved  4  8 more bytes thanks to @ceilingcat
Outputs with ANSI colors.

long p,a,s,c,L;f(n,d){for(a=0;c=a++-n;puts(&quot;&quot;))for(;p=c&lt;a;printf(c&lt;0?&quot; &quot;:&quot;\e[3%dm@@&quot;,L),s=++c&lt;1?1:s*a/c-s)for(L=0;p*=d,L&lt;7&amp;s%p&lt;1;L++);}

Try it online! (no colors on TIO)
Example output for \$f(40,2)\$

Formula
At row \$r\$ and column \$c-1\$, we have:
$$P_{r,c-1}={r\choose c-1}=\frac{r!}{(c-1)!(r-c+1)!}$$
On the same row and the next column \$c\$, we have:
$$\begin{align}P_{r,c}={r\choose c}&amp;=\frac{r!}{c!(r-c)!}\\
&amp;=\frac{r-c+1}{c}\times\frac{r!}{(c-1)!(r-c+1)!}\\
&amp;=\frac{r-c+1}{c}\times P_{r,c-1}\\
&amp;=\frac{r+1}{c}P_{r,c-1}-P_{r,c-1}\end{align}$$
which is translated as s = s * a / c - s in the C code (with \$a=r+1\$).
Commented
long p, a, s, c, L;               // declare a few 64-bit integers
f(n, d) {                         // n = number of rows, d = colorization parameter
  for(a = 0; a++ &lt; n; puts(&quot;&quot;))   // for a = 1 to n, with a linefeed added after each
    for(                          // iteration:
      c = a + ~n;                 //   for c = a - n - 1 to a - 1:
      p = c &lt; a;                  //
      printf(                     //     update the output after each iteration:
        c &lt; 0 ?                   //       if c is negative:
          &quot; &quot;                     //         just append a space
        :                         //       else:
          &quot;\e[3%dm@@&quot;,            //         append the ANSI color code, followed by '@@'
        L                         //       set the 2nd digit of the color code
      ),                          //
      s = ++c &lt; 1 ? 1             //     increment c; set s to 1 while c is less than 1
                  : s * a / c - s //     then, update s to s * a / c - s
    )                             //
      for(                        //       compute the color L:
        L = 0;                    //         start with L = 0
        p *= d,                   //         multiply p by d
        L &lt; 7 &amp; s % p &lt; 1;        //         stop if L = 7 or p does not divide s
        L++                       //         increment L
      );                          //
}                                 //