Skip to content

Commit b6a3a89

Browse files
committed
Imported changes from internal graphics repository
1 parent ea38d3a commit b6a3a89

27 files changed

+1596
-418
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
.DS_Store
33
*.pyc
44
out
5-
deps.js
6-
deps
75
*.swp
86
contrib/compiler/

build

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import time
1414
#=======================================================================================================================
1515
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
1616
CONTRIB_PATH = os.path.join(PROJECT_PATH, 'contrib')
17-
COMPILER_PATH = os.path.join(CONTRIB_PATH, 'compiler', 'compiler.jar')
17+
COMPILER_VERSION = '20160911'
18+
COMPILER_PATH = os.path.join(CONTRIB_PATH, 'compiler', 'closure-compiler-v%s.jar' % COMPILER_VERSION)
1819
SRC_PATH = os.path.join(PROJECT_PATH, 'src')
1920
OUT_PATH = os.path.join(PROJECT_PATH, 'out')
2021
CLOSURE_LIBRARY_PATH = os.path.join(CONTRIB_PATH, 'closure-library')
@@ -28,6 +29,7 @@ PYTHON = 'python'
2829
if not (platform.system() == 'Windows'):
2930
PYTHON = 'python2.7'
3031

32+
3133
#=======================================================================================================================
3234
# Synchronize contributions.
3335
#=======================================================================================================================
@@ -44,16 +46,16 @@ def __has_closure_linter_wrapper():
4446

4547

