Tape Mouse

I was looking around for different project's in processing and i came across something interesting, it stated something about "using a mouse as a tape measure tool" i thought to myself "that's impossible" then i read more about it and it mentioned something about using the mouse wheel for it and i thought to myself "might actually work" so i first started by seeing how many clicks the mouse wheel does before it does a full rotation and checked how far on click is , it turns out its about .125 inches AKA 1/8 of an inch, so i started testing it out and it works well ! Keep in consideration that the mouse wheel only has an estimate of how long the piece is , so if the object is 6 inches the program would do something like 6.125 or 5.875 . Hopefully this tool could come in handy when measuring round objects or weirdly shaped objects! reply to this if you would like to take a look at the code!

submitted by /u/alexander20112
[link] [comments]

fill() fills all children of SVG instead of just one.

I'm trying to change the colours of the children of an svg but as far as I can see, the last colour called is used to fill the entire image. It looks as if the filling behaviour is happenening correctly (I can see this at a slow framerate in the first example below), until the mouse is released, then the last fill() call fills everything.

I've tried adding individual colour variables for each child but that doesn't work either (second version below).

Anyone know how to stop this? Any help appreciated.

The intention is to build an interactive where people can send commands to the program where they can choose the part of the image to change the colour of, so the image needs to be drawn continuously otherwise the newly coloured pieces will overlap incorrectly.

SVG xml here

First Version:

PShape img, meatus, head, dGlans, mGlans, fGlans, tBones, tMeat, tongue, temp, lips, teethDirt, teeth, gums, uvula, dThroat, mThroat, fThroat, mouthInner; PVector pos; boolean clicked = false; void setup() { size(800, 800); pos = new PVector(0, 0); img = loadShape("WholeImageIV.svg"); meatus = img.getChild("dickSlit"); head = img.getChild("dickhead"); dGlans = img.getChild("deepGlans"); mGlans = img.getChild("midGlans"); fGlans = img.getChild("foreGlans"); tBones = img.getChild("toungueBones"); tMeat = img.getChild("tongueMeat"); tongue = img.getChild("tongue"); lips = img.getChild("lips"); teethDirt = img.getChild("teethDirt"); teeth = img.getChild("teeth"); gums = img.getChild("gums"); uvula = img.getChild("uvula"); dThroat = img.getChild("deepThroat"); mThroat = img.getChild("midThroat"); fThroat = img.getChild("foreThroat"); mouthInner = img.getChild("mouthInner"); frameRate(5); } void draw() { background(100); shape(img, 0, 0); stroke(255); img.disableStyle(); if (clicked) { for (int i = 0; i < img.getChildCount(); i++) { temp = img.getChild(i); fill(random(255), random(255), random(255)); shape(temp, 0, 0); } } } void mousePressed() { clicked = !clicked; } void mouseReleased() { clicked = !clicked; } 

Second Version:

