Sha256: f89d6782f999888d60647ee6ef6526b3eb398ecf759d69aaa1c61596bff7ea92

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

/*
---
 
script: Stroke.js
 
description: Fills shape with color and strokes with a stroke
 
license: Public domain (http://unlicense.org).

authors: Yaroslaff Fedin
 
requires:
  - LSD.Layer
  - LSD.Layer.Color
 
provides: 
  - LSD.Layer.Stroke
 
...
*/

LSD.Layer.Stroke = {
  
  properties: {
    stroke:    ['width', ['cap', 'join', 'dash'], 'color'], 
    color:     ['gradient', 'color'],
    width:     ['length'],
    cap:       ['butt', 'round', 'square'],
    join:      ['butt', 'round', 'square'],
    dash:      ['tokens']
  },
  
  paint: function(color, width, cap, join, dash) {
    if (!width) width = 0;
    var gradient = color && (color['gradient'] || color['linear-gradient']);
    var result = {    
      dash: dash,
      size: {
        width: width,
        height: width
      },
      move: {
        x: width / 2,
        y: width / 2
      },
      inside: {
        left: width,
        top: width,
        right: width,
        bottom: width
      },
      stroke: [!gradient && color || null, width, cap, join]
    };
    if (this.radius != null) {
      var radius = result.radius = []
          for (var i = 0; i < 4; i++) radius[i] = (this.radius[i] > 0) ? width / 1.5 : 0;
    }
    if (gradient) result.strokeLinear = [gradient]
    return result;
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/lsd/Source/Layer/Stroke.js
lsd_rails-0.1.5 Packages/lsd/Source/Layer/Stroke.js
lsd_rails-0.1.4 Packages/lsd/Source/Layer/Stroke.js
lsd_rails-0.1.3 Packages/lsd/Source/Layer/Stroke.js
lsd_rails-0.1.2 Packages/lsd/Source/Layer/Stroke.js
lsd_rails-0.1.1 Packages/lsd/Source/Layer/Stroke.js
lsd_rails-0.1 Packages/lsd/Source/Layer/Stroke.js