Log in

View Full Version : New Script: mt_line


jmac698
12th October 2011, 11:46
#mt_line Ver 1.0 by jmac698
#A utility to create relative coordinates of a line for use with Masktools V2

n=12
str=mt_line(n,0,true,n/2)#Create a horizontal line ending with (0,0) (left line)
messageclip("'"+str+"'")

function mt_line(int "hor_radius", int "ver_radius", bool "zero", int "position"){
#mt_line(int hor_radius(1), int ver_radius(0), bool zero(true), string position(0))
#Creates a relative coordinates list that can be used in mt_convolution, mt_mappedblur, luts(x), mt_expand and mt_inpand
#Requires Masktools v2a30+ (mt_freerectangle)
#zero decides whether the center of the form is included or not.
#One of hor_radius or ver_radius must be zero
#position is the position of (0,0). Zero indicates that it is centered.
#Bugs: zero support is non-functional due to a bug in masktools
# returns 0 0 for radius=0, following underlying function
hor_radius=default(hor_radius,1)
ver_radius=default(ver_radius,0)
assert(hor_radius==0 || ver_radius==0,"mt_line: hor_radius or ver_radius must be zero")
zero=default(zero,true)
position=default(position,0)
x1=hor_radius==0?0:-position-(hor_radius-1)/2
y1=ver_radius==0?0:-position-(ver_radius-1)/2
x2=hor_radius==0?0:-position+hor_radius/2#this is one more than x1 on even radius
y2=ver_radius==0?0:-position+ver_radius/2
#mt_freerectangle : int top_x(-1), int top_y(-1), int bottom_x(1), int bottom_y(1), bool zero(true)
mt_freerectangle(x1, y1, x2, y2, zero)#automagically work when masktools is fixed
}