06 Jan 2013, 06:13
Generic-user-small

steve daniels (1 post)

Just started with book today (Jan 6 , 2013), seems you are aware of this, but for other readers

motionPressure no longer support in P2b7.

This breaks many examples in Chapter 2, minor frustration so early on – especially since this is such a great resource.

Based on one of the chapter footnotes and this link - http://wiki.processing.org/w/Android#Mouse.2C_Motion.2C_Keys.2C_and_Input

can get functionality back with mod to mousePressed() (or other mouse calls)

void mousePressed() {
  println( "pressed x: " + mouseX + " y: " + mouseY);
  
// add folowing lines
  MotionEvent me = (MotionEvent) mouseEvent.getNative();
  float mPres = me.getPressure();
  println (mPres);  // can do stuff with this float now -- mine ranges .4 - 3.6 -- not 0 -1

}
08 Jan 2013, 08:05
Generic-user-small

James Clark (1 post)

Ah, thanks for this, I was wondering what I had missed.

There are a few of other things to get the 2.2 example working: # the import: import android.view.MotionEvent; # a motionPressure global var that is set in the mousePressed event. # use the mouseDragged event to update the motionPressure variable so that it detects changes in pressure during the drag.

import android.view.MotionEvent;

float maxPressure;
float motionPressure;

void setup()
{
  noStroke();
  background(0);
}

void draw()
{
  fill(motionPressure/maxPressure * 255);
  
  ellipse(mouseX, mouseY, mouseX-pmouseX, mouseY-pmouseY);
  
  println(motionPressure);
  
  if(motionPressure > maxPressure)
    maxPressure = motionPressure;
}

void mouseDragged() {
  MotionEvent me = (MotionEvent) mouseEvent.getNative();
  motionPressure = me.getPressure();
  println (motionPressure);  // can do stuff with this float now -- mine ranges .4 - 3.6 -- not 0 -1
}
19 Mar 2013, 19:51
Ds_2009_mpark_pragsmall

Daniel Sauter (46 posts)

Thanks for posting this fix. The motionPressure constant is gone for good, so we need to do it this way. Best, Daniel

  You must be logged in to comment