What does step do? Also, changing single pixel colors?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Josh1910
Posts: 19
Joined: Tue Jan 20, 2015 7:30 am

What does step do? Also, changing single pixel colors?

Post by Josh1910 » Fri Jan 08, 2016 4:00 pm

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

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: What does step do? Also, changing single pixel colors?

Post by Martin Koob » Fri Jan 08, 2016 4:26 pm

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

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: What does step do? Also, changing single pixel colors?

Post by Martin Koob » Fri Jan 08, 2016 4:34 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: What does step do? Also, changing single pixel colors?

Post by dunbarx » Fri Jan 08, 2016 5:03 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: What does step do? Also, changing single pixel colors?

Post by jacque » Sat Jan 09, 2016 6:19 pm

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. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: What does step do? Also, changing single pixel colors?

Post by FourthWorld » Sat Jan 09, 2016 8:00 pm

This thread contains some super-wonderful image manipulation tools:
http://forums.livecode.com/viewtopic.php?f=10&t=9490
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: What does step do? Also, changing single pixel colors?

Post by Martin Koob » Sat Jan 09, 2016 10:01 pm

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? :D

Martin

Post Reply