check if smooth is on
in
Share your Work
•
2 years ago
I'm working on a function and for that i need to know the strokeWeight that is set (cause i don't want to pass the strokeWeight everytime the function get's used).
Since there is no way to return the current strokeWeight i thought why not try it myself.
To start practise on such thing i started with a function to check if smooth is on or not.
One of the bad things about it is that after the function is used fill is set to 255 and stroke to 0.
I thought i post since someone meight ever need to find out if smooth is on or not.
(and i understande it would be better to change processing core but i don't want to go into that).
Since there is no way to return the current strokeWeight i thought why not try it myself.
To start practise on such thing i started with a function to check if smooth is on or not.
One of the bad things about it is that after the function is used fill is set to 255 and stroke to 0.
I thought i post since someone meight ever need to find out if smooth is on or not.
(and i understande it would be better to change processing core but i don't want to go into that).
- void setup() {
size(100, 100);
smooth();
}
void draw() {
background(255);
for(int y = 0; y < 2; y++) {
for(int x = 0; x < 2; x++) {
stroke(random(255));
point(x, y);
}
}
println(getSmoothStatus());
}
boolean getSmoothStatus() {
boolean smoothStatus;
//store the original 2x2 pixels from the left corner
PImage img2x2 = createImage(2, 2, RGB);
loadPixels();
int count = 0;
for(int y = 0; y < 2; y++) {
for(int x = 0; x < 2; x++) {
img2x2.pixels[count] = get(x, y);
count ++;
}
}
//create white area
fill(255);
noStroke();
rect(0, 0, 2, 2);
//create a point
stroke(0);
point(0.5, 0.5);//-16777216 if noSmooth is on
//point(0, 0);//-10066330
//read out if it's smoothed or not
smoothStatus = (get(0,0) == -16777216) ? false : true;
//reconstruct the original
image(img2x2, 0, 0);
return(smoothStatus);
}