Forum Liberty Basic France

Projets open source » Mini Editeur de schémas de mailles Permet d'éditer des séquences de tricotage
Le 14/08/2020 à 18h06

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
Hello à Tous,
C'est un mini éditeur de schémas de mailles simple et très limité.
C'est le principe que j'ai voulu faire.
Il peut être largement amélioré.
Je n'ai pas trouvé d'autre manière de le faire graphiquement.
Ni lorsqu'on maintien le bouton gauche d'insérer la maille en continu.
Au départ je cherchais un éditeur de font pour faire une police de caractères, et au lieu de caractères, taper des mailles, changer à bien plaire, et mettre du texte sur une feuille Word par exemple.
C'est pourquoi je suis curieux de voir l'éditeur de fonts de Joan74.

MiniStitchEditor.zip
____________________
Castel

   
Le 14/08/2020 à 19h10

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Fichtre !! Pourquoi autant de graphicbox ? Y a quand même plus simple pour contraindre le placement de bmp.
Joan 74 a fait avec des sprites (dont on fait ce qu'on veut au niveau du placement; comme les bmp).
C'était quoi le but ? (si tu veux bien développer).
A part ça, tu aurais dû mettre le dossier "STMailles" et le fichier ".bas" ensembles dans un dossier: "Castel-Mailles" (parce qu'en fonction de la méthode d'organisation dans la page (alphabétique ou autre...) et du nombre de dossiers et fichiers. "STMailles" peut se retrouver loin du fichier ".bas", ce qui n'est pas très cohérent

Il y a ça:
Code VB :
 
    nomainwin
    open "Snap to Grid" for graphics_nsb as #m
    #m "trapclose [quit.m]"
    #m "home"
    #m "posxy CenterX CenterY"
    BoxWidth = CenterX * 2
    BoxHeight = CenterY * 2
    #m "down"
    for x = 50 to BoxWidth step 50
        #m JBline$(x, 0, x, BoxHeight)
    next
    for y = 50 to BoxHeight step 50
        #m JBline$(0, y, BoxWidth, y)
    next
    #m "flush"
    #m "when mouseMove [CheckSnap]"
    #m "setfocus"
    #m "size 40"
    #m "color red"
    #m "rule xor"
    OldPosX = -25
    OldPosY = -25
    wait
[CheckSnap]
    GridBoxX = int(MouseX / 50) + 1
    GridBoxY = int(MouseY / 50) + 1
    PosX = GridBoxX * 50 - 25
    PosY = GridBoxY * 50 - 25
    if PosX <> OldPosX or PosY <> OldPosY then
        #m "discard"
        #m JBset$(PosX, PosY)
        #m JBset$(OldPosX, OldPosY)
        OldPosX = PosX
        OldPosY = PosY
    end if
    wait
[quit.m]
    close #m
    end
function JBline$(StartX, StartY, EndX, EndY)
    ' wrapper function for the graphics line method
    JBline$ = "line "; StartX; " "; StartY; " "; EndX; " "; EndY
end function
function JBset$(X, Y)
    ' wrapper function for the graphics set method
    JBset$ = "set "; X; " "; Y
end function
 

-----------------------------
Et ça:
Code VB :
 
nomainwin
    WindowWidth = 460
    WindowHeight = 480
    UpperLeftX = (DisplayWidth-WindowWidth) / 3
    UpperLeftY = 10 '(DisplayHeight-WindowHeight) / 2
    MapWidth = 400
    MapHeight = 400
    dc = 36  'size of a cell in pixels
    ncx = int(MapWidth/dc)  'nb of X cells
    ncy = int(MapHeight/dc) 'nb of Y cells
    dim cell(ncx,ncy)
    statictext #w.txt "",10,12,280,20
    BUTTON #w.grid, "Grid", [grid], UL, WindowWidth-60, 5, 50, 25
    graphicbox #w.map, 5, 40, MapWidth, MapHeight
    graphicbox #w.red, 410, 40, 40, 40
    graphicbox #w.blue, 410, 85, 40, 40
    graphicbox #w.yel, 410, 130, 40, 40
    open "    TEST GRID Coord..." for window_nf as #w  'graphics_nf_nsb
    #w "trapclose [quit]"
    #w.map "down; fill black"
    #w.map "backcolor lightgray; color lightgray"
    #w.map "when mouseMove [coord]"
    #w.map "when leftButtonDown [Mark]"
    #w.red, "down; fill red": #w.blue, "down; fill blue": #w.yel, "down; fill yellow"
    goto [grid]
    wait
    [coord]
        mX = int(MouseX/dc)
        mY = int(MouseY/dc)
        if mX<=ncx and mY<=ncy then
            if oldmX then
                #w.map "rule ";_R2_NOT
                #w.map "place ";oldmX*dc+1;" ";oldmY*dc+1;"; boxfilled ";oldmX*dc+dc-1;" ";oldmY*dc+dc-1
            end if
            oldmX = mX
            oldmY = mY
           ' #w.map "rule ";_R2_COPYPEN
            #w.map "place ";mX*dc+1;" ";mY*dc+1;"; boxfilled ";mX*dc+dc-1;" ";mY*dc+dc-1
        end if
        gosub [infos]
    wait
    [grid]
        grid = grid+1-2*(grid=1) '0 -> 1 -> 0 -> 1 -> 0 etc...
        gosub [DispMap]
    wait
    [Mark]
        #w.map "backcolor red; color red"
        #w.map "place ";mX*dc+1;" ";mY*dc+1;"; boxfilled ";mX*dc+dc-1;" ";mY*dc+dc-1
        #w.map "backcolor lightgray; color lightgray"
    wait
    [infos]
        #w.txt "pixels : ";MouseX;" / ";MouseY;_
        "         Cell ( ";mX;" , ";mY;" )"
    return
    [DispMap]
        gosub [infos]
        if grid then
            #w.map "backcolor lightgray; color lightgray"
        else
            #w.map "backcolor black; color black"
        end if
        for y=1 to ncy
            #w.map "place 0 ";y*dc;"; goto ";MapWidth;" ";y*dc
        next
        for x=1 to ncx
            #w.map "place ";x*dc;" 0; goto ";x*dc;" ";MapHeight
        next
        #w.map "backcolor lightgray; color lightgray"
        #w.map "flush; discard"
    return
    [quit]
        close #w
        end
    wait
 
____________________
Roro

   
Le 14/08/2020 à 20h56

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
Oui, absolument, je suis d’accord sur tout ce que tu as écrit. Tes remarques Confirment que je passe à coté de certains détails importants.
Très prochainement, je m’expliquerais en détails ce que cette application doit faire.
Qui en finalité est très simple.
____________________
Castel

   
Le 14/08/2020 à 21h01

Modérateur

Groupe: Modérateur

Inscrit le: 30/03/2011
Messages: 437
ben meme si ya pleins de graphicbox je trouve le programme tres bien foutu ! c épuré et sans bug =) !
____________________
Yo !

MSN Web    
Le 14/08/2020 à 21h18

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
Merci Atomose
____________________
Castel

   
Le 14/08/2020 à 22h01

Modérateur

Groupe: Modérateur

Inscrit le: 30/03/2011
Messages: 437
le top serait de la faire plus grand (fenetre) avec plus de case dispo =)
ca serait un bon petit logiciel =)
____________________
Yo !

