MCPcopy
hub / github.com/methodofaction/Method-Draw / getPaint

Function getPaint

src/js/method-draw.js:119–146  ·  view source on GitHub ↗
(color, opac, type)

Source from the content-addressed store, hash-verified

117 }
118
119 var getPaint = function(color, opac, type) {
120 // update the editor's fill paint
121 var opts = null;
122 if (color.indexOf("url(#") === 0) {
123 var refElem = svgCanvas.getRefElem(color);
124 if(refElem) {
125 refElem = refElem.cloneNode(true);
126 } else {
127 refElem = $("#" + type + "_color defs *")[0];
128 }
129
130 opts = { alpha: opac };
131 opts[refElem.tagName] = refElem;
132 }
133 else if (color.indexOf("#") === 0) {
134 opts = {
135 alpha: opac,
136 solidColor: color.substr(1)
137 };
138 }
139 else {
140 opts = {
141 alpha: opac,
142 solidColor: 'none'
143 };
144 }
145 return new $.jGraduate.Paint(opts);
146 };
147
148 // set the canvas properties at init
149 var res = svgCanvas.getResolution();

Callers 2

clickSwitchFunction · 0.70
PaintBoxFunction · 0.70

Calls 1

$Function · 0.85

Tested by

no test coverage detected