Permalink
Browse files

Added support for cross-browser image smoothing

- Updated build script with some minor changes
- Updated the project manifest
  • Loading branch information...
1 parent d2f0335 commit e65a15fe9877128e2dc1da8b5cea5264c5f8712e @caleb531 committed Jan 18, 2013
Showing with 101 additions and 77 deletions.
  1. +2 −1 .gitignore
  2. +20 −20 license.txt → LICENSE.txt
  3. +19 −8 build/build.py
  4. +2 −2 jcanvas.jquery.json
  5. +12 −1 jcanvas.js
  6. +46 −45 jcanvas.min.js
View
@@ -1,3 +1,4 @@
.DS_Store
__pycache__
-.pyc
+.pyc
+license.txt
@@ -1,21 +1,21 @@
-Copyright 2013 Caleb Evans
-http://calebevans.me/projects/jcanvas/
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+Copyright 2013 Caleb Evans
+http://calebevans.me/projects/jcanvas/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# This script supports Python 2 and 3
import datetime, sys, os, re
@@ -6,23 +7,23 @@
def compress(source):
# Create path to minified file from source path
minified = re.sub('(\.\w+)$', '.min\\1', source)
-
+
# Compress source file using Google Closure Compiler
os.system('java -jar closure-compiler.jar --js ' + source + ' --js_output_file ' + minified + ' --compilation_level SIMPLE_OPTIMIZATIONS')
# Update version in given source file
-def update_version(source, version):
+def replace_in_file(path, expression, version):
# Open source file for reading and writing
- f = open(source, 'r+')
+ f = open(path, 'r')
# Read contents from source file
contents = f.read()
f.close()
# Update source version
- contents = re.sub('\d{2}\.\d{2}\.\d{2}', version, contents, 1)
+ contents = re.sub(expression, version, contents, 1)
# Write updated source to source file
- f = open(source, 'w+')
+ f = open(path, 'w+')
f.write(contents)
f.close()
@@ -34,20 +35,30 @@ def main():
# Get current date
now = datetime.datetime.now()
+ # Get current year for license
+ year = now.strftime('%Y')
# Get jCanvas version from current date
version = now.strftime('%y.%m.%d')
source = '../jcanvas.js'
manifest = '../jcanvas.jquery.json'
readme = '../README.md'
+ license = '../LICENSE.txt'
# Update version in source and readme files
- update_version(source, version)
- update_version(manifest, version)
+ version_re = '\d{2}\.\d{2}\.\d{2}'
+ replace_in_file(source, version_re, version)
+ replace_in_file(manifest, version_re, version)
+
+ # Update year in copyright license
+ year_re = '\d{4}'
+ replace_in_file(source, year_re, year)
+ replace_in_file(readme, year_re, year)
+ replace_in_file(license, year_re, year)
# Compress jCanvas source
compress(source)
-
+
# Inform user when build process has finished
print('Done.')
View
@@ -1,7 +1,7 @@
{
"name": "jcanvas",
"title": "jCanvas",
- "version": "13.01.17",
+ "version": "13.01.18",
"author": {
"name": "Caleb Evans",
"email": "calebevans.me@gmail.com",
@@ -10,7 +10,7 @@
"licenses": [
{
"type": "MIT",
- "url": "https://github.com/caleb531/jcanvas/blob/master/license.txt"
+ "url": "https://github.com/caleb531/jcanvas/blob/master/LICENSE.txt"
}
],
"dependencies": {
View
@@ -1,5 +1,5 @@
/**
- * @license jCanvas v13.01.17
+ * @license jCanvas v13.01.18
* Copyright 2013 Caleb Evans
* Released under the MIT license
*/
@@ -70,6 +70,7 @@ defaults = {
fn: NULL,
graph: 'y',
height: NULL,
+ imageSmoothing: TRUE,
inDegrees: TRUE,
lineHeight: 1,
load: NULL,
@@ -127,6 +128,7 @@ function getContext(canvas) {
// Set canvas context properties
function setGlobalProps(ctx, params) {
+ var imageSmoothingEnabled, imageSmoothing;
// Fill/stroke styles
ctx.fillStyle = params.fillStyle;
ctx.strokeStyle = params.strokeStyle;
@@ -148,6 +150,11 @@ function setGlobalProps(ctx, params) {
// Opacity and composite operation
ctx.globalAlpha = params.opacity;
ctx.globalCompositeOperation = params.compositing;
+ // Support cross-browser toggling of image smoothing
+ if (params.imageSmoothing) {
+ imageSmoothingEnabled = 'imageSmoothingEnabled';
+ ctx['webkit' + imageSmoothingEnabled] = ctx['webkit' + imageSmoothingEnabled] = params.imageSmoothing;
+ }
}
// Close current canvas path
@@ -2515,6 +2522,10 @@ $.fn.setPixels = function self(args) {
// Get canvas image as data URL
$.fn.getCanvasImage = function(type, quality) {
var canvas = this[0];
+ // JPEG quality defaults to 1
+ if (quality === UNDEFINED) {
+ quality = 1;
+ }
return (canvas && canvas.toDataURL ? canvas.toDataURL('image/' + type, quality) : NULL);
};
Oops, something went wrong.

0 comments on commit e65a15f

Please sign in to comment.