ColorMaterial.js 681 B

1234567891011121314151617181920212223242526272829303132
  1. var ColorMaterial = Class.extend
  2. ({
  3. color: null,
  4. opacity: null,
  5. colorString: null,
  6. // Uses hex instead of rgb is for keeping the syntax similar to .as version
  7. init: function( color, opacity )
  8. {
  9. this.setColor( color ? color : 0xff0000 );
  10. this.setOpacity( opacity ? opacity : 1 );
  11. },
  12. setColor: function( color )
  13. {
  14. this.color = color;
  15. this.updateColorString();
  16. },
  17. setOpacity: function( opacity )
  18. {
  19. this.opacity = opacity;
  20. this.updateColorString();
  21. },
  22. updateColorString: function()
  23. {
  24. this.colorString = 'rgba(' + (this.color >> 16 & 0xff) + ',' + (this.color >> 8 & 0xff) + ',' + (this.color & 0xff) + ',' + this.opacity + ')';
  25. }
  26. });
粤ICP备19079148号