Blends and Composite Fills in Graphics 2.0

Im trying to test out first taking a picture and save it to system.TemporaryDirectory == this works fine
and the try to use it in a comp blend == not ok, I get this error code:
“Attempt to concatenate upvalue ‘baseDir’ (a userdata value)”

Heres the chunk that goes wrong:
[lua]
local baseDir = system.TemporaryDirectory
[/lua]
–The image in temp dir = “image01.jpg”

–Further down in the code:
[lua]
compositePaint =
  {
     type=“composite”,
     paint1 = { type=“image”, filename = baseDir … “image01.jpg” },
     paint2 = { type=“image”, filename = “texture3.jpg” }
  }

[/lua]
When trying this code;

  1. click first on the button start screen (it fires up the camera and saves it to the baseDir)
  2. click the button over to start the blending show
    Download the attached file and try it out:
    PS!
    You have to use Version 2013.2026 (2013.07.15) for this to work

Download the test here and try it out

I think you have to use system.pathForFile() to get access to the image first.

Like in:
local savedImage = system.pathForFile(“image01.jpg”, basedir)

system.TemporaryDirectory is not a string that can be appended to a file.  You should be able to do:
 

compositePaint =  {     type=“composite”,     paint1 = { type=“image”, filename = “image01.jpg”, baseDir=system.TemporaryDirectory  },     paint2 = { type=“image”, filename = “texture3.jpg” }  }

See:

http://docs.coronalabs.com/api/type/BitmapPaint/index.html

Rob

Hi Rob 

This does not work:

Heres the code I used from examplefile, I just copied the files to the sandboxed temp folder and reloaded

[lua]

– list of effects

local composite_effect = {
“composite.add”,
“composite.average”, 
“composite.colorBurn”,
“composite.colorDodge”,
“composite.darken”,  
“composite.exclusion”,
“composite.glow”,
“composite.hardLight”,
“composite.hardMix”,
“composite.lighten”,
“composite.linearLight”,
“composite.multiply”,
“composite.negation”,
“composite.normalMapWith1DirLight”,
“composite.normalMapWith1PointLight”,
“composite.overlay”,
“composite.phoenix”, 
“composite.pinLight”, 
“composite.reflect”,
“composite.screen”,
“composite.softLight”,
“composite.subtract”,
“composite.vividLight”,
}

– setup the UI

local effectText = display.newText("", display.contentCenterX/2, 180, “Helvetica”, 32)
local effectText1 = display.newText(“Normal”, display.contentCenterX / 2 + display.contentCenterX, 180, “Helvetica”, 32)
local tapToStart = display.newText(“Tap anywhere to start”, display.contentCenterX, 60, “Helvetica”, 48)

– Declare the paint

local compositePaint =
{
    type=“composite”,
    paint1={ type=“image”, filename=“image01.jpg”, baseDir=system.TemporaryDirectory },
    paint2={ type=“image”, filename=“images/texture3.jpg” }
}

– setup the comparison image

local base = display.newImageRect( “images/image01.jpg”, 600, 400 )
base.x = display.contentCenterX / 2 + display.contentCenterX
base.y = display.contentCenterY

– setup the image to modify

local object = display.newRect(0, 0, 600, 400)
object.x = display.contentCenterX / 2
object.y = display.contentCenterY

– start up the timer to loop through the effects
local startItUp
startItUp = function(event)
if event.phase == “ended” then
  tapToStart.isVisible = false
  Runtime:removeEventListener(“touch”, startItUp)
  local index = 1
  timer.performWithDelay(2000, function()
    effectText.text = composite_effect[index]
    object.fill = compositePaint
    object.fill.effect = composite_effect[index]
    index = index + 1
   end, #composite_effect)
end
return true
end

Runtime:addEventListener(“touch”, startItUp)

[/lua]

The images are well known, I think you or Walter made the example ;D)

try it out and see for your self, I use: Version 2013.2036 (2013.07.15)

