Comparing version 0.1.4 to 0.1.5
@@ -15,8 +15,10 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.alanView = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
AlanView.prototype.draw = function(block) { | ||
var canvas, colors, context, faces, height, lines, padded_faces, ref, ref1, saliency, scale, scene, src, width; | ||
ref = block.cover, saliency = ref.saliency, colors = ref.colors, faces = ref.faces, padded_faces = ref.padded_faces, src = ref.src, width = ref.width, height = ref.height, scene = ref.scene, lines = ref.lines; | ||
var canvas, colors, context, faces, height, lines, ref, ref1, saliency, scale, scene, src, textregions, width; | ||
ref = block.cover, saliency = ref.saliency, colors = ref.colors, faces = ref.faces, textregions = ref.textregions, src = ref.src, width = ref.width, height = ref.height, scene = ref.scene, lines = ref.lines; | ||
ref1 = this.getSizeAndScale(width, height), width = ref1.width, height = ref1.height, scale = ref1.scale; | ||
canvas = this.props.canvas; | ||
context = canvas.getContext('2d'); | ||
context.clearRect(0, 0, width, height); | ||
if (this.props.noBackground == null) { | ||
context.clearRect(0, 0, width, height); | ||
} | ||
if (saliency != null) { | ||
@@ -27,7 +29,2 @@ if (this.props.noSaliency == null) { | ||
} | ||
if (padded_faces != null) { | ||
if (this.props.noPaddedFaces == null) { | ||
this.drawPaddedFaces(context, padded_faces, scale); | ||
} | ||
} | ||
if (faces != null) { | ||
@@ -38,2 +35,7 @@ if (this.props.noFaces == null) { | ||
} | ||
if (textregions != null) { | ||
if (this.props.noTextregions == null) { | ||
this.drawTextregions(context, textregions, scale); | ||
} | ||
} | ||
if (scene != null) { | ||
@@ -90,3 +92,3 @@ if (this.props.noScene == null) { | ||
context.rect(x, y, w, h); | ||
context.strokeStyle = 'rgba(0, 255, 0, 0.5)'; | ||
context.strokeStyle = 'rgba(0, 255, 0, 1.0)'; | ||
context.stroke(); | ||
@@ -103,40 +105,8 @@ if (this.props.noSceneFading == null) { | ||
AlanView.prototype.drawSaliency = function(context, saliency, width, height, scale) { | ||
var b, bbox, bounding_rect, center, firstPoint, h, j, k, l, len, len1, len2, len3, len4, m, n, o, point, polygon, r, radius, region, regions, t, w, x, y; | ||
center = saliency.center, polygon = saliency.polygon, bounding_rect = saliency.bounding_rect, radius = saliency.radius, regions = saliency.regions, bbox = saliency.bbox; | ||
if (bbox != null) { | ||
context.beginPath(); | ||
context.rect(bbox.x * scale, bbox.y * scale, bbox.width * scale, bbox.height * scale); | ||
context.strokeStyle = 'rgba(0, 0, 255, 0.5)'; | ||
context.stroke(); | ||
} | ||
if (regions != null) { | ||
for (j = 0, len = regions.length; j < len; j++) { | ||
region = regions[j]; | ||
polygon = region.polygon; | ||
for (k = 0, len1 = polygon.length; k < len1; k++) { | ||
point = polygon[k]; | ||
x = point.x, y = point.y; | ||
context.beginPath(); | ||
context.arc(x * scale, y * scale, 1, 0, TAU, false); | ||
context.fillStyle = 'rgba(255, 255, 255, 0.75)'; | ||
context.fill(); | ||
} | ||
context.beginPath(); | ||
firstPoint = polygon[0]; | ||
context.moveTo(firstPoint.x * scale, firstPoint.y * scale); | ||
for (m = 0, len2 = polygon.length; m < len2; m++) { | ||
point = polygon[m]; | ||
x = point.x, y = point.y; | ||
context.lineTo(x * scale, y * scale); | ||
} | ||
context.lineTo(firstPoint.x * scale, firstPoint.y * scale); | ||
context.closePath(); | ||
context.fillStyle = 'rgba(255, 255, 255, 0.25)'; | ||
context.fill(); | ||
} | ||
} | ||
var b, bounding_rect, center, firstPoint, h, j, k, l, len, len1, len2, m, point, polygon, r, radius, ref, region, regions, results, t, w, x, y; | ||
regions = saliency.regions, center = saliency.center, polygon = saliency.polygon, bounding_rect = saliency.bounding_rect, radius = saliency.radius; | ||
if (polygon != null) { | ||
if (this.props.noPolygon == null) { | ||
for (n = 0, len3 = polygon.length; n < len3; n++) { | ||
point = polygon[n]; | ||
for (j = 0, len = polygon.length; j < len; j++) { | ||
point = polygon[j]; | ||
context.beginPath(); | ||
@@ -154,4 +124,4 @@ context.arc(point[0] * scale, point[1] * scale, 1, 0, TAU, false); | ||
context.moveTo(firstPoint[0] * scale, firstPoint[1] * scale); | ||
for (o = 0, len4 = polygon.length; o < len4; o++) { | ||
point = polygon[o]; | ||
for (k = 0, len1 = polygon.length; k < len1; k++) { | ||
point = polygon[k]; | ||
context.lineTo(point[0] * scale, point[1] * scale); | ||
@@ -183,13 +153,27 @@ } | ||
context.strokeStyle = 'rgba(255, 255, 255, 0.7)'; | ||
return context.stroke(); | ||
context.stroke(); | ||
} | ||
} | ||
if (regions != null) { | ||
results = []; | ||
for (m = 0, len2 = regions.length; m < len2; m++) { | ||
region = regions[m]; | ||
ref = region.bbox, x = ref.x, y = ref.y, width = ref.width, height = ref.height; | ||
x *= scale; | ||
y *= scale; | ||
width *= scale; | ||
height *= scale; | ||
context.strokeStyle = 'rgba(255, 255, 255, 0.5)'; | ||
results.push(context.strokeRect(x, y, width, height)); | ||
} | ||
return results; | ||
} | ||
}; | ||
AlanView.prototype.drawPaddedFaces = function(context, faces, scale) { | ||
var face, height, j, len, results, width, x, y; | ||
AlanView.prototype.drawFaces = function(context, faces, scale) { | ||
var area, confidence, face, height, j, len, results, width, x, y; | ||
results = []; | ||
for (j = 0, len = faces.length; j < len; j++) { | ||
face = faces[j]; | ||
x = face.x, y = face.y, width = face.width, height = face.height; | ||
x = face.x, y = face.y, width = face.width, height = face.height, confidence = face.confidence; | ||
x *= scale; | ||
@@ -199,6 +183,13 @@ y *= scale; | ||
height *= scale; | ||
context.fillStyle = 'rgba(0, 0, 150, 0.3)'; | ||
context.fillStyle = 'rgba(0, 0, 155, 0.5)'; | ||
context.fillRect(x, y, width, height); | ||
context.strokeStyle = 'rgba(0, 0, 150, 0.9)'; | ||
results.push(context.strokeRect(x, y, width, height)); | ||
context.strokeStyle = 'rgba(0, 0, 155, 0.9)'; | ||
context.strokeRect(x, y, width, height); | ||
if (this.props.noFaceConfidence == null) { | ||
context.fillStyle = 'rgba(255, 255, 255, 1.0)'; | ||
context.fillText(confidence.toFixed(2), x, y + height + 10); | ||
} | ||
area = width * height; | ||
context.fillText(width + "x" + height, x + width / 3, y + height / 2); | ||
results.push(context.fillText(area.toFixed(0), x + width / 3, y + height / 2 + 10)); | ||
} | ||
@@ -208,8 +199,8 @@ return results; | ||
AlanView.prototype.drawFaces = function(context, faces, scale) { | ||
var confidence, face, height, j, len, results, width, x, y; | ||
AlanView.prototype.drawTextregions = function(context, regions, scale) { | ||
var height, j, len, region, results, width, x, y; | ||
results = []; | ||
for (j = 0, len = faces.length; j < len; j++) { | ||
face = faces[j]; | ||
x = face.x, y = face.y, width = face.width, height = face.height, confidence = face.confidence; | ||
for (j = 0, len = regions.length; j < len; j++) { | ||
region = regions[j]; | ||
x = region.x, y = region.y, width = region.width, height = region.height; | ||
x *= scale; | ||
@@ -219,12 +210,6 @@ y *= scale; | ||
height *= scale; | ||
context.fillStyle = 'rgba(0, 0, 155, 0.5)'; | ||
context.fillStyle = 'rgba(155, 0, 0, 0.5)'; | ||
context.fillRect(x, y, width, height); | ||
context.strokeStyle = 'rgba(0, 0, 155, 0.9)'; | ||
context.strokeRect(x, y, width, height); | ||
if (this.props.noFaceConfidence == null) { | ||
context.fillStyle = 'rgba(255, 255, 255, 1.0)'; | ||
results.push(context.fillText(confidence.toFixed(2), x, y + height + 10)); | ||
} else { | ||
results.push(void 0); | ||
} | ||
context.strokeStyle = 'rgba(155, 0, 0, 0.9)'; | ||
results.push(context.strokeRect(x, y, width, height)); | ||
} | ||
@@ -231,0 +216,0 @@ return results; |
{ | ||
"name": "alan-view", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Alan's view for a given image", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
526174
387