summaryrefslogtreecommitdiffstats
path: root/src/line.js
diff options
context:
space:
mode:
authorSaivan <savian@me.com>2018-02-27 00:48:11 +1100
committerSaivan <savian@me.com>2018-02-27 00:48:11 +1100
commitbec7881979149425a9c1b894f4741413b28c8141 (patch)
tree3a496f834520925686af3a8059766b61b65be390 /src/line.js
parentec0a8aee0e21a93b22c255dae6768a9ff7b09e73 (diff)
downloadsvg.js-bec7881979149425a9c1b894f4741413b28c8141.tar.gz
svg.js-bec7881979149425a9c1b894f4741413b28c8141.zip
The first half of the library complies with Standard linting
This commit reformats the code so that it complies with the standard linting style. Its currently a work in progress, but it is meant to pave the way for linting in the build process
Diffstat (limited to 'src/line.js')
-rw-r--r--src/line.js40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/line.js b/src/line.js
index 9e8692f..67fa96b 100644
--- a/src/line.js
+++ b/src/line.js
@@ -1,50 +1,50 @@
SVG.Line = SVG.invent({
// Initialize node
- create: 'line'
+ create: 'line',
// Inherit from
-, inherit: SVG.Shape
+ inherit: SVG.Shape,
// Add class methods
-, extend: {
+ extend: {
// Get array
- array: function() {
+ array: function () {
return new SVG.PointArray([
- [ this.attr('x1'), this.attr('y1') ]
- , [ this.attr('x2'), this.attr('y2') ]
+ [ this.attr('x1'), this.attr('y1') ],
+ [ this.attr('x2'), this.attr('y2') ]
])
- }
+ },
// Overwrite native plot() method
- , plot: function(x1, y1, x2, y2) {
- if (x1 == null)
+ plot: function (x1, y1, x2, y2) {
+ if (x1 == null) {
return this.array()
- else if (typeof y1 !== 'undefined')
+ } else if (typeof y1 !== 'undefined') {
x1 = { x1: x1, y1: y1, x2: x2, y2: y2 }
- else
+ } else {
x1 = new SVG.PointArray(x1).toLine()
+ }
return this.attr(x1)
- }
+ },
// Move by left top corner
- , move: function(x, y) {
+ move: function (x, y) {
return this.attr(this.array().move(x, y).toLine())
- }
+ },
// Set element size to given width and height
- , size: function(width, height) {
+ size: function (width, height) {
var p = proportionalSize(this, width, height)
-
return this.attr(this.array().size(p.width, p.height).toLine())
}
- }
+ },
// Add parent method
-, construct: {
+ construct: {
// Create a line element
- line: function(x1, y1, x2, y2) {
+ line: function (x1, y1, x2, y2) {
// make sure plot is called as a setter
// x1 is not necessarily a number, it can also be an array, a string and a SVG.PointArray
return SVG.Line.prototype.plot.apply(
- this.put(new SVG.Line)
+ this.put(new SVG.Line())
, x1 != null ? [x1, y1, x2, y2] : [0, 0, 0, 0]
)
}