Aaron
Aaron

Reputation: 55

Draw segment 1/4th below the top of a canvas using paper.js

For a portfolio site I am creating, I want to draw a line in Paper.js one-quarter from the top of the target canvas, to make a header of sorts. I tried this code using the view functionality but don't see anything:

var ycoord = view.size.height * 0.25;
var xcoord = view.size.width;
console.log(pos);
var point3 = new Point(xcoord, ycoord);
var point4 = new Point(xcoord, 0);
var pathh = new Path({
  segments: [point3, point4],
  strokeColor: 'black',
  strokeWidth: '10',
});

Any help would be greatly appreciated!

Upvotes: 0

Views: 139

Answers (1)

sasensi
sasensi

Reputation: 4650

You confused x and y and you are actually drawing a vertical line at the right of the screen.
Here is the corrected code:

var ycoord = view.size.height * 0.25;
var xcoord = view.size.width;
var point3 = new Point(0, ycoord);
var point4 = new Point(xcoord, ycoord);
var pathh = new Path({
    segments: [point3, point4],
    strokeColor: 'black',
    strokeWidth: '10',
});

Upvotes: 2

Related Questions