PShape img, meatus, head, dGlans, mGlans, fGlans, tBones, tMeat, tongue, temp, lips, teethDirt, teeth, gums, uvula, dThroat, mThroat, fThroat, mouthInner; PVector pos; boolean clicked = false; color cMeatus, cHead, cDGlans, cMGlans, cFGlans, cTBones, cTMeat, cTongue, cLips, cTeethDirt, cTeeth, cGums, cUvula, cDThroat, cMThroat, cFThroat, cMouthInner; void setup() { size(800, 800); pos = new PVector(0, 0); img = loadShape("WholeImageIV.svg"); meatus = img.getChild("dickSlit"); head = img.getChild("dickhead"); dGlans = img.getChild("deepGlans"); mGlans = img.getChild("midGlans"); fGlans = img.getChild("foreGlans"); tBones = img.getChild("toungueBones"); tMeat = img.getChild("tongueMeat"); tongue = img.getChild("tongue"); lips = img.getChild("lips"); teethDirt = img.getChild("teethDirt"); teeth = img.getChild("teeth"); gums = img.getChild("gums"); uvula = img.getChild("uvula"); dThroat = img.getChild("deepThroat"); mThroat = img.getChild("midThroat"); fThroat = img.getChild("foreThroat"); mouthInner = img.getChild("mouthInner"); //frameRate(5); } void draw() { background(100); img.enableStyle(); shape(img, 0, 0); noStroke(); img.disableStyle(); if (keyPressed) interaction(key); shape(mouthInner, pos.x, pos.y); shape(tongue, pos.x, pos.y); println("M: " + cMouthInner + " T: " + cTongue); } color colourChange() { println("colour changed"); return color(random(255), random(255), random(255)); } void interaction(int section) { int tempSection = section; switch(tempSection) { case '1': mouthInner.disableStyle(); fill(cMouthInner = colourChange()); shape(mouthInner, pos.x, pos.y); case '2': tongue.disableStyle(); fill(cTongue = colourChange()); shape(tongue, pos.x, pos.y); } } 
submitted by /u/OlympicGurn
[link] [comments]

How do I change the color of these dots? How do I add more elements to this pattern?

I'm trying to make a still image of a generative pattern for a poster. I have this code:

float[][] distances; float maxDistance; int spacer; void setup() { size(1200, 1200); maxDistance = dist(width/4, height/4, width, height); distances = new float[width][height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { float distance = dist(width/4, height/4, x, y); distances[x][y] = distance/maxDistance * 450; } } spacer = 12; strokeWeight(12); noLoop(); } void draw() { background(12); for (int y = 0; y < height; y += spacer) { for (int x = 0; x < width; x += spacer) { stroke(distances[x][y]); point(x + spacer/5, y + spacer/8); } } } 

How would I go about changing the color of these dots? Adding "colorMode" doesn't do anything. I got the code off the Processing website where it is a sample, and I am in the process of trying to modify it.

Basically I really want to fuck around with it and add stuff but I don't know how. Also, why are the circles so blurry?

Thanks!

submitted by /u/maekart
[link] [comments]

Need help with making a still image, a generative pattern for a poster

So I'm brand new to Processing, and I'll be honest, I don't really understand it. The only experience I have is with HTML. I've spent many hours looking at tutorials but can't seem to find out how to do what I want to do.

I want to make a poster with a still image, a drawing made with Processing. It doesn't have to be very complicated, but just something with maybe lines repeating at certain intervals, or shapes repeating? I can make a single rectangle or line but don't really know how to place thousands in a pattern.

I'm not asking for someone to make it for me, just to point me in the right direction, maybe to a bit of example code I can play around with and modify.

Any help is greatly appreciated.

submitted by /u/maekart
[link] [comments]

Is processing free to distribute?

Hi! I'm a Computer Science student at a state university and we're having an open house in a few weeks. I want to put processing on flash drives and distribute them to potential students that seem interested in programming as part of a display I'm building. I wanted to know if that broke any of the license agreements with processing? I've already found some IDEs for Java that are open sourced and don't allow this, but I can't find the documentation for processing. I think it's a really good language to develop interest in computer science because it's very easy to create highly visual content. Thanks for your time!

submitted by /u/DragonGuru
[link] [comments]

[PWC51] Image Input

Hello Everybody, this is the 51st Weekly Processing challenge, the challenges are decided just to give you a prompt to test your skills so it can be as simple or as complicated as you have time to write!

Start Date : 27-02-2017 End Date : 05-03-2017

Post entries in the comments here.

This Weeks Challenge : Image input, write something that takes the following image and creates some sort of interesting output from it. With creativity you could use the same code from last week, if this is what you want to do look into PImage and the function loadpixels which gives a 1 dimensional array of pixel values

Image

Winners from last week : -Nicolai

Don't forget to vote for your favorite submissions!

Also I am currently out of ideas so if you have any suggestions let me know.

submitted by /u/seoceojoe
[link] [comments]

Help with some code.

Having a little trouble with some code.

I am creating code that randomly picks a letter, and after comparing that letter to an index in an array, prints that letter then starts over in the next letter slot.

I believe I am almost there, but am in need of some help.

Original Code

I know that the line I'm having trouble with is this one :

this.letter = text(randomLetter, 25 + textsize, 100); 

(line 64) I get why it doesn't work, but can't figure a loop around to combat it. Any suggestions?

submitted by /u/ilDosh
[link] [comments]