Thursday, January 19, 2017

p5 drawing continued


Code:

var nums = [[56, 45],[185, 175],[185, 45],[255,145]];
var radius = 55;
var tw = 10;
var titles = ["Hello","World","!","hola"];

function setup() {
  createCanvas(400, 400);
}

function draw() {

  for(var i = 0; i < nums.length - 1; i++) {
    line(nums[i][0], nums[i][1], nums[i+1][0], nums[i+1][1]);
  }


 for(var i = 0; i < nums.length; i++) {
   ellipse(nums[i][0], nums[i][1],radius, radius);
   text(titles[i], nums[i][0] - titles[i].length - tw, nums[i][1] + 0.5*tw, tw);
 }


}

Try: https://danmartensen.svbtle.com/javascripts-map-reduce-and-filter ,
http://jcla1.com/blog/javascript-mapreduce/

For mapping: <?s> <?p> <?o> , <?s1> <?p1> <?o1>

<?s>     , <?o>       ;  <?s1>    ,  <?o1>
 [56,45] , [185,175] ; [185, 45] , [255,145]


 [56,45] , [185,175] ; [185,175] , [255,145]

If this does not work, try mapping functions in the php scripts : https://github.com/bshambaugh

No comments:

Post a Comment