Sha256: f906ffc19c65d29a9ac85736f780fe278bbf2144139326b3c94f8cd797ff5d97

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

/*
---
 
script: Shape.js
 
description: Draw a widget with any SVG path you want
 
license: Public domain (http://unlicense.org).

authors: Yaroslaff Fedin
 
requires: 
  - LSD.Trait
  - ART/ART.Shape
  
provides: 
  - LSD.Module.Shape
 
...
*/

LSD.Module.Shape = new Class({
  options: {
    shape: 'rectangle'
  },
  
  getShape: Macro.getter('shape', function(name) {
    return this.setShape(name);
  }),
  
  setShape: function(name) {    
    if (!name) name = this.options.shape;
    var shape = new ART.Shape[name.camelCase().capitalize()];
    shape.name = name;
    shape.widget = this;
    if (!this.shape) this.addEvents(LSD.Module.Shape.events);
    this.shape = shape;
    return shape;
  },
  
  getCanvas: Macro.getter('canvas', function() {
    var art = new ART;
    art.toElement().inject(this.toElement(), 'top');
    return art;
  })
  
});

LSD.Module.Shape.events = {
  'render': function() {
    if (this.setSize()) this.resized = true;
  },
  'update': function() {
    delete this.resized;
  }
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/lsd/Source/Module/Graphics/Shape.js
lsd_rails-0.1.5 Packages/lsd/Source/Module/Graphics/Shape.js
lsd_rails-0.1.4 Packages/lsd/Source/Module/Graphics/Shape.js
lsd_rails-0.1.3 Packages/lsd/Source/Module/Graphics/Shape.js
lsd_rails-0.1.2 Packages/lsd/Source/Module/Graphics/Shape.js
lsd_rails-0.1.1 Packages/lsd/Source/Module/Graphics/Shape.js
lsd_rails-0.1 Packages/lsd/Source/Module/Graphics/Shape.js