MSN Web    
Le 15/08/2020 à 09h56

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
En effet, ce que j’ai posté est le principe, pour voir si ça fonctionne. Et en même temps, avoir des avis
Sur cet exemple. Par exemple au point de vue graphique dont j’ai très peu d’expérience. Surtout concernant les sprytes avec leurs commandes « roule » .
Apprendre de nouvelles techniques prend du temps.
J’aimerais éviter ces centaines de graphiques box.
Je vais regarder les exemples de Roland.
Bon week-end
____________________
Castel

   
Le 15/08/2020 à 10h27

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Concernant le placement en "grille", il y a aussi ça-->: http://libertybasic.fr/forum/topic-286+plannings.php
____________________
Roro

   
Le 16/08/2020 à 10h27

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
Hello Roland,
But et développement du sujet.
Lorsqu'on veut usiner une pièce mécanique, il faut un dessin technique.
Sur ce dessin, il y aura toutes les informations nécessaires pour réaliser la pièce en question.
On peut comparer un dessin technique à un schéma de mailles dans le domaine
de la machine à main.
Si à l'avenir, on doit reproduire l'article (Pull, Tricot, etc.), la fiche technique donnera toutes les infos.
On peut faire une photo, mais selon la structure de la maille, il est difficile de voir comment c'est fait.
Aujourd'hui on fait, pour ceux et celles qui savent, un schéma de mailles à main levée plus ou moins précis sur un bout de papier. Souvent même, c'est écrit en texte, que l'on doit imaginer et comprendre.
Un schéma de mailles est parlant pour tout le monde de la branche.
L'idée et le but de cette application est de sauvegarder en fichier xxxx.bmp de la zone mailles,
de l'insérer sur une feuille Word ou Excel et d'y ajouter toutes les informations nécessaires pour
en faire une fiche technique, sur une feuille A4.
Avec une capture d'écran j'ai essayé et ça marche plutôt bien.
L'avantage c'est que sur Word ou Excel le bmp peut être plus ou moins zoomé, déplacé sur la feuille
et d'y écrire toute les infos.
Bien sûr qu'aujourd'hui, il existe des logiciels professionnels performants mais ils sont très couteux
et accessibles seulement si on achète une de leurs machines à commande électronique.
Ce que j'aimerais faire serais simple et facile à utiliser et surtout gratuit.
Voilà, je crois m'être expliqué un peu plus.
A+
____________________
Castel

   
Le 16/08/2020 à 11h00

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Ah, comme ça c'est plus clair donc on oublie la machine et ses commandes (quelqu'un a demandé un truc dans ce genre, avec sortie machine) mais n'a pas répondu aux questions et ne donne plus de nouvelles, splendeur et misères du virtuel, que certains prennent pour la foire d'empoigne...).

