Reverse 'pixelcoloring' and total amount of colors

William de Smet williamdesmet at gmail.com
Mon Mar 5 14:13:26 EST 2018


Thanks Mike that helped a lot!
I extended your script with this:

----
repeat with x= 1 to the number of items of tInstructions
put char 2 of item x of tInstructions into tChar
put "v"&x into tNaam
set the label of btn tNaam to tChar
set the showname of btn tNaam to true
put char 1 of item x of tInstructions into tLetter
if tLetter is "W"
then
set the backgroundcolor of btn tNaam to 255,255,255
else
set the backgroundcolor of btn tNaam to 90,200,250
end if
end repeat
---

Now it almost looks like this:
http://www.camelcaps.nl/pixelcoding/pixelcoding.jpg

One thing left:
If the last button(s) is/are white it doesn't have to be shown on the
instruction.
So how do I leave it out?
When I add this it almost works:
--
if char 1 of the last item of tInstructions is "W"
then
put the last item of tInstructions into fld "instructions2"
delete the last item of tInstructions
--
This fails if the last item is the first and only item (when there are 7
white buttons).
Any thoughts on this?



greetings,

William



2018-03-05 17:41 GMT+01:00 Mike Bonner via use-livecode <
use-livecode at lists.runrev.com>:

> Ah, I understand better now.
> Something like this should work.  Its just a quicky, no time to really test
> before my doc appointment.
>
>
> on mouseup
> local tInstructions -- gotta have this cause a non declared isn't seen as
> empty
>
>    repeat with i = 1 to 4
>       switch
>          case the backgroundcolor of button ("b" & i) is "255,255,255"
>             if tInstructions is empty then put "W0" into tInstructions
>             if char -2 of tInstructions is not "W" then put comma & "W0"
> after tInstructions
>             add 1 to char -1 of tInstructions
>             break
>          case the backgroundcolor of button ("b" & i) is "0,0,255"
>             if tInstructions is empty then put "B0" into tInstructions
>             if char -2 of tInstructions is not "B" then put comma & "B0"
> after tInstructions
>             add 1 to char -1 of tInstructions
>             break
>          default
>             if tInstructions is empty then
>                put "E" into tInstructions
>             else
>                put comma & "E" after tInstructions
>             end if
>       end switch
>    end repeat
>
>    put tInstructions
> end mouseup
>
> On Mon, Mar 5, 2018 at 8:28 AM, William de Smet via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>
> > Hi Mike,
> >
> > Thanks for your answer!
> > The exercises are actually binary exercises but the children don't know.
> > All they know is a 'puzzle' to solve with pixelcoloring.
> > Funny I can solve it this way :-)
> > Still figuring how to do it because the children instruction is not just
> > binary writing as you explained it.
> >
> > Did you see my picture?
> > http://www.camelcaps.nl/pixelcoding/pixelcoding.jpg
> >
> >
> > greetings.
> >
> > William
> >
> >
> >
> > 2018-03-05 16:10 GMT+01:00 Mike Bonner via use-livecode <
> > use-livecode at lists.runrev.com>:
> >
> > > If you want to know which "pixel" is on in a row, you could treat them
> as
> > > binary bits.  Farthest right in a row is bit 1, next to the left is bit
> > 2..
> > >
> > > So your buttons could be   0   0   1   0   1   0  1
> > >                                           64 32 16  8   4   2   1
> > > for a total of 21 which would then tell you the "bit patteren" of your
> > row.
> > >
> > > Not fully awake yet, so if there is anything wrong with my example,
> > > hopefully it still makes sense.
> > >
> > > On Mon, Mar 5, 2018 at 5:50 AM, William de Smet via use-livecode <
> > > use-livecode at lists.runrev.com> wrote:
> > >
> > > > Thanks for your reply!
> > > > Your app is the same as what I did before and that's quit easy to do.
> > > >
> > > > For now I want to build instruction cards based upon a pixel drawing.
> > > > First you makel your drawing and then it gives you your instruction
> > card.
> > > > The other way around.
> > > >
> > > > My question is how to do that?
> > > >
> > > >
> > > >
> > > > groeten,
> > > >
> > > > William
> > > >
> > > >
> > > >
> > > > 2018-03-05 13:40 GMT+01:00 Jose Enrique Montero via use-livecode <
> > > > use-livecode at lists.runrev.com>:
> > > >
> > > > > I made a similar application, you can look,
> > > > > https://play.google.com/store/apps/details?id=com.kaikuse.
> > > babygrid&hl=es
> > > > >
> > > > > best regards
> > > > >
> > > > >
> > > > > 2018-03-05 3:55 GMT-04:00 William de Smet via use-livecode <
> > > > > use-livecode at lists.runrev.com>:
> > > > >
> > > > > > Hi there,
> > > > > >
> > > > > > This is quite a challenge for me.
> > > > > > I an trying to build a template in which users (small children)
> can
> > > > > > 'pixeldraw' something and based on the drawing the instruction
> will
> > > be
> > > > > > made.
> > > > > > The instruction is needed for other children to make the pixel
> > > drawing.
> > > > > > The instruction is quite special.
> > > > > >
> > > > > > The template is a square with 49 buttons (7x7) for the coloring
> and
> > > 49
> > > > > > fields for the instruction.
> > > > > > The coloring of the buttons is no problem. The 'reverse' coloring
> > is
> > > > the
> > > > > > problem.
> > > > > > I can get the amount of a colors in a row (5 x white and 2 x
> blue)
> > > but
> > > > > how
> > > > > > do I determine on which place (in which buttons) these colors
> are.
> > > > > > The first row is: 3 white - 1 blue - 2 white - 1 blue
> > > > > > But how do I output it like: 3 - 1- 2 - 1 ? And each number needs
> > to
> > > be
> > > > > in
> > > > > > another field.
> > > > > >
> > > > > > ---------------
> > > > > > on mouseup
> > > > > > if the backgroundcolor of btn "f1" is 255,255,255 then add "1" to
> > > field
> > > > > > "v1"
> > > > > > end mouseup
> > > > > >
> > > > > > or
> > > > > >
> > > > > > on mouseup
> > > > > > repeat with x=1 to 7
> > > > > > put "f"&x into tButton
> > > > > > if the backgroundcolor of btn tButton is 255,255,255
> > > > > > then
> > > > > > add "1" to field "v1"
> > > > > > else
> > > > > > add "1" to field "v2"
> > > > > > end if
> > > > > > end mousep
> > > > > >
> > > > > > -------------------
> > > > > >
> > > > > > What is the best way to do this?
> > > > > >
> > > > > > Any pointers are welcome.
> > > > > >
> > > > > >
> > > > > > To easier understand what i am trying to do, see this image:
> > > > > > http://www.camelcaps.nl/pixelcoding/pixelcoding.jpg
> > > > > >
> > > > > >
> > > > > >
> > > > > > greetings,
> > > > > >
> > > > > > William
> > > > > > _______________________________________________
> > > > > > use-livecode mailing list
> > > > > > use-livecode at lists.runrev.com
> > > > > > Please visit this url to subscribe, unsubscribe and manage your
> > > > > > subscription preferences:
> > > > > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > > > > >
> > > > > _______________________________________________
> > > > > use-livecode mailing list
> > > > > use-livecode at lists.runrev.com
> > > > > Please visit this url to subscribe, unsubscribe and manage your
> > > > > subscription preferences:
> > > > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > > > >
> > > > _______________________________________________
> > > > use-livecode mailing list
> > > > use-livecode at lists.runrev.com
> > > > Please visit this url to subscribe, unsubscribe and manage your
> > > > subscription preferences:
> > > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > > >
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list