summaryrefslogtreecommitdiffstats
path: root/playgrounds/colors/main.js
blob: fda3ce2e2f7067fa93c98218198a707b10054813 (plain)
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
let canvas = SVG('#canvas').group()
  .translate( -150, 230 )

// Make a bunch of rectangles
function rectangles ( method='Vibrant') {

  // Make a group
  let group = canvas.group()
  group.text(method).attr('font-size', 50).move( -230, 20 )

  // Add the squares
  for ( let i = 0; i < 20; i++ ) {
    let color = SVG.Color.random( method.toLowerCase() ).hex()
    let rect = group.rect(100, 100)
      .x( 20 + 100 * i )
      .fill( color )
  }
  return group
}

rectangles( 'Vibrant' ).translate( 0, 100 )
rectangles( 'Sine' ).translate( 0, 220 )
rectangles( 'Pastel' ).translate( 0, 340 )
rectangles( 'Dark' ).translate( 0, 460 )
rectangles( 'RGB' ).translate( 0, 580 )
rectangles( 'LAB' ).translate( 0, 700 )
rectangles( 'Grey' ).translate( 0, 820 )