Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when selecting an artboard #2

Closed
lanceplaine opened this issue Sep 22, 2017 · 2 comments
Closed

Bug when selecting an artboard #2

lanceplaine opened this issue Sep 22, 2017 · 2 comments
Labels

Comments

@lanceplaine
Copy link

Steps to reproduce the bug

  1. Create an empty artboard
  2. Select the artboard (The bug doesn't happen otherwise)
  3. Run the code
  4. Bug: One part of the pie chart is too big (the pink)

screen shot 2017-09-22 at 4 34 50 pm

Code used

Pie chart

//The percentages you need to visualize
var percentages = [30,60,10];

function setup() {
  //Creates an 400x400 artboard
  createCanvas(400, 400);
  //Remove Borders
  noStroke();
}

function draw() {
  //Custom function defined underneath
  pieChart(300, percentages);
}

//We define a function called pieChart that asks
//for diameter and percentage
function pieChart(diameter, data) {

  //We keep trak of the last angle drawn. The initial value
  //defines where the pie chart stars. -HALF_PI it 12 on a clock.
  var lastAngle = -HALF_PI;

  //We run a loop that runs as many times as there
  //are elements in the percentages array
  for (var i = 0; i < data.length; i++) {

    //Every time we run the loop we define a random rgb color
    //for each section of the pie
    fill(random(255),random(255),random(255));

    //We draw an arc that is centered at the center of the artboard,
    //has the first parameter of pieChart as a diameter
    //and takes one of the values from percentage, divides it by 100
    //multiplies it by 360 (so we get the percentage in degrees)
    //and then converts it into radians for angle
    //The variabile lastAngle is used to make sure we have arcs that
    //start where the last arc ended.
    arc(width/2, height/2, diameter, diameter, lastAngle,  lastAngle+radians((data[i]/100)*360));
    lastAngle += radians((data[i]/100)*360);
  }
}
@jacopocolo
Copy link
Owner

What a fantastic find, I've been wondering for weeks WHY one masks would not work and never realized that it was connected to the current selection. Thanks, this should be an easy fix!

@jacopocolo jacopocolo added the bug label Sep 23, 2017
jacopocolo pushed a commit that referenced this issue Sep 23, 2017
@lanceplaine
Copy link
Author

No problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants