Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

help with coloring book
Started by patrikes May 11 2016 02:53 AM

4 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

patrikes

[GLOBAL: userInfoPane.html]
patrikes
  • Observer

  • 15 posts
  • Corona SDK

Hello
I want to make something like coloring book. I made image from coordinates pixels. This is my code to help you understand my problem.
piksele={}
local tablica={(there are numbers of pixels)}
local counterX=1    
local counterY=1
local wysokosc=444
local szerokosc=276
local rozmiarx = 1
local rozmiary = 1
local d=0
for j=1, wysokosc do
    pixels[counterY]={}
    counterX=1
        for i=1, szerokosc do
            d=(j*szerokosc)-(szerokosc-1)
             local pixelColor = tablica[i+d]
             if tablica[i+d] == 0 then
            pixels[counterY][counterX] = display.newRect(0, 0, rozmiarx, rozmiary)
             pixels[counterY][counterX]:setFillColor(pixelColor)
             pixels[counterY][counterX].x = i+20
             pixels[counterY][counterX].y = j+30
             counterX=counterX+1
             end
end
counterY=counterY+1
end
Now i want to flood fill with colors. I found this code( https://gist.github.com/GymbylCoding/8fc95e1e8d1ce2c152ef) , but i m only begginer and I dont understand how to get my table to drawn pixels. Could anyone help me with some code?



[TOPIC: post.html]
#2

patrikes

[GLOBAL: userInfoPane.html]
patrikes
  • Observer

  • 15 posts
  • Corona SDK

[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,790 posts
  • Enterprise

I have a couple of suggestions for you. First, when you post code, it needs to be formatted in an easy to read manner. For this forum software there is a blue <> button in bar with Bold and Italics. In the window that pops up, paste your code into it. It will make it much easier for the community to figure out what you're doing.

 

Secondly, we don't really support flood filling. It looks to me like Caleb has worked out a way to make it work with a bunch of small rectangles. I don't know how efficient this will be. You're best bet if you have questions about Caleb's code is to ask him in his Gymble Coding forum. I'll move this topic there.

 

Rob



[TOPIC: post.html]
#4

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Hi @patrikes! The Gist I posted a while ago is just a POC. It's not meant to be used for actual production stuff, and it's definitely not efficient at all. I suggest you try a different route for sort-of-advanced graphics editing code. The code you link to is just kind of an interesting thing I came up with to see if doing rectangle pixels was even possible.

 

- Caleb



[TOPIC: post.html]
#5

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 805 posts
  • Corona SDK

@patrikes Something I posted in a related thread might interest you (though with regard to per-pixel rects rather than flood fill).




[topic_controls]
[/topic_controls]