On peut si tu veux voir ensemble de modifier le "Planning" pour mettre tes mailles à la place des carrés de couleur. (sans garanti car ce truc m'avait donné pas mal de fil à retordre)

Ou partir des deux codes "secs" plus haut (ce qui serait plus sage).
A-tu une machine et si oui, quel est le mode de saisie des commandes ?
____________________
Roro

   
Le 16/08/2020 à 11h03

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Suite: A ce que je comprends, sur l'image il y a le pull-over avec les mailles (comme grossies et schématisées)
Il doit même y a voir moyen d'afficher sur la dernière maille (avant changement) le nombre de mailles concernées par le type de la ligne en question.
On doit aussi pouvoir placer une règle graduée fixe et une mobile.

Il ne manque plus que le compteur de maille (réelles), ou sinon, bonjour l'angoisse... :(
____________________
Roro

   
Le 16/08/2020 à 12h53

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Re Suite:
J'ai fait ça: (à mettre dans un dossier en compagnie de "STMailles")
Code VB :
 
nomainwin
    WindowWidth = 460
    WindowHeight = 480
    UpperLeftX = (DisplayWidth-WindowWidth) / 3
    UpperLeftY = 10 '(DisplayHeight-WindowHeight) / 2
    MapWidth = 400
    MapHeight = 400
    dc = 36  'size of a cell in pixels
    ncx = int(MapWidth/dc)  'nb of X cells
    ncy = int(MapHeight/dc) 'nb of Y cells
    dim cell(ncx,ncy)
    statictext #w.txt "",10,12,280,20
    BUTTON #w.grid, "Grid", [grid], UL, WindowWidth-60, 5, 50, 25
    graphicbox #w.map, 5, 40, MapWidth, MapHeight
    graphicbox #w.comb, 405, 35, 45, 175
    open "    TEST GRID Coord..." for window_nf as #w  'graphics_nf_nsb
    #w "trapclose [quit]"
    #w.map "down; fill black"
    #w.map "backcolor lightgray; color lightgray"
    #w.map "when mouseMove [coord]"
    #w.map "when leftButtonDown [Mark]"
    #w.comb, "down;fill white": #w.comb, "when leftButtonDown [sel]"
   dos$ = "STMailles\Maille": x=5: y=5
   for x=3 to 8
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";x;" ";y
     y=y+50
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
    goto [grid]
    wait
    [coord]
        mX = int(MouseX/dc)
        mY = int(MouseY/dc)
        if mX<=ncx and mY<=ncy then
            if oldmX then
                #w.map "rule ";_R2_NOT
                #w.map "place ";oldmX*dc+1;" ";oldmY*dc+1;"; boxfilled ";oldmX*dc+dc-1;" ";oldmY*dc+dc-1
            end if
            oldmX = mX
            oldmY = mY
           ' #w.map "rule ";_R2_COPYPEN
            #w.map "place ";mX*dc+1;" ";mY*dc+1;"; boxfilled ";mX*dc+dc-1;" ";mY*dc+dc-1
        end if
        gosub [infos]
    wait
    [grid]
        grid = grid+1-2*(grid=1) '0 -> 1 -> 0 -> 1 -> 0 etc...
        gosub [DispMap]
    wait
    [sel]
      bx=MouseX: by=MouseY
      if bx> 5 and bx< 45 and by> 5 and by< 45 then nm=3: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 45 and by> 50 and by< 90 then nm=4: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 45 and by> 100 and by< 140 then nm=5: bmp$="STMailles\Maille"+str$(nm)
  wait
        [Mark]
       loadbmp "image"+str$(x), "STMailles\Maille" +str$(nm)+".bmp"
       xx=mX*dc+1: yy=mY*dc+1
       #w.map, "drawbmp ";"image"+str$(x);" ";xx;" ";yy
     unloadbmp "image"+str$(x)
     #w.map, "flush"
    wait
    [infos]
        #w.txt "pixels : ";MouseX;" / ";MouseY;_
        "         Cell ( ";mX;" , ";mY;" )"
    return
    [DispMap]
        gosub [infos]
        if grid then
            #w.map "backcolor lightgray; color lightgray"
        else
            #w.map "backcolor black; color black"
        end if
        for y=1 to ncy
            #w.map "place 0 ";y*dc;"; goto ";MapWidth;" ";y*dc
        next
        for x=1 to ncx
            #w.map "place ";x*dc;" 0; goto ";x*dc;" ";MapHeight
        next
        #w.map "backcolor lightgray; color lightgray"
        #w.map "flush; discard"
    return
    [quit]
        close #w
        end
    wait
 

Il reste à:
Agrandir la #w.comb
Y placer les bmp avec ta méthode
Ajuster les bx by en faire un select case ou une sub.
Ajuster tailles des cases.
Simplifier l'affichage de la grille
Pour l'instant seules les deux premières mailles sont dispos
____________________
Roro

   
Le 16/08/2020 à 18h29

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
Oui, je suis entièrement d’accord de voir ça ensemble, car j’apprends beaucoup de ce forum et si je le peux, je restitue volontiers mes idées et ce que je fait ... si cela peut profiter à d’autres ... c’est tant mieux, c’est ainsi que je vois ma manière de faire.
J’ai regardé avec attention ton dernier exemple c’est un super début.
J’aurais une remarque concernant la variable dc qui a la valeur de 36.
Pour que les symboles de mailles correspondent il faudrais séparer.
C’est à dire qu’il faudrais dch = 32 pour la hauteur et dcl = 22 pour la largeur afin que les symboles,
Lorsqu’ils sont mis côte à côte correspondent mieux.
Les symboles sont plus hauts que larges.
Merci Roland, je vais essayer d’y travailler dessus.
____________________
Castel

   
Le 16/08/2020 à 20h17

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Les dernières modifs!
Code VB :
 
nomainwin
    WindowWidth = 600: WindowHeight = 480
    UpperLeftX = (DisplayWidth-WindowWidth) / 3
    UpperLeftY = 10 '(DisplayHeight-WindowHeight) / 2
    MapWidth = 400: MapHeight = 400
    dcx = 21: dcy=30  'size of a cell in pixels
   ' ncx = int(MapWidth/dcx)  'nb of X cells
   ' ncy = int(MapHeight/dcy) 'nb of Y cells
    statictext #w.txt "",10,12,280,20
    graphicbox #w.map, 5, 40, MapWidth, MapHeight
    graphicbox #w.comb, 410, 40, 150, 300
    open "    TEST GRID Coord..." for window_nf as #w  'graphics_nf_nsb
    #w "trapclose [quit]"
    #w.map "down; fill white"
    #w.map "backcolor lightgray; color lightgray"
   ' #w.map "when mouseMove [coord]"
    #w.map "when leftButtonDown [Mark]"
    #w.comb, "down;fill lightgray": #w.comb, "when leftButtonDown [sel]"
    #w.comb, "when rightButtonDown [coord]"
   dos$ = "STMailles\Maille": x=5: y=5
   for x=2 to 8
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"5";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     next x
     y=5
   for x=9 to 15
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"35";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
    gosub [grid]
    wait
    [grid]
        #w.map, "color blue"
        for x= 1 to MapWidth step dcx ', MapHeight
          #w.map, "line ";x;" ";"0";" ";x;" ";MapHeight
        next x
        for y= 1 to MapHeight step dcy
          #w.map, "line ";"0";" ";y;" ";MapWidth;" ";y
        next y
        #w.map "flush; discard"
    return
    wait
    [sel]
      bx=MouseX: by=MouseY
      if bx> 5 and bx< 25 and by> 5 and by< 35 then nm=2: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 25 and by> 47 and by< 85 then nm=3: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 25 and by> 86 and by< 126 then nm=4: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 25 and by> 125 and by< 164 then nm=5: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 25 and by> 164 and by< 206 then nm=6: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 25 and by> 206 and by< 246 then nm=7: bmp$="STMailles\Maille"+str$(nm)
      if bx> 5 and bx< 25 and by> 246 and by< 276 then nm=8: bmp$="STMailles\Maille"+str$(nm)
 
      if bx> 35 and bx< 55 and by> 5 and by< 35 then nm=9: bmp$="STMailles\Maille"+str$(nm)
      if bx> 35 and bx< 55 and by> 47 and by< 85 then nm=10: bmp$="STMailles\Maille"+str$(nm)
      if bx> 35 and bx< 55 and by> 86 and by< 126 then nm=11: bmp$="STMailles\Maille"+str$(nm)
      if bx> 35 and bx< 55 and by> 125 and by< 164 then nm=12: bmp$="STMailles\Maille"+str$(nm)
      if bx> 35 and bx< 55 and by> 164 and by< 206 then nm=13: bmp$="STMailles\Maille"+str$(nm)
      if bx> 35 and bx< 55 and by> 206 and by< 246 then nm=14: bmp$="STMailles\Maille"+str$(nm)
      if bx> 35 and bx< 55 and by> 246 and by< 276 then nm=15: bmp$="STMailles\Maille"+str$(nm)
  wait
        [Mark]
         mX = int(MouseX/dcx): mY = int(MouseY/dcy)
       loadbmp "image"+str$(x), "STMailles\Maille" +str$(nm)+".bmp"
       xx=mX*dcx+1: yy=mY*dcy+1
       #w.map, "drawbmp ";"image"+str$(x);" ";xx;" ";yy
     unloadbmp "image"+str$(x)
     #w.map, "flush"
    wait
    [infos]
        #w.txt "pixels : ";MouseX;" / ";MouseY;_
        "         Cell ( ";mX;" , ";mY;" )"
    return
    [DispMap]
        gosub [infos]
        if grid then
            #w.map "backcolor lightgray; color lightgray"
        else
            #w.map "backcolor black; color black"
        end if
        for y=1 to ncy
            #w.map "place 0 ";y*dc;"; goto ";MapWidth;" ";y*dc
        next
        for x=1 to ncx
            #w.map "place ";x*dc;" 0; goto ";x*dc;" ";MapHeight
        next
        #w.map "backcolor lightgray; color lightgray"
        #w.map "flush; discard"
    return
    [coord]
      cx=MouseX: cy=MouseY
      #w.map, "color black;backcolor yellow"
      #w.map, "place ";"100";" ";cy: #w.map, "\x:";cx;"  y:";cy
    wait
    [quit]
        close #w
        end
    wait
 
____________________
Roro

   
Le 17/08/2020 à 01h26

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Et pour éviter des listes de if then:
Code VB :
 
   nomainwin
    WindowWidth = 600: WindowHeight = 480
    UpperLeftX = (DisplayWidth-WindowWidth) / 3
    UpperLeftY = 10 '(DisplayHeight-WindowHeight) / 2
    MapWidth = 400: MapHeight = 400
    dcx = 21: dcy=30  'size of a cell in pixels
   ' statictext #w.txt "",10,12,280,20
    graphicbox #w.map, 5, 40, MapWidth, MapHeight
    graphicbox #w.comb, 410, 40, 150, 300
    open "    TEST GRID Coord..." for window_nf as #w  'graphics_nf_nsb
    #w "trapclose [quit]"
    #w.map "down; fill white"
    #w.map "backcolor lightgray; color lightgray"
    #w.map "when leftButtonDown [Mark]"
    #w.comb, "down;fill lightgray": #w.comb, "when leftButtonDown [sel]"
    #w.comb, "when rightButtonDown [coord]"
   dos$ = "STMailles\Maille"
   x=5: y=5: d=0
   for a=2 to 8
     ax(a)=5: ay(a)=y+d
     d=d+40
   next a
   dim a1x(20): dim a1y(20): d=0
   for a=9 to 15
     a1x(a)=30: a1y(a)=y+d
     d=d+40
   next a
   '--------------------affichage mailles
    x=5: y=5
   for x=2 to 8
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"5";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     next x
   y=5
   for x=9 to 15
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"35";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
    gosub [grid]
    wait
    [grid]
        #w.map, "color blue"
        for x= 1 to MapWidth step dcx ', MapHeight
          #w.map, "line ";x;" ";"0";" ";x;" ";MapHeight
        next x
        for y= 1 to MapHeight step dcy
          #w.map, "line ";"0";" ";y;" ";MapWidth;" ";y
        next y
        #w.map "flush; discard"
    return
    wait
    [sel]
      bx=MouseX: by=MouseY
   for a=2 to 8 ' test 1ere colonne
     if bx> ax(a) and bx< (ax(a)+20) and by> ay(a) and by< (ay(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
   for a=9 to 15 ' test 2eme colonne
     if bx> a1x(a) and bx< (a1x(a)+20) and by> a1y(a) and by< (a1y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
  wait
        [Mark]
         mX = int(MouseX/dcx): mY = int(MouseY/dcy)
       loadbmp "image"+str$(x), "STMailles\Maille" +str$(nm)+".bmp"
       xx=mX*dcx+1: yy=mY*dcy+1
       #w.map, "drawbmp ";"image"+str$(x);" ";xx;" ";yy
     unloadbmp "image"+str$(x)
     #w.map, "flush"
    wait
    [infos]
        #w.txt "pixels : ";MouseX;" / ";MouseY;_
        "         Cell ( ";mX;" , ";mY;" )"
    return
    [DispMap]
        gosub [infos]
        if grid then
            #w.map "backcolor lightgray; color lightgray"
        else
            #w.map "backcolor black; color black"
        end if
        for y=1 to ncy
            #w.map "place 0 ";y*dc;"; goto ";MapWidth;" ";y*dc
        next
        for x=1 to ncx
            #w.map "place ";x*dc;" 0; goto ";x*dc;" ";MapHeight
        next
        #w.map "backcolor lightgray; color lightgray"
        #w.map "flush; discard"
    return
    [coord]
      cx=MouseX: cy=MouseY
      #w.map, "color black;backcolor yellow"
      #w.map, "place ";"100";" ";cy: #w.map, "\x:";cx;"  y:";cy
    wait
    [quit]
        close #w
        end
    wait
 

Reste à savoir pourquoi tu a séparés les flèches et les 1G et autres; mais bon, on peut le faire.
____________________
Roro

   
Le 17/08/2020 à 03h10

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
[url]ad/casteldivmailles.zip]CastelDivMailles.zip[/url]

C'est en faisant cette application ( qui est un recueil de différents types de maille) que l'idée de faire un éditeur de schémas de mailles m'est venue.

J'ai fait tous les bop avec Paint.
c'était très long et aussi très fastidieux!
Bon, il y avait le confinement ... mais quand même ...
Avec l'éditeur ça irait beaucoup plus vite
____________________
Castel

   
Le 17/08/2020 à 03h12

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
____________________
Castel

   
Le 17/08/2020 à 09h27

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
On sait bien que dans l'élaboration d'un soft, le plus difficile est d'en définir clairement les fonctionnalités; ne crains pas de t'étaler en texte explicatif (en t'appuyant sur l'existant).
C'est diablement technique le tricot !!!
Je sens qu'avec toutes ces données on peut faire un super truc de la mort qui tue. (miam miam ^^

Si tu a le temps, ce serait bien de renommer les deux sujets (zips)"Mailles V1" et: "Mailles V2"
Ou de mettre "maillesV1.bas" et maillesV2.bas dans "Mailles-Castel" avec bien sûr les "STMailles" et blpMailles" avec. Car on risque de s'emmeller les pinceaux vu que les deux trucs cohabitent sur ce threead et qu'ils sont différents

Amélioration de l'avant dernier (la V1):
Code VB :
 
      nomainwin
    WindowWidth = 600: WindowHeight = 480
    UpperLeftX = (DisplayWidth-WindowWidth) / 3
    UpperLeftY = 10 '(DisplayHeight-WindowHeight) / 2
    dcx = 21: dcy=30  'size of a cell in pixels
    MapWidth = 18*dcx: MapHeight = 13*dcy
    graphicbox #w.col, 5, 20, WindowWidth-80, 10
    graphicbox #w.map, 5, 40, MapWidth, MapHeight
    graphicbox #w.comb, 410, 40, 150, 300
    open "    TEST GRID Coord..." for window_nf as #w  'graphics_nf_nsb
    #w "trapclose [quit]"
    #w.map "down; fill white"
    #w.map "backcolor lightgray; color lightgray"
    #w.map "when leftButtonDown [Mark]"
    #w.comb, "down;fill lightgray": #w.comb, "when leftButtonDown [sel]"
    #w.comb, "when rightButtonDown [coord]"
    gosub [col]
   dos$ = "STMailles\Maille"
   x=5: y=5: d=0
   for a=2 to 8 ' tableau des distances 1er colonne
     ax(a)=5: ay(a)=y+d
     d=d+40
   next a
   dim a1x(20): dim a1y(20): d=0' tableau des distances 2eme colonne
   for a=9 to 15
     a1x(a)=30: a1y(a)=y+d
     d=d+40
   next a
   dim a3x(32): dim a3y(32): d=0
   for a=28 to 30 ' distances 3eme colonne
     a3x(a)=70: a3y(a)=y+d
     d=d+40
   next a
   dim a4x(46): dim a4y(46): d=0
   for a=38 to 44 ' distances 4 eme colonne
     a4x(a)=95: a4y(a)=y+d
     d=d+40
   next a
   '--------------------affichage mailles
     loadbmp "image"+"0", "STMailles\Maille" +"0"+".bmp" 'maille vide
     #w.comb, "drawbmp ";"image"+"0";" ";"125";" ";"10"
     unloadbmp "image"+"0"
     '---------
    x=5: y=5
   for x=2 to 8 ' 1ere colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"5";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     next x
   y=5
   for x=9 to 15 '2eme colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"35";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
   y=5
   for x=28 to 30 ' 3eme colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"65";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
   y=5
   for x=38 to 44 ' 4 eme colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"95";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
    gosub [grid]
    wait
    [sel]
      bx=MouseX: by=MouseY
   if bx> 125 and bx< 145 and by> 12 and by< 42 then
     nm=0: bmp$="STMailles\Maille"+"0": gosub [grid] ' Maille vide
   end if
   for a=2 to 8 ' test 1ere colonne
     if bx> ax(a) and bx< (ax(a)+20) and by> ay(a) and by< (ay(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
   for a=9 to 15 ' test 2eme colonne
     if bx> a1x(a) and bx< (a1x(a)+20) and by> a1y(a) and by< (a1y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
   for a=28 to 30 ' test 3eme colonne
     if bx> a3x(a) and bx< (a3x(a)+20) and by> a3y(a) and by< (a3y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
 
   for a=38 to 44 ' test 4 eme colonne
     if bx> a4x(a) and bx< (a4x(a)+20) and by> a4y(a) and by< (a4y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
  wait
        [Mark]
         mX = int(MouseX/dcx): mY = int(MouseY/dcy)
       loadbmp "image"+str$(x), "STMailles\Maille" +str$(nm)+".bmp"
       xx=mX*dcx+1: yy=mY*dcy+1
       #w.map, "drawbmp ";"image"+str$(x);" ";xx;" ";yy+4
     unloadbmp "image"+str$(x)
     #w.map, "flush"
    wait
    [grid]
        #w.map, "color blue"
        for x= 1 to MapWidth step dcx ' verticales
          #w.map, "line ";x+1;" ";"0";" ";x+1;" ";MapHeight
        next x
        for y= 1 to MapHeight step dcy 'horizontales
          #w.map, "line ";"0";" ";y+1;" ";MapWidth;" ";y+1
        next y
        #w.map, "color red"
        #w.map, "line ";MapWidth-3*dcx;" ";"0";" ";MapWidth-3*dcx;" ";MapHeight
        #w.map, "line ";MapWidth-2*dcx;" ";"0";" ";MapWidth-2*dcx;" ";MapHeight
        #w.map, "line ";MapWidth-dcx;" ";"0";" ";MapWidth-dcx;" ";MapHeight
        #w.map "flush; discard"
    return
  [col]
    #w.col, "down;color cyan;backcolor cyan"
    #w.col, "place 0 0": #w.col, "boxfilled 315 10"
    #w.col, "place 405 0": #w.col, "boxfilled 460 10"
    #w.col, "down;color red;backcolor red"
    #w.col, "place 317 0": #w.col, "boxfilled 338 10"
    #w.col, "place 469 0": #w.col, "boxfilled 492 10"
    #w.col, "down;color green;backcolor green"
    #w.col, "place 340 0": #w.col, "boxfilled 360 10"
    #w.col, "place 500 0": #w.col, "boxfilled 520 10"
    #w.col, "flush"
  return
    [coord]
      cx=MouseX: cy=MouseY
      #w.map, "color black;backcolor yellow"
      #w.map, "place ";"100";" ";cy: #w.map, "\x:";cx;"  y:";cy
    wait
    [quit]
        close #w
        end
    wait
 
____________________
Roro

   
Le 18/08/2020 à 10h05

Libertynaute Actif

Groupe: Membre

Inscrit le: 10/10/2017
Messages: 121
OK, ce sera rénommé.
Hier, j'étais absent, mais la dernière version est super.
____________________
Castel

   
Le 18/08/2020 à 10h23

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2489
Ajout de la sauvegarde de la grille (en ".bmp" dans le dossier)
Si tu veux agrandir, dis en combien tu le veux, j'ai commencé de tout mettre en relatif pour maîtriser la taille avec deux paramètres (le nombre de cases en x et y)
Qu'est-ce qu'on peut ajouter ? (j'aime bien ajouter)
Code VB :
 
     nomainwin
    WindowWidth = 600: WindowHeight = 565
    UpperLeftX = (DisplayWidth-WindowWidth) / 3
    UpperLeftY = 5 '(DisplayHeight-WindowHeight) / 2
    dcx = 21: dcy=30  'size of a cell in pixels
    MapWidth = 18*dcx: MapHeight = 16*dcy
    graphicbox #w.col, 5, 30, WindowWidth-78, 10
    graphicbox #w.map, 5, 40, MapWidth, MapHeight
    graphicbox #w.comb, 410, 40, 150, 300
    button #w.s, "Save bmp", [savebmp], UL, WindowWidth-150, WindowHeight-80, 70, 25
    open "    TEST GRID Coord..." for window_nf as #w  'graphics_nf_nsb
    #w "trapclose [quit]"
    #w.map "down; fill white"
    #w.map "backcolor lightgray; color lightgray"
    #w.map "when leftButtonDown [Mark]"
    #w.comb, "down;fill lightgray": #w.comb, "when leftButtonDown [sel]"
    #w.comb, "when rightButtonDown [coord]"
    gosub [col]
   dos$ = "STMailles\Maille"
   x=5: y=5: d=0
   for a=2 to 8 ' tableau des distances 1er colonne
     ax(a)=5: ay(a)=y+d
     d=d+40
   next a
   dim a1x(20): dim a1y(20): d=0' tableau des distances 2eme colonne
   for a=9 to 15
     a1x(a)=30: a1y(a)=y+d
     d=d+40
   next a
   dim a3x(32): dim a3y(32): d=0
   for a=28 to 30 ' distances 3eme colonne
     a3x(a)=70: a3y(a)=y+d
     d=d+40
   next a
   dim a4x(46): dim a4y(46): d=0
   for a=38 to 44 ' distances 4 eme colonne
     a4x(a)=95: a4y(a)=y+d
     d=d+40
   next a
   '--------------------affichage mailles
     loadbmp "image"+"0", "STMailles\Maille" +"0"+".bmp" 'maille vide
     #w.comb, "drawbmp ";"image"+"0";" ";"125";" ";"10"
     unloadbmp "image"+"0"
     '---------
    x=5: y=5
   for x=2 to 8 ' 1ere colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"5";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     next x
   y=5
   for x=9 to 15 '2eme colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"35";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
   y=5
   for x=28 to 30 ' 3eme colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"65";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
   y=5
   for x=38 to 44 ' 4 eme colonne
     loadbmp "image"+str$(x), "STMailles\Maille" +str$(x)+".bmp"
     #w.comb, "drawbmp ";"image"+str$(x);" ";"95";" ";y
     y=y+40
     unloadbmp "image"+str$(x)
     #w.comb, "flush"
   next x
    gosub [grid]
    wait
    [sel]
      bx=MouseX: by=MouseY
   if bx> 125 and bx< 145 and by> 12 and by< 42 then
     nm=0: bmp$="STMailles\Maille"+"0": gosub [grid] ' Maille vide
   end if
   for a=2 to 8 ' test 1ere colonne
     if bx> ax(a) and bx< (ax(a)+20) and by> ay(a) and by< (ay(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
   for a=9 to 15 ' test 2eme colonne
     if bx> a1x(a) and bx< (a1x(a)+20) and by> a1y(a) and by< (a1y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
   for a=28 to 30 ' test 3eme colonne
     if bx> a3x(a) and bx< (a3x(a)+20) and by> a3y(a) and by< (a3y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
 
   for a=38 to 44 ' test 4 eme colonne
     if bx> a4x(a) and bx< (a4x(a)+20) and by> a4y(a) and by< (a4y(a)+30) then nm=a: bmp$="STMailles\Maille"+str$(nm)
   next a
  wait
        [Mark]
         mX = int(MouseX/dcx): mY = int(MouseY/dcy)
       loadbmp "image"+str$(x), "STMailles\Maille" +str$(nm)+".bmp"
       xx=mX*dcx+1: yy=mY*dcy+1
       #w.map, "drawbmp ";"image"+str$(x);" ";xx;" ";yy+4
     unloadbmp "image"+str$(x)
     #w.map, "flush"
    wait
    [grid]
        #w.map, "color blue"
        for x= 1 to MapWidth step dcx ' verticales
          #w.map, "line ";x+1;" ";"0";" ";x+1;" ";MapHeight
        next x
        for y= 1 to MapHeight step dcy 'horizontales
          #w.map, "line ";"0";" ";y+1;" ";MapWidth;" ";y+1
        next y
        #w.map, "color red"
        #w.map, "line ";(MapWidth-3*dcx)+1;" ";"0";" ";(MapWidth-3*dcx)+1;" ";MapHeight
        #w.map, "line ";(MapWidth-2*dcx)+1;" ";"0";" ";(MapWidth-2*dcx)+1;" ";MapHeight
        #w.map, "line ";MapWidth-dcx+1;" ";"0";" ";MapWidth-dcx+1;" ";MapHeight
        #w.map "flush; discard"
    return
[savebmp]
 #w.map "getbmp drawing 1 1 378 480"
  bmpsave "drawing", "marmaille.bmp"
Notice,"C'est dans le dossier"
wait
  [col]
    #w.col, "down;color cyan;backcolor cyan"
    #w.col, "place 0 0": #w.col, "boxfilled 316 10"
    #w.col, "place 405 0": #w.col, "boxfilled 462 10"
    #w.col, "down;color red;backcolor red"
    #w.col, "place 316 0": #w.col, "boxfilled 339 10"
    #w.col, "place 469 0": #w.col, "boxfilled 492 10"
    #w.col, "down;color green;backcolor green"
    #w.col, "place 339 0": #w.col, "boxfilled 360 10"
    #w.col, "place 500 0": #w.col, "boxfilled 520 10"
    #w.col, "flush"
  return
    [coord]
      cx=MouseX: cy=MouseY
      #w.map, "color black;backcolor yellow"
      #w.map, "place ";"100";" ";cy: #w.map, "\x:";cx;"  y:";cy
    wait
    [quit]
        close #w
        end
    wait
 
____________________
Roro

   
Projets open source » Mini Editeur de schémas de mailles Permet d'éditer des séquences de tricotage  

 |  |

1 Utilisateur en ligne : 0 Administrateur, 0 Modérateur, 0 Membre et 1 Visiteur
Utilisateur en ligne : Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie