|
242 | 242 | return this;
|
243 | 243 | };
|
244 | 244 |
|
245 |
| - /* |
246 |
| - const gradient = paper.conic_gradient({ |
247 |
| - degree: 0, |
248 |
| - x: 50, |
249 |
| - y: 50, |
250 |
| - stops: '0,red 0.25,orange 0.5,yellow 0.75,green 1,blue' |
251 |
| - }); |
252 |
| - paper.rect({ x: 0, y: 0, width: 100, height: 100, fill: gradient }); |
253 |
| - */ |
254 | 245 | Palette.prototype.conic_gradient = function (settings) {
|
255 | 246 | const ctx = this.context;
|
256 | 247 | const gradient = ctx.createConicGradient(settings.degree * Math.PI / 180, settings.x, settings.y);
|
|
261 | 252 | return gradient;
|
262 | 253 | };
|
263 | 254 |
|
264 |
| - /* |
265 |
| - const gradient = paper.linear_gradient({ |
266 |
| - x1: 0, |
267 |
| - y1: 0, |
268 |
| - x2: 100, |
269 |
| - y2: 0, |
270 |
| - stops: '0,red 0.25,orange 0.5,yellow 0.75,green 1,blue' |
271 |
| - }); |
272 |
| - paper.rect({ x: 0, y: 0, width: 100, height: 100, fill: gradient }); |
273 |
| - */ |
274 | 255 | Palette.prototype.linear_gradient = function (settings) {
|
275 | 256 | const ctx = this.context;
|
276 | 257 | const gradient = ctx.createLinearGradient(settings.x1, settings.y1, settings.x2, settings.y2);
|
|
281 | 262 | return gradient;
|
282 | 263 | };
|
283 | 264 |
|
284 |
| - /* |
285 |
| - const gradient = paper.radial_gradient({ |
286 |
| - x1: 50, |
287 |
| - y1: 50, |
288 |
| - r1: 0, |
289 |
| - x2: 50, |
290 |
| - y2: 50, |
291 |
| - r2: 50, |
292 |
| - stops: '0,red 0.25,orange 0.5,yellow 0.75,green 1,blue' |
293 |
| - }); |
294 |
| - paper.rect({ x: 0, y: 0, width: 100, height: 100, fill: gradient }); |
295 |
| - */ |
296 | 265 | Palette.prototype.radial_gradient = function (settings) {
|
297 | 266 | const ctx = this.context;
|
298 | 267 | const gradient = ctx.createRadialGradient(settings.x1, settings.y1, settings.r1, settings.x2, settings.y2, settings.r2);
|
|
303 | 272 | return gradient;
|
304 | 273 | };
|
305 | 274 |
|
306 |
| - // export the canvas as a DataURL image, returning a string with the DataURL image. Both arguments are optional. |
307 |
| - // Supported type: 'image/png', 'image/jpeg', 'image/webp' |
308 |
| - // quality is applied only if type is jpeg or webp, and must be between 0.0 and 1.0 |
309 | 275 | Palette.prototype.toDataURL = function (settings) {
|
310 | 276 | settings = settings || {};
|
311 | 277 | const type = settings.type || 'image/png';
|
312 | 278 | const quality = settings.quality || 1.0;
|
313 | 279 | return this.canvas.toDataURL(type, quality);
|
314 | 280 | };
|
315 | 281 |
|
316 |
| - // export the canvas as a blob image. You must pass a callback function, because this method is a void. |
317 |
| - // Supported type: 'image/png', 'image/jpeg', 'image/webp' |
318 |
| - // quality is applied only if type is jpeg or webp, and must be between 0.0 and 1.0 |
319 | 282 | Palette.prototype.toBlob = function (settings, callback) {
|
320 | 283 | settings = settings || {};
|
321 | 284 | const type = settings.type || 'image/png';
|
|
0 commit comments