Blame view

app/scripts/controllers/tshirtdesign.js 2.08 KB
6f105dbd5   Truong LD   add source code i...
1
2
  define(['app'], function (app) {
  	'use strict';
422e7837d   DANG   Change color t-shirt
3
  	app.controller('TshirtdesignCtrl', function ($scope, $rootScope, $illustration) {
6f105dbd5   Truong LD   add source code i...
4
5
6
7
8
9
10
11
12
13
14
15
16
  		
  		var canvas = new fabric.Canvas('main-design-container');
  		fabric.Object.prototype.transparentCorners = false;
  
  		canvas.on('after:render', function() {
  		});
  		canvas.on({
  			'object:moving': onIllustrationChange,
  			'object:scaling': onIllustrationChange,
  			'object:rotating': onIllustrationChange,
  			'object:selected': onllustrationSelected,
  		});
  		function onIllustrationChange(options) {
d75c45c56   Truong LD   remove test showcase
17
18
19
20
21
  			// options.target.setCoords();
  			// canvas.forEachObject(function(obj) {
  			// if (obj === options.target) return;
  			// 	obj.setOpacity(options.target.intersectsWithObject(obj) ? 0.5 : 1);
  			// });
6f105dbd5   Truong LD   add source code i...
22
23
24
25
26
27
28
29
30
31
32
33
  		}
  
  		$scope.currentObject = null;
  		function onllustrationSelected(options){
  			$scope.currentObject = canvas.getActiveObject();
  			console.log(canvas.getActiveObject());
  		}
  
  		// Illustration process
  		$scope.changeIllustrationCategory = function(currentIllustration){
  			$scope.currentIllustrationCate = $illustration.getList(currentIllustration);
  			console.log($scope.currentIllustrationCate);
422e7837d   DANG   Change color t-shirt
34
  		};
6f105dbd5   Truong LD   add source code i...
35
36
37
38
  
  		$scope.insertSvg = function(item){
  			fabric.loadSVGFromURL(item.path, function(objects, options) {
  				var shape = fabric.util.groupSVGElements(objects, options);
d75c45c56   Truong LD   remove test showcase
39
  				// shape.setFill('green');
6f105dbd5   Truong LD   add source code i...
40
41
42
43
44
  				canvas.add(shape.scale(0.6));
  				shape.set({ left: 150, top: 200 }).setCoords();
  				canvas.renderAll();
  				canvas.setActiveObject(shape);
  			});
422e7837d   DANG   Change color t-shirt
45
  		};
6f105dbd5   Truong LD   add source code i...
46
47
48
49
50
  
  		// color pattern
  		$scope.changeColorPattern = function(color){
  			canvas.getActiveObject().set("fill", color);
              canvas.renderAll();
422e7837d   DANG   Change color t-shirt
51
  		};
6f105dbd5   Truong LD   add source code i...
52
53
54
55
56
57
58
59
60
61
62
  		$scope.listColorPatterns = [
  			'#000000',
  			'#ffff00',
  			'#ff6600',
  			'#ff0000',
  			'#ff6262',
  			'#ffa19c',
  			'#ff9933',
  			'#c45d01',
  			'#5d2b03',
  			'#ffffcc',
6f105dbd5   Truong LD   add source code i...
63
64
65
66
67
68
69
70
71
72
  			'#000000',
  			'#ffff00',
  			'#ff6600',
  			'#ff0000',
  			'#ff6262',
  			'#ffa19c',
  			'#ff9933',
  			'#c45d01',
  			'#5d2b03',
  			'#ffffcc',
6f105dbd5   Truong LD   add source code i...
73
74
75
76
77
78
79
80
81
82
  			'#000000',
  			'#ffff00',
  			'#ff6600',
  			'#ff0000',
  			'#ff6262',
  			'#ffa19c',
  			'#ff9933',
  			'#c45d01',
  			'#5d2b03',
  			'#ffffcc',
6f105dbd5   Truong LD   add source code i...
83
  			'#ffffcc'
422e7837d   DANG   Change color t-shirt
84
  		];
6f105dbd5   Truong LD   add source code i...
85
86
  	});
  });