Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,252 Programmers. There are 2,121 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

How to Understand this function?

 
Reply to this topicStart new topic

How to Understand this function?, Using API

KimJ.
post 20 Apr, 2008 - 03:39 PM
Post #1


New D.I.C Head

*
Joined: 20 Apr, 2008
Posts: 4



I am not understanding how to control the position of two lines with one variable. Or whether I am doing this correctly..

I writing the code as
line(25,25,75,46);
line(25,25,84,90);

If we use one Variable is it Keeping the X coordinate the same, and changing the Y value only? Thanks=)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Martyr2
post 20 Apr, 2008 - 04:36 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 3,561

It might help if you actually tell us what language you are using and what API you are talking about. There are only hundreds of languages and thousands of APIs in the world so maybe we should know, but I think it would save us a little time here. wink2.gif

This post has been edited by Martyr2: 20 Apr, 2008 - 04:37 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

KimJ.
post 20 Apr, 2008 - 05:20 PM
Post #3


New D.I.C Head

*
Joined: 20 Apr, 2008
Posts: 4

I have no I idea what kind of language I am using but the reference that my teach gave me is here

www.processing.org/reference
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

KimJ.
post 20 Apr, 2008 - 05:36 PM
Post #4


New D.I.C Head

*
Joined: 20 Apr, 2008
Posts: 4

I'm sorry my teacher didn't explain what kind of APi we were using at all=(
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

PsychoCoder
post 20 Apr, 2008 - 05:44 PM
Post #5


ToCode || !ToCode

Group Icon
Joined: 26 Jul, 2007
Posts: 5,857

It's an open source language called Processing designed for images & graphics
User is online!Profile CardPM
Go to the top of the page
+Quote Post

Martyr2
post 20 Apr, 2008 - 05:49 PM
Post #6


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 3,561

Well the language is called "processing" and it appears to be a simplistic form of other programming languages out there like c++ or java. From what I can see here of the reference material you are writing it correctly, but remember that each of those lines you wrote are called "functions" and they are not variables. You give it data called parameters which tell the function what to do. In this case draw a line.

The first two parameters are the X and Y coordinates of one point of the line (the beginning) and the third/fourth parameters are the X and Y of second point. Think of it like on a cartesian plane... you know the whole graph paper sort of grid with a X and Y axis.

So your two function calls are going to draw two separate lines. If you want the lines to meet or intersect you are just going to have to do so. As the example on the reference pages you gave me shows, you could essentially make a box like...

CODE

line(30, 20, 85, 20); <-- Here is the line for the top
line(85, 20, 85, 75); <-- Here is the line for the right side
line(85, 75, 30, 75); <-- Here is the line for the bottom
line(30, 75, 30, 20); <-- Here is the line for the left side


Now if you take a look at the four function calls you will notice that many of the coordinates for point 2 (parameters 3 and 4) are the starting point (parameters 1 and 2) of the next function call. This means that one line is starting where the last line left off.

Now if you are having trouble understanding this or trying to do something with one function, perhaps you can show us what you mean with an example of what you want done and how you are trying to do it.

smile.gif

This post has been edited by Martyr2: 20 Apr, 2008 - 05:52 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

KimJ.
post 20 Apr, 2008 - 06:12 PM
Post #7


New D.I.C Head

*
Joined: 20 Apr, 2008
Posts: 4

I understand now, thank you for explaining that better to me you guys. I appreciate it=)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 09:05AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month