[Resolved] how to filling a circle by touchs

i am trying to fill a circle i already know how to drawing in the screen but i want to draw inside the circle exactly only without any things go outside it and if the circle filled totally i want to get notify

here is the code (just copy and paste in the main):

local widget = require "widget"  
-----------------------------------  
-- VARIABLES & LINE TABLE   
-----------------------------------  
local lineTable = {}  
  
local lineWidth = 12  
local lineColor = {R=200, G=100, B=0}  
local myRectangle = display.newRect(180, 150, 350, 350)  
myRectangle:setFillColor(140, 200, 10)  
local circle = display.newCircle( 350, 300, 130 )   
-----------------------------------  
-- DRAW LINE FUNCTIONALITY   
-----------------------------------  
local newLine = function(event)  
  
 local function drawLine()  
 local line = display.newLine(linePoints[#linePoints- 1].x,linePoints[#linePoints-1].y,linePoints[#linePoints].x,linePoints[#linePoints].y)  
 line:setColor(lineColor.R, lineColor.G, lineColor.B);  
 line.width=lineWidth;  
 lineTable[i]:insert(line)  
  
 local circle = display.newCircle(linePoints[#linePoints].x,linePoints[#linePoints].y,lineWidth/2)  
 circle:setFillColor(lineColor.R, lineColor.G, lineColor.B)  
 lineTable[i]:insert(circle)  
 end  
  
 if event.phase=="began" then  
 i = #lineTable+1  
 lineTable[i]=display.newGroup()  
 display.getCurrentStage():setFocus(event.target)  
  
 local circle = display.newCircle(event.x,event.y,lineWidth/2)  
 circle:setFillColor(lineColor.R, lineColor.G, lineColor.B)  
 lineTable[i]:insert(circle)  
  
 linePoints = nil  
 linePoints = {};  
  
 local pt = {}  
 pt.x = event.x;  
 pt.y = event.y;  
 table.insert(linePoints,pt);  
  
 elseif event.phase=="moved" then  
  
  
 local pt = {}  
 pt.x = event.x;  
 pt.y = event.y;  
  
 if not (pt.x==linePoints[#linePoints].x and pt.y==linePoints[#linePoints].y) then  
 table.insert(linePoints,pt)  
 drawLine()  
  
 end   
  
  
 elseif event.phase=="cancelled" or "ended" then  
 display.getCurrentStage():setFocus(nil)  
 i=nil  
 end  
  
return true  
end   
circle:addEventListener("touch",newLine)  
  

i am try to do like this game

https://itunes.apple.com/us/app/kids-finger-painting-learn/id383809358?mt=8
please help … [import]uid: 118973 topic_id: 32311 reply_id: 332311[/import]

finally it work and this is the code …

  
-----------------------------------  
-- VARIABLES & LINE TABLE   
-----------------------------------  
local lineTable = {}  
  
local lineWidth = 12  
local lineColor = {R=200, G=100, B=0}  
local myRectangle = display.newRect(0, 0, display.contentWidth, display.contentHeight)  
myRectangle:setFillColor(140, 290, 10)  
local img = display.newImageRect( "test.png", 400, 400 )   
  
img.x = display.contentWidth/2  
img.y = display.contentHeight/2  
  
   
-----------------------------------  
-- DRAW LINE FUNCTIONALITY   
-----------------------------------  
local newLine = function(event)  
  
 local function drawLine()  
 local line = display.newLine(linePoints[#linePoints- 1].x,linePoints[#linePoints-1].y,linePoints[#linePoints].x,linePoints[#linePoints].y)  
 line:setColor(lineColor.R, lineColor.G, lineColor.B);  
 line.width=lineWidth;  
 lineTable[i]:insert(line)  
  
 local circle = display.newCircle(linePoints[#linePoints].x,linePoints[#linePoints].y,lineWidth/2)  
 circle:setFillColor(lineColor.R, lineColor.G, lineColor.B)  
 lineTable[i]:insert(circle)  
 end  
  
 if event.phase=="began" then  
 i = #lineTable+1  
 lineTable[i]=display.newGroup()  
 display.getCurrentStage():setFocus(event.target)  
  
 local circle = display.newCircle(event.x,event.y,lineWidth/2)  
 circle:setFillColor(lineColor.R, lineColor.G, lineColor.B)  
 lineTable[i]:insert(circle)  
  
 linePoints = nil  
 linePoints = {};  
  
 local pt = {}  
 pt.x = event.x;  
 pt.y = event.y;  
 table.insert(linePoints,pt);  
  
 elseif event.phase=="moved" then  
  
  
 local pt = {}  
 pt.x = event.x;  
 pt.y = event.y;  
  
 if not (pt.x==linePoints[#linePoints].x and pt.y==linePoints[#linePoints].y) then  
 table.insert(linePoints,pt)  
 drawLine()  
  
 img:toFront()  
 end   
  
  
 elseif event.phase=="cancelled" or "ended" then  
 display.getCurrentStage():setFocus(nil)  
 i=nil  
 end  
  
return true  
end   
  
  
myRectangle:addEventListener("touch",newLine)  
  
  

to check if the circle filled all you should have a sensors inside the circle
here is the test.png :
https://www.dropbox.com/s/lypqx0d3vk3uymm/test.png
test.png =

it like a Transparent circle inside black background

i would thank Ricardo
for his hint :)) [import]uid: 118973 topic_id: 32311 reply_id: 128652[/import]

finally it work and this is the code …

  
-----------------------------------  
-- VARIABLES & LINE TABLE   
-----------------------------------  
local lineTable = {}  
  
local lineWidth = 12  
local lineColor = {R=200, G=100, B=0}  
local myRectangle = display.newRect(0, 0, display.contentWidth, display.contentHeight)  
myRectangle:setFillColor(140, 290, 10)  
local img = display.newImageRect( "test.png", 400, 400 )   
  
img.x = display.contentWidth/2  
img.y = display.contentHeight/2  
  
   
-----------------------------------  
-- DRAW LINE FUNCTIONALITY   
-----------------------------------  
local newLine = function(event)  
  
 local function drawLine()  
 local line = display.newLine(linePoints[#linePoints- 1].x,linePoints[#linePoints-1].y,linePoints[#linePoints].x,linePoints[#linePoints].y)  
 line:setColor(lineColor.R, lineColor.G, lineColor.B);  
 line.width=lineWidth;  
 lineTable[i]:insert(line)  
  
 local circle = display.newCircle(linePoints[#linePoints].x,linePoints[#linePoints].y,lineWidth/2)  
 circle:setFillColor(lineColor.R, lineColor.G, lineColor.B)  
 lineTable[i]:insert(circle)  
 end  
  
 if event.phase=="began" then  
 i = #lineTable+1  
 lineTable[i]=display.newGroup()  
 display.getCurrentStage():setFocus(event.target)  
  
 local circle = display.newCircle(event.x,event.y,lineWidth/2)  
 circle:setFillColor(lineColor.R, lineColor.G, lineColor.B)  
 lineTable[i]:insert(circle)  
  
 linePoints = nil  
 linePoints = {};  
  
 local pt = {}  
 pt.x = event.x;  
 pt.y = event.y;  
 table.insert(linePoints,pt);  
  
 elseif event.phase=="moved" then  
  
  
 local pt = {}  
 pt.x = event.x;  
 pt.y = event.y;  
  
 if not (pt.x==linePoints[#linePoints].x and pt.y==linePoints[#linePoints].y) then  
 table.insert(linePoints,pt)  
 drawLine()  
  
 img:toFront()  
 end   
  
  
 elseif event.phase=="cancelled" or "ended" then  
 display.getCurrentStage():setFocus(nil)  
 i=nil  
 end  
  
return true  
end   
  
  
myRectangle:addEventListener("touch",newLine)  
  
  

to check if the circle filled all you should have a sensors inside the circle
here is the test.png :
https://www.dropbox.com/s/lypqx0d3vk3uymm/test.png
test.png =

it like a Transparent circle inside black background

i would thank Ricardo
for his hint :)) [import]uid: 118973 topic_id: 32311 reply_id: 128652[/import]