foam-framework
Version:
MVC metaprogramming framework
46 lines (42 loc) • 1.08 kB
JavaScript
/**
* @license
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
CLASS({
package: 'foam.ui',
name: 'Color',
properties: [
{
model_: 'IntProperty',
name: 'red',
preSet: function(_, v) { return Math.max(0, Math.min(255, v)); },
},
{
model_: 'IntProperty',
name: 'green',
preSet: function(_, v) { return Math.max(0, Math.min(255, v)); },
},
{
model_: 'IntProperty',
name: 'blue',
preSet: function(_, v) { return Math.max(0, Math.min(255, v)); },
},
{
model_: 'FloatProperty',
name: 'alpha',
preSet: function(_, v) { return Math.max(0.0, Math.min(1.0, v)); },
},
],
methods: [
function toString() {
return 'rgba(' + this.red + ',' + this.green + ',' + this.blue + ',' +
this.alpha + ')';
},
],
});