Hi Giorgio,
They should behave the same. Can you provide an example where they don't?
Hello Tom,
sure! here's the example from the draft of some graphic work,
take a look at the final effect as it should be:
www.todo.to.it/clients/nodebox/lines_joydivision_ok.jpg
this was drawn with "drawpath(pathname)".
This one instead was drawn with "pathname.draw()"
www.todo.to.it/clients/nodebox/lines_joydivision_bizarre.jpg
(it would be nice to post images also in comments :-)
here's the code:
size(400,400) background(0.5) # this is set to grey only to debug, it should be black nofill() nostroke() core = ximport("coreimage") canvas = core.canvas(150,150) imm = canvas.layer("yourgrayscaleimage.png") imm_w, imm_h = imm.size() imm_w = int(imm_w) imm_h = int(imm_h) imm_p = imm.pixels() step_x = 3 step_y = 10 linedepth = 70 def ovo(x,y,d): r = d/2.0 oval(x-r,y-r,d,d) strokewidth(0.6) stroke(1) fill(0) colormode(RGB,255) pathlist = [] for y in range(0, imm_h, step_y): multipath = BezierPath() multipath.moveto(0, y + linedepth) for x in range(0, imm_w, step_x): r, g, b = imm_p.get_pixel(x, y) c = color(r, g ,b) b = c.brightness multipath.lineto( x, y + b*linedepth) pathlist.append(multipath) for i in range(len(pathlist)): pathlist[i].draw() # THE WEIRD ONE #drawpath(pathlist[i]) # THE OK ONEload whatever grayscale blurred image you have
(and yes, it is inspired at Peter Saville's cover art for Joy Division ;-)
Ah yes, I see. You should always use drawpath().
path.draw() is for internal use only - it draws the path without taking into account the current state.
If you must use path.draw(), then first intherit the state:
p.inheritFromContext() p.draw()Thanks for sharing your Savillizer by the way, looks great! Perhaps we should add it to the gallery.
Naturally, you could also do the grayscaling and blurring in the script itself:
imm.desaturate() imm.filter_blur(5)For this to work you would also have to discern between RGB and RGBA pixels:
p = imm_p.get_pixel(x, y) if len(p) == 4: r, g, b, a = p else: r, g, b = p
Awesome! thanks for the useful tips.
If you like the idea of adding it to the gallery I'll be more than glad to prepare a document with proper images and a detailed description.
Please go ahead, we will be more than happy to add it, and thanks for sharing.
pathname.draw() VS drawpath(pathname)
Posted by Giorgio O. on Oct 29, 2007Hello,
and ?what's the difference - under the hood - between
In one sketch that I'm writing, using pathname.draw() gives me only the fill without stroke while drawpath(pathname) gives me the stroked path. Shouldn't they behave the same?
thanks!
G.