We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
beginner part 2 (Read 1164 times)
beginner part 2
Aug 13th, 2009, 2:18am
 
i am trying to add a picture to a project (?).
Should be simple right, but is rather frustrating.
I put the following line of code in the editor (taken from get started tutorial):

PImage image = loadImage("MYIMAGE.jpg");

And everytime i run it, it shows me a small lite grey box with nothing in it.
I expect to see my image.
So please tell me if i am doing something wrong.

thx

l.
Re: beginner part 2
Reply #1 - Aug 13th, 2009, 2:31am
 
loadImage() does what it says on the tin:  it loads the image into memory.  It doesn't display it; that's what image() is for...
Re: beginner part 2
Reply #2 - Aug 13th, 2009, 4:36am
 
i tried that.
Doesnt work either.
it displays a very small box, which is part of my image.
now, i tried to put size (600,791); , which is the size of the actual image and voila now it works.
Just to let you know.
You have to write that in your description, otherwise one gets really frustrated. Cause I tried very often with different variations.
Is there any source to learn the basics of this language.

thank you very much

l.
Re: beginner part 2
Reply #3 - Aug 13th, 2009, 4:58am
 
Ortiz wrote on Aug 13th, 2009, 4:36am:
i tried that.
Doesnt work either.


No - it does work: without image() the image wouldn't be displayed, but I'll admit I'd overlooked that you hadn't got past the basics of setting the window size...

Ortiz wrote on Aug 13th, 2009, 4:36am:
Is there any source to learn the basics of this language.


Have you tried the Learning link at the top of the page  Seems like a fairly obvious place to start to me...  You'll find information on setting the size of the window in the getting started tutorial, and also this useful piece of information (which is often overlooked):

"The size() function must always be the first line inside setup()."
Re: beginner part 2
Reply #4 - Aug 13th, 2009, 6:42am
 
From your question above, it sounds as if you're not ready for images yet. As with any programming language, you can only get so far when you don't know the basics. You really need to start at the very beginning with the basic line tutorial and go from there. I've found the tutorials on this site to be some of the best on the planet for learning a new language, and I constantly find myself wishing other languages had the same community and help sections as Processing.

So please, before you start posting threads bashing the quality of the work of this site and this project (which was done all for free, so you could even learn this stuff,  mind you), please take the time to learn it right and start from the beginning.
Re: beginner part 2
Reply #5 - Aug 14th, 2009, 12:27am
 
Ok.

1. I absolutley agree with you. This is the best documentation to learn a new prgramming language I encountered aswell. I thought about learning a couple of times and this is the first I tried. So please see all my comment on this background and absolute appreciation of what has been accomplished yet by all of you. I am truly grateful for that.

2. I did the line tutorials. I did all the get started tutorials. And i admit that I overlooked things. Shame on me.

Ok so on the basis of this, you might allow me to tell you what I did and what i fund very frustrating.

E.g.
Yesterday, I downloaded processing code, as I believe that this is the best way to learn. See how actual code is working and change parameters. All of these did not work. Processing said it is old code and showed me what i have to change (e.g. push() becomes pushMatrix). Plus it showed me the menu option Fix encoding and reload. Did not work aswell (grey window)

One of the files i dwnloaded was the radiohead video.

So I know I have to start from the beginning. I did that. But then you want to move on. And it seems everytime I change code (well not everytime, I successfully changed and runed code aswell), it seems it is not running anymore for mysteroius reasons.

And I dont understand why. All this to explain you that I in no way want to bash your software, but would love to understand it to use it.

And thats why I would be super grateful. If you could tell me where I can find a package of all the stuff I need for this prgram to run flawless.

Without telling me: "code old or need renderer" etc. The interesting thing is that the code working online, but it wont work on my computer.

Maybe it is Mac problem. Maybe I need extra software I dont know of.
So any help in this direction would be really really great.

Thanks for the hard work and your time and attention..

l.
Re: beginner part 2
Reply #6 - Aug 14th, 2009, 4:51am
 
We don't live in an ideal world so you shouldn't have unrealistic expectations - i.e. to download someone else's code and expect it to run just like that.  Different operating systems may be a factor; however the main thing to look out for is the fact that Processing is extensible through the use of additional libraries.  If you don't have these installed on your machine the code won't run.  It's as simple as that.  (And be warned that libraries may be OS dependent.)

TBH if this is your first programming language and you're only just getting started you're not ready to work with complex code involving external libraries.  Wait till you've got to the point when you can import and use libraries in your own code first.

Ortiz wrote on Aug 14th, 2009, 12:27am:
So I know I have to start from the beginning. I did that. But then you want to move on. And it seems everytime I change code (well not everytime, I successfully changed and runed code aswell), it seems it is not running anymore for mysteroius reasons.


The reasons may seem mysterious at this point, but once you've properly got to grips with the basics you should gain a better understanding of the error messages you get.

If you're serious about learning Processing my suggestion is to invest in one of the several excellent books available.  The basic concepts you learn will be transferable to other languages too and vice-versa - I often use Actionscript books for reference when working in Processing...
Re: beginner part 2
Reply #7 - Aug 14th, 2009, 7:19am
 
I'd like to build off of blindfish's comment.

I'm not sure what the "radiohead video" is, but I'm hoping you're not talking about the Robert Hodgin piece, because that is definitely nowhere to start when you're just learning the language. Robert uses a lot of different libraries, and he also programs a lot in straight up OpenGL, so his code is really no place for a beginner.

