I have Batik installed on my Windows computer and can start the Squiggle browser from the Command prompt.
Not impressed yet. Why are applications being started from the Command prompt anyway?
batik.jar
batik-rasterizer.jar
batik-slideshow.jar
batik-squiggle.jar
batik-svgpp.jar
batik-ttf2svg.jar
and folder lib that has other batik jar files
Start sketch.
Import library; select batik from list (indicating the batik library folder is recognized by Processing?)
Enter code that includes:
error: The package “batik” does not exist. You might be missing a library.
Any idea what the problem is?
“The Extensible Markup Language XML has become the standard for exchanging structured data in Internet applications. proXML allows you to easily integrate and manipulate this data in Processing.”
http://creativecomputing.cc/p5libs/proxml/index.htm
I have this file generated in Inkscape - drawing08.svg - with one rectangle. It basically includes the following:
Add this code:
Console shows:
children index: 0<defs…
children index: 1<sodipodi…
children index: 2<metadata…
children index: 3<g…
Add this code:
Console shows:
children[3]
attributes index: 0inkscape:label
attributes index: 1transform
attributes index: 2inkscape:groupmode
attributes index: 3id
Add this code:
Console shows:
inkscape:label NOT EQUAL transform
transform NOT EQUAL transform
inkscape:groupmode NOT EQUAL transform
id NOT EQUAL transform
Add this code:
Console shows:
attValue: translate(-8.5714245,593.94476)
The term getChild() implies the getting of an independent child object.
I've found this to be a little misleading.
Each rectangle has id: house, door, window.
The svg file shows:
In the sketch I have:
In a previous thread I mentioned that the x,y values of child shapes can be made absolute if translate and x,y values in the svg file are edited to zero.
When going a step further to modify the size of child shapes, I discovered that getChild is really getChildWithPage.
house.width also returns 388.57144.
door.width also returns 388.57144.
window.width also returns 388.57144.
If your code wants to modify the child shape size, it needs to recognize the Page size.
For example, to resize the house, this code works:
Parameters houseW and houseH, along with doorW, doorH, windowW and windowH must be manually entered in Processing from the svg file. It would be much easier if Processing provided the actual child shape dimensions found in the svg file (e.g. house.width = 300; door.width = 60; window.width = 100).
Summary.
As a beginner, I was disappointed that getChild() does not get a shape object that’s independent of the source page. When getChild() is utilized, do we really need to know about the source page size?
In the meantime, I’ve found ways to work around the location (x,y) and size (width,height) "problems" of child shapes. I’m providing this because I don’t see it explained anywhere else.
Please advise if there are simpler ways to do this.
In Inkscape, I have 3 separate rectangles in a page 388w x 297h px.
Each rectangle has id: house, door, window.
That agrees with Page size.
But it also includes:
Where does the transform="translate(-8.5714245,593.94476)"> get these values?
I couldn’t find them in Inkscape.
In the sketch I have:
displays the whole file, all three rectangles as they appear in Inkscape.
But to see the children, I need to use
In Reference, shape() it indicates that parameters x, y, width, and height refer to location and size of drawn shape.
http://processing.org/reference/shape_.html
The only way I’ve seen this works is if:
The sketch has two Main objects.
Each Main has two Part child objects.
But when the Main objects move, the Parts are not staying with them.
How does that work?
I don’t have a specific programming code problem. I wanted to share some code that I haven’t seen in tutorials. I’ve found two methods to do mouse rollover on a circle; there may be others. The sketch includes a demonstration of both methods.
Method A.
S1. Subtract center x from mouseX; square that
S2. Subtract center y from mousey; square that
S3. Add the two square values
S4. If the sum is <= square of radius, the mouse is over (in) the circle.
I copied this concept from: http://stackoverflow.com/questions/481144/how-do-you-test-if-a-point-is-inside-a-circle
Method B.
S1. Subtract mouseX from center x; square that
S2. Subtract mousey from center y; square that
S3. Add the two square values.
S4. Get the square root of that sum.
S5. If the square root < radius, the mouse is over (in) the circle.
Note: the “overCircle” block – not used - at end of my code is example of Method B, copied from:
http://processing.org/learning/topics/buttons.html
When the sketch starts, the mouse positions are 0,0 and is therefore not in the circle. As the user moves the mouse, the values in both methods are updated and displayed. Moving the mouse off the window resets it to 0,0.
The user can click on one of four X’s to show the values of each “corner” where either mouseX or mouseY is set to the radius. These corner settings are helpful in following the math in both methods. Note: Although the mouse settings are set to these values, I don’t know how to actually move the cursor.
Notice that only “A – ON CIRCLE” appears in the circle when a corner X is clicked. There seems to be a question of whether the points on the circumference are part of the circle or if they’re an outside wall of the circle. If one imagines the circumference as a “one-pixel-thick” container, the circumference points would not be inside the container. But in a 2d area, it seems that the circumference is part of the circle. I don’t want to open that discussion; you can modify it as desired. When the average person is moving the mouse, she doesn’t know if it’s exactly on the circumference, so either “<=” or “<” seem to work.
After moving the cursor around, I noticed a pattern. Both methods arrive at the same squared value in step 3. So it makes no difference in steps 1 and 2 which number is subtracted. A negative number squared is positive. So all coordinate differences give positive results in the fourth column.
The big difference is in steps 4 and 5. I don’t understand the logic (especially Method B) but they do work.
Anybody know how these calculations developed? Is it part of geometry?