4648
def __has_closure_linter():
47-
hasLint = True
49+
has_lint = True
4850
try:
4951
subprocess.Popen(['gjslint'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
5052
except StandardError:
51-
hasLint = False
53+
has_lint = False
5254

53-
return hasLint
55+
return has_lint
5456

5557

56-
def __ensureDirExists(path):
58+
def __ensure_dir_exists(path):
5759
if not os.path.exists(path):
5860
os.mkdir(path)
5961

@@ -67,35 +69,35 @@ def __need_sync_contrib():
6769

6870
def __sync_contrib():
6971
t = time.time()
70-
__ensureDirExists(CONTRIB_PATH)
72+
__ensure_dir_exists(CONTRIB_PATH)
7173

7274
subprocess.call(['git', 'submodule', 'init'])
7375
subprocess.call(['git', 'submodule', 'update'])
7476

7577
#Download closure compiler
7678
if not os.path.exists(COMPILER_PATH):
77-
print 'Downloading Google Closure Compiler v.20151216'
79+
print 'Downloading Google Closure Compiler v.' + COMPILER_VERSION
7880
try:
7981
__download_and_unzip_from_http(
80-
'http://dl.google.com/closure-compiler/compiler-20151216.zip',
82+
'http://dl.google.com/closure-compiler/compiler-%s.zip' % COMPILER_VERSION,
8183
'compiler'
8284
)
8385
except StandardError as e:
8486
print e
8587
print 'Failed'
86-
return False;
88+
return False
8789

8890
#Install closure linter
8991
if not __has_closure_linter():
9092
if not __install_closure_linter():
91-
return False;
93+
return False
9294

9395
print 'Environment ready. Time spent: {:.3f}s\n'.format(time.time() - t)
9496
return True
9597

9698

97-
def __download_and_unzip_from_http(from_url, dri_name):
98-
z_obj_path = os.path.join(CONTRIB_PATH, dri_name + '.zip')
99+
def __download_and_unzip_from_http(from_url, dir_name):
100+
z_obj_path = os.path.join(CONTRIB_PATH, dir_name + '.zip')
99101

100102
# download zip archive from url
101103
if not os.path.exists(z_obj_path):
@@ -105,8 +107,8 @@ def __download_and_unzip_from_http(from_url, dri_name):
105107
)
106108

107109
# extract zip archive
108-
target_path = os.path.join(CONTRIB_PATH, dri_name)
109-
__ensureDirExists(target_path)
110+
target_path = os.path.join(CONTRIB_PATH, dir_name)
111+
__ensure_dir_exists(target_path)
110112
z_obj = zipfile.ZipFile(z_obj_path)
111113
z_obj.extractall(path=target_path)
112114
z_obj.close()
@@ -151,30 +153,26 @@ def __getNotOptimizedCompilerArgs():
151153

152154
def __getOptimizedCompilerArgs():
153155
compilerArgs = [
154-
'--compilation_level ADVANCED_OPTIMIZATIONS',
156+
'--compilation_level ADVANCED',
157+
'--env BROWSER',
155158
'--warning_level VERBOSE',
156159
'--jscomp_warning accessControls',
157160
'--jscomp_warning ambiguousFunctionDecl',
158-
'--jscomp_warning checkDebuggerStatement',
159161
'--jscomp_warning checkEventfulObjectDisposal',
160162
'--jscomp_warning checkRegExp',
161163
'--jscomp_warning checkTypes',
162164
'--jscomp_warning checkVars',
163-
'--jscomp_warning closureDepMethodUsageChecks',
164165
'--jscomp_warning conformanceViolations',
165166
'--jscomp_warning const',
166167
'--jscomp_warning constantProperty',
167168
'--jscomp_warning deprecated',
168169
'--jscomp_warning deprecatedAnnotations',
169-
'--jscomp_warning duplicate',
170170
'--jscomp_warning duplicateMessage',
171171
'--jscomp_warning es3',
172172
'--jscomp_warning es5Strict',
173173
'--jscomp_warning externsValidation',
174-
'--jscomp_warning extraRequire',
175174
'--jscomp_warning fileoverviewTags',
176175
'--jscomp_warning globalThis',
177-
'--jscomp_warning inferredConstCheck',
178176
'--jscomp_warning internetExplorerChecks',
179177
'--jscomp_warning invalidCasts',
180178
'--jscomp_warning misplacedTypeAnnotation',
@@ -183,22 +181,24 @@ def __getOptimizedCompilerArgs():
183181
'--jscomp_warning missingProvide',
184182
'--jscomp_warning missingRequire',
185183
'--jscomp_warning missingReturn',
184+
'--jscomp_warning msgDescriptions',
186185
'--jscomp_warning newCheckTypes',
187-
#'--jscomp_warning msgDescriptionsNewCheckTypes',
188186
'--jscomp_warning nonStandardJsDocs',
189-
#'--jscomp_warning reportUnknownTypes',
190187
'--jscomp_warning suspiciousCode',
191188
'--jscomp_warning strictModuleDepCheck',
192-
'--jscomp_warning tweakValidation',
193189
'--jscomp_warning typeInvalidation',
194190
'--jscomp_warning undefinedNames',
195191
'--jscomp_warning undefinedVars',
196192
'--jscomp_warning unknownDefines',
197-
#+'--jscomp_warning unnecessaryCasts',
193+
# '--jscomp_warning unusedLocalVariables',
194+
# '--jscomp_warning unusedPrivateMembers',
198195
'--jscomp_warning uselessCode',
199-
#+'--jscomp_warning useOfGoogBase',
200-
'--jscomp_warning violatedModuleDep',
196+
# '--jscomp_warning useOfGoogBase',
197+
'--jscomp_warning underscore',
201198
'--jscomp_warning visibility',
199+
# '--use_types_for_optimization',
200+
'--rewrite_polyfills',
201+
'--process_closure_primitives',
202202
]
203203
return compilerArgs
204204

@@ -208,19 +208,21 @@ def __getDefaultCompilerArgs(outputFile):
208208
'java -jar',
209209
COMPILER_PATH,
210210
'--charset UTF-8',
211-
'--only_closure_dependencies',
211+
'--dependency_mode STRICT',
212212
'--externs ' + EXTERNS_PATH,
213213
'--js="%s"' % os.path.join(SRC_PATH, '**.js'),
214214
'--js="%s"' % os.path.join(CLOSURE_LIBRARY_PATH, '**.js'),
215-
'--closure_entry_point acgraph',
216-
'--js_output_file ' + outputFile
215+
'--entry_point acgraph',
216+
'--js_output_file ' + outputFile,
217+
'--assume_function_wrapper',
218+
'--output_wrapper "(function(){%output%}).apply(this);"'
217219
]
218220
return result
219221

