Page 1 sur 2

Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 9:48
par Guillot
Ci dessous les image de la manif

PS: les explications dans les posts suivants

Code : Tout sélectionner

; manif - pf shadoko - 2017

EnableExplicit

Procedure ColorBlend(color1.l, color2.l, blend.f=0.5)
    Protected r.w,g.w,b.w,a.w
    r=  Red(color1) + (Red(color2)     - Red(color1)) * blend
    g=Green(color1) + (Green(color2) - Green(color1)) * blend
    b= Blue(color1) + (Blue(color2) -   Blue(color1)) * blend
    a=Alpha(color1) + (Alpha(color2) - Alpha(color1)) * blend
    ProcedureReturn  RGBA(r,g,b,a)
EndProcedure
;=======================================================================================

Structure spancarte
    ok.b
    bcolor.l
    fcolor.l
    slogan.s
EndStructure

Structure smanif
    x.f
    y.f
    z.f
    v.f
    pf.f
    pancarte.spancarte
EndStructure

Global nm=255,ns=6
Global Dim manif.smanif(nm)
Global Dim slogan.s(ns)

slogan(0)=~"Conversion automatique\ndes anciens codes"
slogan(1)=~"LES 'DECLARE'\nY'EN A MARRE !!!"
slogan(2)=~"InitMouse\nInitKeyboard\nInitSprite\nInit...\non en veut plus !"
slogan(3)=~"BYVAL / BYREF"
slogan(4)=~"Les énumérations\ncomme type\nde variable"
slogan(5)=~"Les procedures aussi\nont besoin des types:\nTableau\nListe\nMap\n et Structure !"
slogan(6)=~"DES VARIABLES\n POUR LES 'STEP'"

Procedure initmanif(i,z=100)
    With manif(i)
        \x=Random(400)-200
        \y=Random(20)
        \z=z
        \v=(Random(10)+50)/400
        \pf=Random(200,100)/1000
    EndWith
    With manif(i)\pancarte
        \ok=Bool(Random(32)=0)
        \bcolor=$ff<<24|Random($ffffff)
        \fcolor=$ff<<24|Random($ffffff)
        \slogan=slogan(Random(ns))
    EndWith
EndProcedure

Procedure affiche()
    Static c=1111:c+1
    Protected i,g.f,x.f,y.f,dx,dy
    StartVectorDrawing(CanvasVectorOutput(0))
    VectorFont(FontID(0),10)
    VectorSourceLinearGradient(0,0,0,600)
    VectorSourceGradientColor($ffffaaaa, 0.0)
    VectorSourceGradientColor($ffffaaaa, 0.5)
    VectorSourceGradientColor($ff888888, 1.0)
    FillVectorOutput()
    SortStructuredArray(manif(),#PB_Sort_Descending,OffsetOf(smanif\z), TypeOf(smanif\z))
    For i=0 To nm
        With manif(i)
            g=80/\z
            ResetCoordinates()
            TranslateCoordinates(400,300)
            ScaleCoordinates(g,g)
            x=\x
            y=-(\y-50+4*Abs(Sin(c*\pf)))
            If \pancarte\ok
                RotateCoordinates(x,y,5*Sin(c*\pf))
                dx= VectorTextWidth(\pancarte\slogan)+10
                dy= VectorTextHeight(\pancarte\slogan)+10
                AddPathBox(x-3,y-dy-70,  6,dy+100) 
                VectorSourceColor(ColorBlend($ff88aaaa,$ffffaaaa,\z/100))
                FillPath()
                AddPathBox(x-dx/2,y-dy-60,  dx,dy) 
                VectorSourceColor(ColorBlend(\pancarte\bcolor,$ffffaaaa,\z/100))
                FillPath()
                MovePathCursor(x-dx/2,y-dy-60+5)
                VectorSourceColor(ColorBlend(\pancarte\fcolor,$ffffaaaa,\z/100))
                DrawVectorParagraph(\pancarte\slogan,dx,dy,#PB_VectorParagraph_Center)
            EndIf
            x-20
            AddPathCircle(x,y, 20)
            VectorSourceColor(ColorBlend($ff888888,$ffffaaaa,\z/100))
            FillPath()
            \z-\v:If \z<1:initmanif(i):EndIf
        EndWith
    Next    
    StopVectorDrawing()
EndProcedure

Define i
OpenWindow(0, 0, 0, 800,600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0,0,0,800,600)
LoadFont(0, "Comic Sans MS", 10)

For i=0 To nm
initmanif(i,Random(100,10))
Next
AddWindowTimer(0, 0, 20):BindEvent(#PB_Event_Timer, @ affiche())

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 9:53
par Micoute
Merci professeur Shadoko pour ce partage, j'ai bien aimé ce clin d'œil.

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 10:50
par Zorro
Excellent !! :D

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 11:58
par Torp
Ah Ah TERRIBLE !

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 12:31
par TazNormand
Ah oui, je plussoie : Excellent !!!

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 12:37
par SPH
Nial :mrgreen:

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 12:38
par JohnJohnsonSHERMAN
Génial :) :mrgreen: Et tellement vrai pour le STEP sans VARIABLE.... :(

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 13:26
par Patrick88
pas vu kcc avec sa pancarte : lecture des animations GIF en natif ... :roll:

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 13:48
par Marc56
Amusant pour l'idée et impressionnant par la petite taille du code. :P
118 lignes! quel langage moderne permet d'en faire autant ? 8O (aucun)
Chapeau pour la technique pf shadoko.

Cela dit, certaines revendications comme "supprimer les declare" pourraient se concevoir je pense, mais cela suppose que le compilateur fasse un premier passage pour lister toutes les procédures. Donc potentiellement plusieurs secondes à chaque compilation si le code devient volumineux ?

:wink:

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 14:18
par majikeyric
C'est juste NAZE ! :)

Re: Journée mondial pour la modernisation de PB

Publié : ven. 20/janv./2017 22:56
par venom
Le rendu est top, bravo 8)






@++

Re: Journée mondial pour la modernisation de PB

Publié : sam. 21/janv./2017 0:22
par Ar-S
Je me joins à tes revendications et te félicite au passage pour le code qui m'a bien fait marrer. :P

Re: Journée mondiale pour la modernisation de PB

Publié : sam. 21/janv./2017 3:14
par Huitbit
Superbe !
Y a pas une manif prévue pour Android Studio :mrgreen: !!!?

Re: Journée mondial pour la modernisation de PB

Publié : sam. 21/janv./2017 13:33
par ChrisR
Génial :D
Qui se lance dans une contre manif. 118 lignes de code a battre :wink:

Re: Journée mondial pour la modernisation de PB

Publié : dim. 22/janv./2017 15:12
par Cool Dji
Magnifique, bravo pour le code !