Page 1 of 1
What does step do? Also, changing single pixel colors?
Posted: Fri Jan 08, 2016 4:00 pm
by Josh1910
Hi,
I'm trying to use a stack to change individual pixel colors (surprising challenge with LiveCode). Anyway, one stack that I'm experimenting with has a word "step" in the repeat loop "repeat with i = 1 to tLength step 4".
My silly question is what is step doing? It's not in help or the dictionary. Is it jumping by 4 steps at a time?
Secondary, if someone happens to know how to change a pixel color (I'm trying to sprinkle black pixels on a white square), that'd be great.
Josh
Re: What does step do? Also, changing single pixel colors?
Posted: Fri Jan 08, 2016 4:26 pm
by Martin Koob
Hi
Yes it is jumping through every 4th value in the range you specify in step.
Put the following on a button and put a field on the card and try this.
Code: Select all
on mouseUp
repeat with i = 1 to 100 step 4
put i & CR after tList
end repeat
put tList into field 1
end mouseUp
You can also step backwards by giving a negative value for step.
Code: Select all
on mouseUp
repeat with i = 100 to 1 step -4
put i & CR after tList
end repeat
put tList into field 1
end mouseUp
Not sure how to change a pixel colour though.
Martin Koob
Re: What does step do? Also, changing single pixel colors?
Posted: Fri Jan 08, 2016 4:34 pm
by Martin Koob
I just had a song pop into my head....
+ goes add
- goes subtract
repeat goes around and around again
mouseDown goes Cli..
mouseUp goes ..ick
return goes back
breakpoint goes stop so you can see what wrong
put goes in
so does set
but what I don't know is....
What does the step do?
Ring a ding ding ding a ding ding a ding
etc......
Maybe Jacque can add LiveCode songs to her LiveCode poetry page....
Martin
Re: What does step do? Also, changing single pixel colors?
Posted: Fri Jan 08, 2016 5:03 pm
by dunbarx
Hi.
I could answer this, but would rather have you go to the dictionary for "repeat" and look through the comments near the "with" loopForm.
The mouseColor returns the color of the current pixel. You want to set that pixelColor? You cannot set, say, the color of a single pixel on a card. The various colors of features of controls can be set, but you would have to have a rectangle graphic of 1x1 and set its backColor or maybe the borderColor.
Craig Newman
Re: What does step do? Also, changing single pixel colors?
Posted: Sat Jan 09, 2016 6:19 pm
by jacque
You can manipulate image pixels in all sorts of ways, so if the square is a white image this lesson may give you some ideas:
http://lessons.livecode.com/m/4071/l/126613
There are some other lessons on image processing too, you could try a search through the lessons.
@Martin: I didn't think anyone ever found my personal experimental pages.

Re: What does step do? Also, changing single pixel colors?
Posted: Sat Jan 09, 2016 8:00 pm
by FourthWorld
This thread contains some super-wonderful image manipulation tools:
http://forums.livecode.com/viewtopic.php?f=10&t=9490
Re: What does step do? Also, changing single pixel colors?
Posted: Sat Jan 09, 2016 10:01 pm
by Martin Koob
jacque wrote:
@Martin: I didn't think anyone ever found my personal experimental pages.

@jacque: I had lost the bookmark but with a few google searches I found it. 'LiveCode Haiku Jacque' does the trick.
http://www.jacque.on-rev.com
As far as the song I had just listened to this 'What does the fox say' parody so the tune was going through my head when I read the post.
https://www.youtube.com/watch?v=aEi_4Cyx4Uw
I thought to promote the release of LiveCode 8 it would make a great youTube video. "What does the step do?"
It could be an open source project. People could contribute more lyrics. Someone could host it on git hub, track revisions. I am sure there are a few musicians and singers in the community. And of course the dance moves would be done by Kevin and the LiveCode HQ engineers and staff, in kilts of course, stepping out, up and down the Royal Mile in Edinburgh. If that doesn't go viral what will?
Martin