220222

221223
@sync_required
222224
def __compileBinary():
223-
__ensureDirExists(OUT_PATH)
225+
__ensure_dir_exists(OUT_PATH)
224226

225227
t = time.time()
226228
outputFileName = os.path.join(OUT_PATH, 'graphics.min.js')
@@ -236,7 +238,7 @@ def __compileBinary():
236238

237239
@sync_required
238240
def __compilePlain():
239-
__ensureDirExists(OUT_PATH)
241+
__ensure_dir_exists(OUT_PATH)
240242

241243
t = time.time()
242244
outputFileName = os.path.join(OUT_PATH, 'graphics.js')

contrib/closure-library

Submodule closure-library updated 1405 files

json-schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@
206206
},
207207
"required": ["type", "cx", "cy", "radius"]
208208
},
209+
"unmanageableLayer": {
210+
"type": "object",
211+
"properties": {
212+
"content": { "type": "string" },
213+
"type": { "enum": ["unmanageablelayer"] }
214+
},
215+
"required": ["type"]
216+
},
209217
"layer": {
210218
"type": "object",
211219
"properties": {

src/acgraph.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ goog.require('acgraph.vector.PatternFill');
1717
goog.require('acgraph.vector.Rect');
1818
goog.require('acgraph.vector.Renderer');
1919
goog.require('acgraph.vector.Text');
20+
goog.require('acgraph.vector.UnmanagedLayer');
2021
goog.require('acgraph.vector.primitives');
2122
goog.require('acgraph.vector.svg.Renderer');
2223
goog.require('acgraph.vector.svg.Stage');
@@ -435,6 +436,16 @@ acgraph.clip = function(opt_leftOrShape, opt_top, opt_width, opt_height) {
435436
};
436437

437438

439+
/**
440+
* Creates an instance ot the {@link acgraph.vector.UnmanagedLayer} class.
441+
* @param {string|Element=} opt_content Layer content.
442+
* @return {acgraph.vector.UnmanagedLayer} The instance of the {@link acgraph.vector.UnmanagedLayer} class.
443+
*/
444+
acgraph.unmanagedLayer = function(opt_content) {
445+
return new acgraph.vector.UnmanagedLayer(opt_content);
446+
};
447+
448+
438449
//----------------------------------------------------------------------------------------------------------------------
439450
//
440451
// Reference to url(). For <base> bug.

src/deps.js

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/math/math.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ acgraph.math.round = function(num, opt_digitsCount) {
284284
*/
285285
acgraph.math.angleBetweenVectors = function(ux, uy, vx, vy) {
286286
var sign = ux * vy - uy * vx; // sign determining
287-
var result = goog.math.toDegrees(Math.acos(
288-
(ux * vx + uy * vy) / // vector multiplication
289-
(Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy)) // multiplication of vector lengths
290-
));
287+
var cos = (ux * vx + uy * vy) / // vector multiplication
288+
(Math.sqrt(ux * ux + uy * uy) * Math.sqrt(vx * vx + vy * vy)); // multiplication of vector lengths
289+
cos = goog.math.clamp(cos, -1, 1);
290+
var result = goog.math.toDegrees(Math.acos(cos));
291291
return sign > 0 ? result : -result;
292292
};
293293

src/utils/HTMLParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ acgraph.utils.HTMLParser.prototype.textElement = null;
393393
* @private
394394
*/
395395
acgraph.utils.HTMLParser.prototype.init_ = function() {
396-
/** @type {Array.<acgraph.vector.TextSegmentStyle>} */
396+
/** @type {Array.<?acgraph.vector.TextSegmentStyle>} */
397397
this.styleStack = [];
398398

399399
/** @type {Array.<string>} */

0 commit comments

Comments
 (0)