Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Gradient effects on an Image
Started by vonncc123 Feb 20 2019 09:46 PM

No replies to this topic
image fill gradient texture
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

vonncc123

[GLOBAL: userInfoPane.html]
vonncc123
  • Contributor

  • 231 posts
  • Corona SDK

Good Day, I was wondering if there is a way to put gradient effect on an image? not a rectangle, but an image. I was doing composite, but it just put the paint1 and paint2 on top of each other.

 

Here is my code:


local image_name = "Assets/landscape1.png"
local image_outline = graphics.newOutline( 2, image_name )
     
    -- local newBG = display.newImageRect( image_name, 640, 305 )
local newBG = display.newRect(0,0,640,305)
newBG.x = _W/2
newBG.y = _H/2


local paint = {
    type = "composite",
    paint1 = {  type = "image", filename = image_name },
    paint2 = {  type = "gradient", color1 = { 1, 0, 0, 0 }, color2 = { 1, 0, 0, 1 }, effect = "generator.linearGradient"}
}
newBG.fill = paint
newBG.fill.effect = "composite.average"

I also provided an Image. Thanks in advance




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: image, fill, gradient, texture