Hello,
I’m experimenting a bit with filling a shape with camera preview, I’d like to show just half of the camera preview (well I’d like to manage to mirror the camera preview as if the mirror plane is drawn straight through the half of the screen), but I can’t understand how to do it, after working on the size of the rect, with which I achieved some sort of that goal, but it stretched the camera fill, not leaving the camera preview the full size, I’m trying with effects, the filter.linearWipe seems interesting, but it looks like it’s not working on camera fills, anything I obtain is a black screen.
Here is a sample code for what I’m trying to do:
local widget = require( "widget" ) display.setDrawMode( "forceRender" ) display.setStatusBar( display.HiddenStatusBar ) local halfW = display.contentWidth \* 0.5 local halfH = display.contentHeight \* 0.5 local x = display.contentCenterX local y = display.contentCenterY -- local mask = graphics.newMask( "maskframe.png" ) local shape = display.newRect( x, y, display.contentWidth, display.contentHeight ) -- local shape = display.newRect( halfW \* 0.5, y, display.contentWidth, display.contentHeight ) -- local shapeR = display.newRect( (halfW + (halfW \* 0.5)), y, display.contentWidth, display.contentHeight ) --shape.anchorX = 0 --shape.anchorY = 0 shape.fill = { type="camera" } shape.fill.effect = "filter.linearWipe" shape.fill.effect.direction = { 0, 0.5 } shape.fill.effect.smoothness = 0.00000001 shape.fill.effect.progress = 0.5 -- transition.to( object.fill, { time=4000, x=0.5 } ) -- shapeR.fill = { type="camera" } -- shapeR:scale(-1,1) --shape.fill.effect = "filter.sobel" --shape.fill.effect = "filter.pixelate" if "simulator" == system.getInfo("environment") then msg = display.newText( "No camera in simulator", x, 80, "Verdana-Bold", 12 ) msg:setFillColor( 0, 0, 1 ) else display.setDefault( "cameraSource", "front" ) -- Front-facing camera --display.setDefault( "cameraSource", "back" ) -- Back-facing camera end
Any advice or sample code on this subject?
Thank you for the help,
Gabriele