I think your approach of modifying existing code is a good one. I just think you need to start smaller. For instance, when I was learning Processing, I went through the dozens of example files that CAME WITH THE SOFTWARE, and just messed with them, modifying and expanding them. My projects folder is filled to the brim with little experiments and studies that are simply expansions of simple example files. I suggest you start by doing that. Also, I was going through the developers' book, "Processing: A Programming Handbook for Visual Designers and Artists" at the same time. I suggest you do the same.
Re: beginner part 2
Reply #8 - Aug 14th, 2009, 11:03am
 
Thanks a lot.

I was trying to find examples, because in my processing 1.0 the "examples" are greyed out (under File-Examples). I believe to have read somewhere that this was an issue with apple/mac. So I was looking for code online. I found the radiohead one here:

http://code.google.com/p/radiohead/downloads/list

and the other examples here:

http://processing.unlekker.net/

the second one maybe more fitting for my skills. maybe not. But simpler than radiohead.

I tried to compile(?)/run the .pde files of the sond source.
All of them had something that didnt work.
e.g.
push() had to become pushMatrix()
I change that everywhere processing showed me i had to change that.
The same with pop()- popMatrix().

Then processing would run the code an the result was a grey box.
I didnt understand what could be wrong.
And then I found the "Fix Encoding&Reload" Button, which I believe would Autofix the old code and bring it up to date.
But that didnt fix the problem either.

Then I worked my way through the reference.
The Reference section has all the pieces of code to every example and I put them in the editor window and hit run.
Some of them work.
Some did not. Which was confusing, because I thought they where there to be examples (i posted about that and blindfish was so nice to tell me what went wrong, I still have to understand that).

AND very intersting: I put pieces of code in the same sketch window and hit run. Then I delete it and put the next code in and hit run again. Then after a while the code wont work. Then I accidently closed the whole program and opened it again. made a new sketch. Put the SAME code in and it would work. I really dont understand that. Is there something you have to pay attention? Stuff like that would be super super nice to have in a beginner section (and again, I really like the reference and find it super nice already, I just want to make it easier and less frustrating for future users to learn, and learn fast).

AND very important from my BEGINNER point of view, the reference is awesome when you know how to program already, but for beginner beginners like me, i need to understand the simple questions/overview:

e.g. when I start I have to put size() first.
What do the error message mean?
What does Void mean (in void setup)?
What are the basic blocks (setup, draw, other ???) of the code.
What are stupid errors that one overlooks easy (e.g. forget the semicolon, other ??)?
Does the order in which i write code matter, and if so what order do I have to make it work ?
How can I make one rectangle, circle, line and then multiply it by n.
How can I make easy and fast some examples that are cooler and more rewarding than a simple line (e.g. fractals in my case)?
And so on..

So, all this to ask you: Do you know where i can find examples that help me with this? Examples that work with the standard downloaded program (no extra libraries, or extra libraries if you tell me where I can find them)

Thanks a million for your attention..

l.
Re: beginner part 2
Reply #9 - Aug 14th, 2009, 3:46pm
 
* What do the error message mean?
- They mean what they say - you just have to learn how to interpret them

* What does Void mean (in void setup)?
- Any function has to start by declaring its return value.  Void simply means the function doesn't return a value.  That might not mean a lot to you at this point.

* What are the basic blocks (setup, draw, other ???) of the code.
- This suggests to me that you haven't bothered reading the Getting Started tutorial properly.  See:

"The setup() block runs once, and the draw() block runs repeatedly. As such, setup() can be used for any initialization; in this case, setting the screen size, making the background orange, and setting the stroke color to white. The draw() block is used to handle animation. The size() function must always be the first line inside setup()."

* What are stupid errors that one overlooks easy
- General typos, missing semi-colons, not closing brackets.  You'll learn to avoid these soon enough.  Another useful tip.  The editor colour-codes keywords (i.e. built-in functions or properties).  If the text isn't coloured then it's either mis-typed or a variable/object that you have created.

* Does the order in which i write code matter
- Yes

* and if so what order do I have to make it work ?
- Whatever order you need it to work.  Generally the code runs in the order it is typed.  The first line will happen before the second and so on.  This is important when you draw things to the screen: the last thing drawn will be on the top of anything drawn before...

* How can I make one rectangle, circle, line and then multiply it by n.
- Use a loop.

* How can I make easy and fast some examples that are cooler and more rewarding than a simple line (e.g. fractals in my case)?
And so on..
- Buy a book

* So, all this to ask you: Do you know where i can find examples that help me with this? Examples that work with the standard downloaded program (no extra libraries, or extra libraries if you tell me where I can find them)
- Yes: in a book...  Hopefully you're getting the message by this point: the best place to look for what you need is in something designed specifically to teach beginners how to program with Processing.  Ira Greenberg's is pretty good for beginners...  If you're desperate to look at code then you could check the sites associated with the books and download any available example code, though this will be most useful if you have the book at hand to explain it...
Re: beginner part 2
Reply #10 - Aug 14th, 2009, 3:58pm
 
Ortiz wrote on Aug 14th, 2009, 11:03am:
I was trying to find examples, because in my processing 1.0 the "examples" are greyed out (under File-Examples). I believe to have read somewhere that this was an issue with apple/mac.

And like that error message says, you can always access the examples from the toolbar, instead of the menu.
Re: beginner part 2
Reply #11 - Aug 15th, 2009, 12:36am
 
Ok. thanks for everything.
This really helped me.
I will try to get that book.

Ad Get started tutorial: I read the get started tutorial carefully.
I just wanted to know if there is any OTHER important block BESIDES setup and draw, that could be important. like a loop block or multiply block...

ad Toolbar: Wow! that was so what i was looking for. Thanks a million!!!
Kind of confusing that it is hidden in the open button.
So for every processing 1.0 beginner beginner who uses a MAC like me and reads this post.
All you need is hit the open button and there is a lot of examples in there. START THERE.

Thanks again

l.
Page Index Toggle Pages: 1