Stroke () with pressure

There are 3 strokeCap โ€‹โ€‹() modes in processing: SQUARE, PROJECT or ROUND. However, I am trying to get an effect that simulates pressure, like in Photoshop.

enter image description here

Is there any way to achieve this effect by programming it? I am thinking of using an ellipse that gradually grows and shrinks in size, but I am stuck in figuring out where the start and end of the stroke are when drawing the sketch.

+3


source to share


1 answer


This can be a very rudimentary approach to what you want, but it can be a good starting point. I'm not sure if you want the full pressure sensitivity characterization, but this solution is what simulates this effect by replacing pressure with velocity. This is an example from Daniel Schiffman's Tutorial. Here's a link to the code: http://learningprocessing.com/exercises/chp03/exercise-03-07-absolute-value

I'll post it here as well.



// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com

void setup() {
  size(200, 200);
  background(255);
  smooth();
}

void draw() {
  stroke(0);
  strokeWeight(abs(pmouseX - mouseX));
  line(pmouseX, pmouseY, mouseX, mouseY);
}

      

Hope this is a good starting point for what you need.

+1


source







All Articles