class MMF_ImageImport(common.ulb:ImageWrapper) {
public:
func MMF_ImageImport(Generic pparent)
ImageWrapper.ImageWrapper(pparent)
m_ImportedImage = new @p_importedimage
m_Transform = new @p_transform(this)
m_Transform.Init(0)
m_Transform1 = new @p_transform1(this)
m_Transform1.Init(0)
if @adjustlayer
m_Adjust = new @f_adjust(this)
endif
if !getEmpty() && @p_seamless
m_Widthm1 = getWidth()
m_Heightm1 = getHeight()
m_InvWidth = 1.0/m_Widthm1
m_InvHeight = 1.0/m_Heightm1
m_Widthm1 = m_Widthm1 - 1.0
m_Heightm1 = m_Heightm1 - 1.0
endif
endfunc
color func getColor(complex pz)
if getEmpty()
return rgba(0,0,0,0)
endif
pz = m_Transform.Iterate(pz)
if @p_maintainaspect
pz = NormalizePixel(pz)
endif
if @p_tile
float x = (real(pz)+1.0)%2.0
if x<0.0
x = x + 1.0
else
x = x - 1.0
endif
float y = (imag(pz)+1.0)%2.0
if y<0.0
y = y + 1.0
else
y = y - 1.0
endif
pz = x + flip(y)
endif
pz = m_Transform1.Iterate(pz)
if @p_retile && @p_tile
float x = (real(pz)+1.0)%2.0
if x<0.0
x = x + 1.0
else
x = x - 1.0
endif
float y = (imag(pz)+1.0)%2.0
if y<0.0
y = y + 1.0
else
y = y - 1.0
endif
pz = x + flip(y)
endif
if @p_mirror
if @p_flip
pz = -pz
else
pz = -real(pz) + flip(imag(pz))
endif
elseif @p_flip
pz = real(pz) - flip(imag(pz))
endif
if @p_seamless
pz = (real(pz)*m_Widthm1 - 1.0)*m_InvWidth \
+ flip((imag(pz)*m_Heightm1 + 1.0)*m_InvHeight )
endif
color clr = m_ImportedImage.getColor(pz)
if @adjustlayer
color c = @f_adjustcolour
if @adjusttype==0
c = RGB(@adjred, @adjgreen, @adjblue)
endif
c = compose(clr, m_Adjust.Merge(clr, c), @f_opacity)
return RGBA(red(c), green(c), blue(c), alpha(clr))
endif
return clr
endfunc
color func getPixel(int px, int py)
if getEmpty()
return rgba(0,0,0,0)
endif
return getColor(2.0*px/getWidth()-1.0+flip(2.0*py/getHeight()-1.0))
endfunc
bool func getEmpty()
return m_ImportedImage.getEmpty()
endfunc
int func getWidth()
return m_ImportedImage.getWidth()
endfunc
int func getHeight()
return m_ImportedImage.getHeight()
endfunc
protected:
Image m_ImportedImage
Transform m_Transform
Transform m_Transform1
ColorMerge m_Adjust
float m_Widthm1
float m_Heightm1
float m_InvWidth
float m_InvHeight
default:
title = "MMF Image Import"
int param v_imageimport
caption = "Version (ImageImport)"
default = 100
hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
visible = @v_imageimport < 100
endparam
Image param p_importedimage
caption = "Image file"
hint = "This is the image you want to import and use."
endparam
bool param p_maintainaspect
caption = "Keep proportions"
default = true
hint = "If checked, the image will have the same proportions it \
originally had (except for any fractal distortion). If you \
uncheck this box, the image will be stretched to a square \
shape regardless of its original dimensions."
endparam
Transform param p_transform
caption = "Pre-Transform"
default = NullTransform
hint = "Use to stretch/scale/rotate your image. Applied prior to tiling."
endparam
bool param p_tile
caption = "Tile Image"
default = true
hint = "Tiles the image when enabled."
endparam
Transform param p_transform1
caption = "Post-Transform"
default = NullTransform
hint = "Use to stretch/scale/rotate your image. Applied after tiling."
endparam
bool param p_retile
caption = "Re-Tile Image"
default = false
hint = "Re-applies the tiling after the 'Post-Transform'. This option is \
for when you want transparent areas produced by applying the \
post-transform to be filled from the image."
visible = @p_tile
endparam
bool param p_mirror
caption = "Mirror Image"
default = false
hint = "Mirrors the image when enabled."
endparam
bool param p_flip
caption = "Flip Image"
default = false
hint = "Flips the image when enabled."
endparam
bool param p_seamless
caption = "Seamless edges"
default = true
hint = "When enabled the transparency at the edges of the image rectangle \
is adjusted (for when tiling the image)."
endparam
bool param adjustlayer
caption = "Add Adjust layer"
default = false
hint = "Allows you to add an adjustment layer in a given colour to merge \
on top of the image."
endparam
int param adjusttype
caption = "Colour or RGB"
enum = "RGB values" "Colour Parameter"
default = 1
hint = "This option is specifically added so that if you choose \
'RGB values' you can 'explore' them and see changes to the image \
as you change the RGB. The option may become redundant in a \
future version of UF."
visible = @adjustlayer
endparam
float param adjred
caption = "Red Value"
default = 1.0
hint = "The red part of the adjust colour (0 to 1)."
visible = @adjustlayer && @adjusttype==0
endparam
float param adjgreen
caption = "Green Value"
default = 1.0
hint = "The green part of the adjust colour (0 to 1)."
visible = @adjustlayer && @adjusttype==0
endparam
float param adjblue
caption = "Blue Value"
default = 1.0
hint = "The blue part of the adjust colour (0 to 1)."
visible = @adjustlayer && @adjusttype==0
endparam
color param f_adjustcolour
caption = "Adjust Layer Colour"
default = RGB(1,1,1)
hint = "Allows you to apply overall adjustments to your colouring."
visible = @adjustlayer && @adjusttype==1
endparam
ColorMerge param f_adjust
caption = "Adjustment Layer Merge"
default = MMF_ExtendedColorMerge
visible = @adjustlayer
endparam
float param f_opacity
caption = "Adjustment Opacity"
default = 1.0
hint = "Use to modify the adjustment opacity, the normal range is from \
0 to 1."
visible = @adjustlayer
endparam
}