Got this error:

File: /Users/henrikruud/Desktop/CompositePaint/main.lua
Line: 56 (here)

Attempt to index field ‘fill’ (a string value)

Can you try the latest daily build? There was a bug where the baseDir was not honored in the fill param — fixed starting in 2013.2086

And there the bug was   :slight_smile:

Thanks for fixing and letting me know

Everything is working now

A big thank to you and Rob!

For the others that read this string:

The problem was fixed in build 

2013.2086

So, problem solved.

I think you have to use system.pathForFile() to get access to the image first.

Like in:
local savedImage = system.pathForFile(“image01.jpg”, basedir)

system.TemporaryDirectory is not a string that can be appended to a file.  You should be able to do:
 

compositePaint =  {     type=“composite”,     paint1 = { type=“image”, filename = “image01.jpg”, baseDir=system.TemporaryDirectory  },     paint2 = { type=“image”, filename = “texture3.jpg” }  }

See:

http://docs.coronalabs.com/api/type/BitmapPaint/index.html

Rob

Hi Rob 

This does not work:

Heres the code I used from examplefile, I just copied the files to the sandboxed temp folder and reloaded

[lua]

– list of effects

local composite_effect = {
“composite.add”,
“composite.average”, 
“composite.colorBurn”,
“composite.colorDodge”,
“composite.darken”,  
“composite.exclusion”,
“composite.glow”,
“composite.hardLight”,
“composite.hardMix”,
“composite.lighten”,
“composite.linearLight”,
“composite.multiply”,
“composite.negation”,
“composite.normalMapWith1DirLight”,
“composite.normalMapWith1PointLight”,
“composite.overlay”,
“composite.phoenix”, 
“composite.pinLight”, 
“composite.reflect”,
“composite.screen”,
“composite.softLight”,
“composite.subtract”,
“composite.vividLight”,
}

– setup the UI

local effectText = display.newText("", display.contentCenterX/2, 180, “Helvetica”, 32)
local effectText1 = display.newText(“Normal”, display.contentCenterX / 2 + display.contentCenterX, 180, “Helvetica”, 32)
local tapToStart = display.newText(“Tap anywhere to start”, display.contentCenterX, 60, “Helvetica”, 48)

– Declare the paint

local compositePaint =
{
    type=“composite”,
    paint1={ type=“image”, filename=“image01.jpg”, baseDir=system.TemporaryDirectory },
    paint2={ type=“image”, filename=“images/texture3.jpg” }
}

– setup the comparison image

local base = display.newImageRect( “images/image01.jpg”, 600, 400 )
base.x = display.contentCenterX / 2 + display.contentCenterX
base.y = display.contentCenterY

– setup the image to modify

local object = display.newRect(0, 0, 600, 400)
object.x = display.contentCenterX / 2
object.y = display.contentCenterY

– start up the timer to loop through the effects
local startItUp
startItUp = function(event)
if event.phase == “ended” then
  tapToStart.isVisible = false
  Runtime:removeEventListener(“touch”, startItUp)
  local index = 1
  timer.performWithDelay(2000, function()
    effectText.text = composite_effect[index]
    object.fill = compositePaint
    object.fill.effect = composite_effect[index]
    index = index + 1
   end, #composite_effect)
end
return true
end

Runtime:addEventListener(“touch”, startItUp)

[/lua]

The images are well known, I think you or Walter made the example ;D)

try it out and see for your self, I use: Version 2013.2036 (2013.07.15)

Got this error:

File: /Users/henrikruud/Desktop/CompositePaint/main.lua
Line: 56 (here)

Attempt to index field ‘fill’ (a string value)

Can you try the latest daily build? There was a bug where the baseDir was not honored in the fill param — fixed starting in 2013.2086

And there the bug was   :slight_smile:

Thanks for fixing and letting me know

Everything is working now

A big thank to you and Rob!

For the others that read this string:

The problem was fixed in build 

2013.2086

So, problem solved.