Share your opinion
Library
-
![Unfold Unfold](inc/img/general/plus.gif) Gambas Literature
|
DRAWAREA - Mathematic curve
TRACER DES COURBES MATHEMATIQUES
Sorry French only...
![courbemath.png](img/drawarea/courbemath.png)
Dans cet exemple tiré d'une discussion sur le forum Gambas linux en francais, nous allons réaliser le tracé d'une fonction mathématique dans une Drawarea.
Il faut dans votre application :
- une listbox
- une drawarea avec le nom : aire, la propriété CACHED à TRUE
- un bouton QUITTER
Voici le code de l'application :
' gambas class File
PUBLIC SUB _new()
END
PUBLIC SUB form_OPEN()
me.center
dessin
END
PUBLIC SUB button1_click()
me.CLOSE
END
PUBLIC SUB dessin()
DIM incoy1 AS Float, incox1 AS Float, a AS Float = 2, b AS Float = 5, c AS Float = 3
DIM incoy2 AS Float, incox2 AS Float
DIM unit AS Float = aire.w / 100000 'pour faire varier la courbe entre x et y autrement on voit rien
aire.clear
draw.begin(aire)
FOR incox1 = 0 TO 400 step 10
incoy1 = (a * (incox1 ^ 2)) + (b * incox1) + c
listbox1.add("y= " & incoy1 & " pour une valeur de x de " & incox1)
' incoy1 = incoy1 / 100
print incoy1
draw.forecolor = &hff0000&
'draw.forecolor = color.red
draw.LINE(incox1, incoy1 * unit, incox2, incoy2 * unit) 'y croit tellement vite que ce n'est pas sa valeur qui sert.....
incox2 = incox1
incoy2 = incoy1
NEXT
draw.END
END
|
Creation date : 24/02/2010 @ 10:34
Last update : 27/01/2012 @ 22:21
Category : DRAWAREA
Page read 6000 times
Print the article
![react.gif](inc/img/icons/ico_1/react.gif) Reactions to this article
Reaction #1 |
by jeanpierre
17/09/2010 @ 19:39 |
Salut bonjour, la courbe se définie quand la boucle est épuisée, mais comment faire pour rafraichir l'image après chaque tour? D'avance merci, je cherche à construire un programme de sismographe, et comme je débute, il faut apprendre pas à pas !
|
| QUICK MENU
SEARCH
Where, who?
VISITS
|