Yeah, that's it... Mine reverses the situation and plots the transformed coordinates instead... but there's something which causes the centre to be off... I won't ponder it anymore, now that I've got the thing I needed. I'm not really a math-guy...
Thanks a lot! Chris. -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Valentin Schmidt Verzonden: maandag 8 mei 2006 14:46 Aan: Lingo programming discussion list Onderwerp: Re: <lingo-l> spheroid distortion [EMAIL PROTECTED] wrote: > Thanks for enlightening me, Valentin :) > > There's still something fishy about it, it's not really doing what it > should... here's the code (and I'm having a float attack :) ) > Maybe you can spot where it goes wrong... > > Chris. I don't really understand this spherize function. but check out this one I just wrote, maybe it does what you need. I think it does pretty much the same as the corresponding photoshop filter. notice: code not optimized for speed yet -- optional parameters tPercent, tCenter, tRadius -- defaults: tPercent=100%, tCenter=center of image on spherize (tImage, tPercent, tCenter, tRadius) w = tImage.width h = tImage.height if voidP(tPercent) then tPercent=100.0 if voidP(tCenter) then tCenter = point(w/2, h/2) if voidP(tRadius) then tRadius = min(w/2, h/2) Math = newObject("Math") newImage = tImage.duplicate() centerX = tCenter[1] centerY = tCenter[2] rr = tRadius / sqrt(1- power(1-tPercent/100.0, 2) ) f = Math.asin(tRadius/rr) -- 100%: pi/2 repeat with y = 0 to h-1 repeat with x = 0 to w-1 d0 = sqrt(power(x-centerX,2)+power(y-centerY,2)) if d0>0 and d0<tRadius then d1 = tRadius * Math.asin(d0/rr) k = d1/d0/f xNew = centerX + (x-centerX)* k yNew = centerY + (y-centerY)* k newImage.setPixel(x, y, tImage.getPixel(xNew, yNew)) end if end repeat end repeat tImage.copyPixels(newImage, newImage.rect, newImage.rect) put "done" end [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
