Checkerbord SeExpr Pattern

A couple of months back, I needed a checkerboard pattern and probably used the most inefficient and cumbersome method to create it. Never again!

EDIT: I just noticed that when you have a non-quadratic image, things don’t quite work as I intended. I’m working on a fix and a couple of other patterns to release all together.

$color1 = [0,0,0];
$color2 = [1,1,1];
$scale_horizontal = 10	; # 1,500
$scale_vertical = 10; # 1,500
$offset_horizontal = 5; # 1,500
$offset_vertical = 5; # 1,500
$rotation = 0; # 0,360

$rotated = rotate([$u, $v, 0], [0, 0, 1], rad($rotation));
$u = $rotated[0];
$v = $rotated[1];

$x = round(($u + $offset_horizontal / 100) / $scale_horizontal * 100);
$y = round(($v + $offset_vertical / 100) / $scale_vertical * 100);

$cond1 = ($x % 2 == 0);
$cond2 = ($y % 2 == 0);

if (($cond1 || $cond2) && !($cond1 && $cond2)) {
  # $cond1 XOR $cond2
  $color = $color1;
} else {
  $color = $color2;
}

$color
4 Likes

It looks quite compact actually. Thanks to your efforts we can all now have a very adjustable checkerboard.
Thank you @Rebecca :slight_smile:

1 Like

I just had to do something quick with it :smiley:

Maybe I’ll do a pack of similar patterns…

2 Likes