Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python_fu_ofn_circumcircle usage/parameters
#1
I've managed to load an editable set of lines. I now want to draw a precision circle and I'm stuck again
Code:
images = gimp.image_list()
fill_type=1
new_image = images[0]
new_layer = new_image.layers[0]
new_vectors=pdb.gimp_vectors_new(new_image, 'Vectors!')
pdb.python_fu_path_csv_import(new_image,new_vectors,"/home/mark/cardano/original.csv")
pdb.gimp_image_add_vectors(new_image, new_vectors, 0)
// all good so far, I now want to stick a circle on it
// the next two lines dont work. says I have wrong parameter type.
points=[[4330,4086],[5749,2526],[5589.639999999999,4205.5199999999995]]
pdb.python_fu_ofn_circumcircle(new_image,points)
Reply
#2
After your last post, is the intention to write a plugin or do you want to use the Gimp menu system ?

In case anyone interested, using ofnuts ofn-path-to-shape.py (circumcircle) https://i.imgur.com/84Obqk1.mp4
1. from the menu structure
2. using the search tool /?
Reply
#3
Using Help > Plug-in Browser I found:

   

So, as the second argument the plugin seems to expect a path, not a list of points.
Reply
#4
I don't know if you need or want any more help in this. But I wrote quickly a Python function to create a path from a point list:
Code:
# Convert a pointlist=[[x,y],[x,y],...] to a path and insert in Gimp
def pointlist2path(image, pointlist, closed=False):
   path = pdb.gimp_vectors_new(image, 'path from pointlist')
   points = []
   for x,y in pointlist:
       points += [x,y,x,y,x,y]
   pdb.gimp_vectors_stroke_new_from_points(path, 0, len(points), points, closed)
   pdb.gimp_image_insert_vectors(image, path, None, 0)
   path.visible = True
   return path

##################

# Usage:
pointlist = [[0,0],[300,300],[500,10]]
path = pointlist2path(image, pointlist)
pdb.python_fu_ofn_circumcircle(image,path)
Reply
#5
(01-23-2022, 11:50 AM)mark_lester Wrote: I've managed to load an editable set of lines. I now want to draw a precision circle and I'm stuck again
Code:
images = gimp.image_list()
fill_type=1
new_image = images[0]
new_layer = new_image.layers[0]
new_vectors=pdb.gimp_vectors_new(new_image, 'Vectors!')
pdb.python_fu_path_csv_import(new_image,new_vectors,"/home/mark/cardano/original.csv")
pdb.gimp_image_add_vectors(new_image, new_vectors, 0)
// all good so far, I now want to stick a circle on it
// the next two lines dont work. says I have wrong parameter type.
points=[[4330,4086],[5749,2526],[5589.639999999999,4205.5199999999995]]
pdb.python_fu_ofn_circumcircle(new_image,points)

Can you explain the initial  problem? Looks like the proverbial XY problem to me.

Otherwise, "circumcircle" works from a Path, not from a list of coordinates (it takes the coordinates of the points on the path). If you have the coordinates of three points, finding the circumcircle (center and radius) is a mere geometry problem, not a Gimp problem.
Reply
#6
Firstly thanks everyone. I am trying to describe the following geometry. I've gotten the lines in as you see from that screen grab, and can click on them and paint them, so I can output a series of drawings explaining the geometry.  It's fire and forget, I am just fumbling about in the console. I did try adding a function, i got that wrong but as i paste these commands in a lot i should have another go, I need to do this circle and it needs to be as accurate as the rest of it, and I am still iterating. Even this colouring in is a pain, I'd like to do all that too in a config really because i keep having to redo. That's doable, dragging lines about to precise pixels or even filling in dialogues with numbers all the time, isnt. I need to draw the circle with a command.

Here is a description of wtf you are looking at that I just sent my friends. I will read above and go again. the blockages actually help in working out exactly how i want to go through this anyway.

 Every line on there is defined by just two points, specifically the positions of the G dot and the Imprinted dot. The triangles have tangents of Pi @right of top line, Brun (oh yeah) @right of bottom line, 3/4 (ie 345) on the Aspley dot, and then the phi of 345, the small side is the phi of the small/3 side of the 345 @the 9 dot, on the bottom. Then, above this diagonal diameter (just over 45 degs) two more right angle triangles of tangents e and e - 1 at the exact points that these funny empty lines on the page cut the circle described by the SIX points we already had including a diameter. so e and e-1 have some whacky coincidental to 4 sig figs geometric relationship with pi and Brun. Whackier still, if you take the actual tangent line to G, so obviously the perpendicular to this anchoring diameter line, it cuts the bottom line on the left side exactly where we want, AND, a parallel line to that and draw it from the 9 dot at the bottom, it will cut the top line exactly where required. so not only does e-1,e, and pi, brun make near perfect parallel lines, we can balance them near  perfectly, these two lines stick out as much on either side.
the above is machine generated using those rules. which is why things are very slightly out, the bottom line dribbles away but comes back at the end, we are fractions of a millimeter out on each point bar 345 Aspley dot which is a shocking 3 full millimeters from where it needs to be. That appears to be because of the fancy capital G but they could have just nudged the dot up.
Those two lines with nothing are superfluous, we can draw them ourselves. They normally are for putting the anonymous author in. They contain the crux of a chi rho. The chi rho is made by reflecting the diameter about its centre, and the line from the 9 dot to the P.
Underneath is an isosceles triangle (almost) drawn from this same point and the massive G dot and that point before the re , bottom right. Delta dot is Dee's signature. This is dot Delta.
The Petrine cross formed from the vertical line of the chi rho and that perfectly horizontal base line of Dee's delta turns out to be the exact spot of the shakes memorial, based on the two main columns of the south transept. I need to verify PRECISELY where it says. We don't actually want it to be bang on, it's just too ******* stupid at that stage.


Attached Files Thumbnail(s)
   
Image(s)
   
Reply
#7
  • In Gimp these are paths, they are saved with the image (if you save as XCF), and remain editable. If you want to adjust something, you just drag an anchor.
  • The whole point of my Path-to-Shape series is no never have to enter coordinates. The coordinates are taken from the path on which you call the function.
  • You can write a script to rebuild your construction using the ofn-path-to-shape functions but you will likely have to set each line to its path.
  • Furthermore ofn-path-to-shape functions are not designed to be called from scripts. They will work but you can have ambiguities about the result path, etc...
  • Once you have removed the relative complexity of Bézier splines, these function are fairly basic applications of Cartesian geometry, so you can achieve the same result directly in a tailored script.
  • Keep in mind that circles can only be approximated by Bézier splines, distance from any point of the "circle" to the center can vary by about .5%.
PS: What is "Brun"? The only number I can relate this to is "Brun's constant" but the existence of this number was established in 1915...
Reply


Forum Jump: