File: monbitmap.pas

package info (click to toggle)
dozzaqueux 3.51-2.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 5,764 kB
  • sloc: pascal: 35,831; xml: 961; makefile: 50; sh: 32
file content (1563 lines) | stat: -rwxr-xr-x 61,627 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
unit MonBitmap;


{$mode objfpc}{$H+}

interface

uses
    Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,LCLProc,Math,LCLType
  {$ifdef windows},Windows{$endif};
type
 TCouleurPixelPourDensityPlot = function(x,y:extended):tcolor;
  pimage=^timage;
  TMonBitmap = Object
 image_pointee:pimage;
 
   Xmin,Xmax,Ymin1,Ymax1,Ymin2,Ymax2,GraduationX, GraduationY1,GraduationY2,
   SousGraduationX, SousGraduationY1,SousGraduationY2:extended;

   Rang_Premiere_Graduation_X,Rang_Premiere_Graduation_Y1,Rang_Premiere_Graduation_Y2,
    Rang_Derniere_Graduation_X,Rang_Derniere_Graduation_Y1,Rang_Derniere_Graduation_Y2,
    Rang_Premiere_Sous_Graduation_X,Rang_Premiere_Sous_Graduation_Y1,Rang_Premiere_Sous_Graduation_Y2,
    Rang_Derniere_Sous_Graduation_X,Rang_Derniere_Sous_Graduation_Y1,Rang_Derniere_Sous_Graduation_Y2:integer;
  Largeur,Hauteur,BordureBasse,BordureHaute,
  BordureGauche,BordureDroite,EpaisseurGrille,PuissanceDeDixX,
  PuissancedeDixY1,PuissancedeDixY2,epaisseurcadre,epaisseurgraduation:integer;
  longueurgraduationX,longueurgraduationY1,longueurgraduationY2:extended;
  PasGrillex,PasGrilley1,PasGrilley2:extended;
  couleurfond,couleurcadre,couleurgraduation,
  couleurgrille1,couleurgrille2:tcolor;
  cadre,gradue,grille1,grille2,fond,borduresverticalessymetriques,echelle_g,echelle_d:boolean;
   titre,labelx,labely1,labely2,unitex,unitey1,unitey2:string;
  fontegraduation:tfont;
  fontetitre:tfont;
    procedure background(couleur:tcolor);
 procedure DensityPlot(TCP:TCouleurPixelPourDensityPlot; gauche:boolean);


  function LimitesEtAxes(pointeur_sur_image:pimage;_xmin,_xmax,_ymin1,_ymax1,_ymin2,_ymax2:extended;
 _Largeur,_Hauteur:integer;
 _titre:string;
  _fontetitre:tfont;
  _Fond:boolean;
 _CouleurFond:tcolor;
 _Cadre:boolean; _EpaisseurCadre:integer;
 _CouleurCadre:tcolor;
 _Gradue:boolean;
 _EpaisseurGraduation,_LongueurGraduation:integer;
 _couleurgraduation:tcolor;
 _fontegraduation:tfont;
 _Grille1,_Grille2:boolean; _EpaisseurGrille:integer;
 _CouleurGrille1,_CouleurGrille2:tcolor;
 _labelx,_labely1,_labely2,_unitex,_unitey1,_unitey2:string;
  _borduresverticalessymetriques,
 _echelle_g,_echelle_d:boolean):boolean;

procedure  dessinergrille(pas_grillex,pas_grilley:extended);

procedure arronditalagrille(var x1,y1:extended;pas_grillex,pas_grilley:extended);

 function invconvert(var xi,yi:integer; x,y:extended;gauche:boolean):boolean;

 function Convert(xi,yi:integer; var x,y:extended;gauche:boolean):boolean;

 function CroixX(x,y:extended;
 demi_diagonale,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

 function CroixP(x,y:extended;
 demi_longueur,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

 function Carreau(x,y:extended;
 demi_diagonale,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

            function Trait(x1,y1,x2,y2:extended; epaisseur:integer;
 couleur:tcolor; sty:tpenstyle; penmod:tpenmode;gauche:boolean):boolean;

 function Point(x,y:extended; rayon:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

 function cercle(x,y:extended; rayon,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

function ellipse(x,y,rayonx,rayony:extended; epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

   function ellipse2(xcentre,ycentre,rayonx,rayony,axe1_x,axe1_y,axe2_x,axe2_y:extended; epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;
  function disque(x,y:extended; rayon:extended; couleurbord,couleurf:tcolor;_transparent:boolean;gauche:boolean):
 boolean;

  function disque2(x,y:extended; rayon:integer; couleurbord,couleurf:tcolor;gauche:boolean):
 boolean;

  function arcdecercle(x,y:extended; rayonreel:extended;
     epaisseur:integer; theta1,theta2:extended;
     couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;

     function tracepolygone(nombrepoint:integer;listex,listey:array of extended; couleurbord,couleurf:tcolor;_transparent:boolean;gauche:boolean):boolean;

   procedure traceconique(theta0,theta1,theta2,fx,fy,excentricite,parametre:extended;
    couleur:tcolor;gauche:boolean);

     procedure arronditalagrille(var x1,y1:extended;gauche:boolean);

      procedure ecrire(x,y:extended; s:string;gauche:boolean; police:tfont);
     function MonRectangle(x1,y1,x2,y2:extended; couleur:tcolor; gauche:boolean):boolean;



      procedure graduation(xi,xa:extended;
var xci,xca:extended; var graduation,sousgraduation:extended;
var rang_premiere_sousgraduation,rang_derniere_sousgraduation,rang_premiere_graduation,rang_derniere_graduation:integer);





 
  end;

   procedure echange(var a,b:extended);

       procedure echange_entiers(var a,b:integer);

        function partieentiere(x:extended):extended;

         function dix_pp(p:longint):extended;





implementation

uses Unit1;


 procedure TMonBitmap.arronditalagrille(var x1,y1:extended;pas_grillex,pas_grilley:extended);
  var newx,newy,divx,divy,fracx,fracy:extended;
  begin
  divx:=partieentiere((x1-xmin)/pas_grillex);
  divy:=partieentiere((y1-ymin1)/pas_grilley);
  fracx:=x1-xmin-divx*pas_grillex;
  fracy:=y1-ymin1-divy*pas_grilley;
  if fracx>0.5*pas_grillex then newx:=xmin+(divx+1)*pas_grillex else newx:=xmin+divx*pas_grillex;
  if fracy>0.5*pas_grilley then newy:=ymin1+(divy+1)*pas_grilley else newy:=ymin1+divy*pas_grilley;
  x1:=newx; y1:=newy;
                        end;


procedure  TMonBitmap.dessinergrille(pas_grillex,pas_grilley:extended);
 var i,j,x1,y1:integer; x,y:extended;
  begin
 if grille1 then begin


  for i:=1 to trunc((xmax-xmin)/pas_grillex) do
  for j:=1 to trunc((ymax1-ymin1)/pas_grilley) do begin
  x:=xmin+i*pas_grillex; y:=ymin1+j*pas_grilley;
 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax1-y)/(ymax1-ymin1)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;


     image_pointee^.picture.Bitmap.canvas.pixels[x1,y1]:=couleurgrille1;

    end;   end; end;


procedure TMonBitmap.DensityPlot(TCP:TCouleurPixelPourDensityPlot; gauche:boolean);
var i,j:integer; x,y:extended;
begin
for i:=BordureGauche to  largeur-BordureDroite  do
for j:=BordureHaute to  hauteur-BordureBasse  do begin
 self.convert(i,j,x,y,gauche);
 image_pointee^.picture.Bitmap.canvas.pixels[i,j]:=TCP(x,y);
   end;

end;


procedure TMonBitmap.graduation(xi,xa:extended;
var xci,xca:extended; var graduation,sousgraduation:extended;
var rang_premiere_sousgraduation,rang_derniere_sousgraduation,rang_premiere_graduation,rang_derniere_graduation:integer);

var g,sg,d:extended;
p:longint;

 label 124;
begin
if xa<xi then echange(xi,xa);
d:=xa-xi;

p:=floor(log10(d/4));
{d est compris entre 4.10^p et 4.10^(p+1)}
if d<=8*intpower(10,p) then begin
g:=intpower(10,p);
sg:=g/5;
end else
if d<=20*intpower(10,p) then begin
g:=2*intpower(10,p);
sg:=g/4;
end else begin
  g:=5*intpower(10,p);
  sg:=g/5;
end;



        graduation:=g;
        sousgraduation:=sg;




  rang_derniere_sousgraduation:=ceil(xa/sousgraduation);
  rang_premiere_sousgraduation:=floor(xi/sousgraduation);
  xci:=rang_premiere_sousgraduation*sousgraduation;
  xca:=rang_derniere_sousgraduation*sousgraduation;
  rang_derniere_graduation:=floor(xca/graduation);
  rang_premiere_graduation:=ceil(xci/graduation);
end;




 function dix_pp(p:longint):extended;
var i:longint;
inter:extended;
begin

if (p<-1) then begin
inter:=1/10;
for i:=1 to abs(p)-1 do
inter:=inter/10;
result:=inter;
end else


if p=0 then begin
result:=1;
end else

if p=1 then begin
 result:=10;
end else

if (p>1) then begin
inter:=10;
for i:=1 to p-1 do
inter:=inter*10;
result:=inter;
end else

if (p=-1) then begin
result:=1/10;
end;



       end;


function partieentiere(x:extended):extended;
begin
if x>=0 then  begin
partieentiere:=int(x);
exit;
end;
if frac(x)=0 then begin
partieentiere:=x;
exit;
end;
{cas ou x est <0 et non entier}
partieentiere:=int(x)-1;
end;



function TMonBitmap.disque2(x,y:extended; rayon:integer; couleurbord,couleurf:tcolor;gauche:boolean):
 boolean;

            var x1,y1,r1x,r1y:integer;
            ymax,ymin,pasgrilley:extended;
             old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;


  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
            x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 disque2:=false;
 exit;
 end;
     x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
     if rayon=0 then exit;

 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;

       image_pointee^.picture.Bitmap.canvas.pen.color:=couleurbord;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=1;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=pmcopy;
     disque2:=true;

     image_pointee^.picture.Bitmap.canvas.brush.style:=bssolid;
     image_pointee^.picture.Bitmap.canvas.brush.color:=couleurf;

image_pointee^.picture.Bitmap.canvas.ellipse(x1-rayon,y1-rayon,x1+rayon,
y1+rayon);

      image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;

     end;




 function TMonBitmap.Carreau(x,y:extended;
 demi_diagonale,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;
 var x1,y1:integer;
ymax,ymin,pasgrilley:extended;
         old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;


  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 carreau:=false;
 exit;
 end;

 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;

 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;


 image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
  image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
  image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
  image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
   image_pointee^.picture.Bitmap.canvas.moveto(x1,y1+demi_diagonale);
   image_pointee^.picture.Bitmap.canvas.lineto(x1+demi_diagonale,y1);
    image_pointee^.picture.Bitmap.canvas.lineto(x1,y1-demi_diagonale);
     image_pointee^.picture.Bitmap.canvas.lineto(x1-demi_diagonale,y1);
      image_pointee^.picture.Bitmap.canvas.lineto(x1,y1+demi_diagonale);

   carreau:=true;

    image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;


   end;



    procedure echange_entiers(var a,b:integer);
     var c:integer;
    begin
    c:=a; a:=b; b:=c; end;


    procedure echange(var a,b:extended);
    var c:extended;
    begin
    c:=a; a:=b; b:=c; end;






 procedure TMonBitmap.traceconique(theta0,theta1,theta2,fx,fy,excentricite,parametre:extended;
   couleur:tcolor;gauche:boolean);
   var pas,theta,r,ract,thetaact,nx,ny,ttai:extended;
   nombrepas,i:integer;
   ymax,ymin,pasgrilley:extended;
     old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;



  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
   nombrepas:=1000;
   pas:=(theta2-theta1)/nombrepas;
   thetaact:=theta1;
   ract:=parametre/(1+excentricite*cos(thetaact-theta0));
   for i:=1 to nombrepas do begin
   theta:=theta1+i*pas;
   r:=parametre/(1+excentricite*cos(theta-theta0));
   if ((r>0) and (ract>0)) then trait(fx+ract*cos(thetaact),fy+ract*sin(thetaact),fx+r*cos(theta),fy+r*sin(theta),
   1,couleur,pssolid,pmcopy,gauche);
   thetaact:=theta;
   ract:=r;
   end;
    end;


function TMonBitmap.tracepolygone(nombrepoint:integer;listex,listey:array of extended;
  couleurbord,couleurf:tcolor;_transparent:boolean;gauche:boolean):boolean;
  var i,x1,y1:integer;  titi:array of tpoint;
  ymax,ymin,pasgrilley:extended;
  old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;



  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
  setlength(titi,nombrepoint);
 for i:=1 to nombrepoint do begin
    x1:= trunc((listex[i-1]-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-listey[i-1])/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
 titi[i-1].x:=x1;
 titi[i-1].y:=y1;
 end;


 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;

 image_pointee^.picture.Bitmap.canvas.Pen.Color:=couleurbord;
 image_pointee^.picture.Bitmap.canvas.brush.color:=couleurf;
if not(_transparent) then image_pointee^.picture.Bitmap.canvas.brush.style:=bsSolid else
image_pointee^.picture.Bitmap.canvas.brush.style:=bsclear;

  image_pointee^.picture.Bitmap.canvas.Polygon(titi,false,0,nombrepoint);
  image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;

  end;


     function TMonBitmap.arcdecercle(x,y:extended; rayonreel:extended;
     epaisseur:integer; theta1,theta2:extended;
     couleur:tcolor; penmod:tpenmode;gauche:boolean): boolean;

            var x1,y1,rax,ray:integer;
           ymax,ymin,pasgrilley:extended;
           old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;


  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
      invconvert(x1,y1,x,y,gauche);
   rax:= trunc(rayonreel/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
   ray:= trunc(rayonreel/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
          if rayonreel=0 then exit;

     old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;


    image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
     arcdecercle:=true;
     image_pointee^.picture.Bitmap.canvas.brush.style:=bsclear;


     image_pointee^.picture.Bitmap.canvas.arc(x1-rax,y1-ray,x1+rax,y1+ray,trunc(theta1/Pi*180*16),trunc((theta2-theta1)/Pi*180*16));
     arcdecercle:=true;

     image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;

     end;




function TMonBitmap.Point(x,y:extended; rayon:integer; couleur:tcolor
 ; penmod:tpenmode;gauche:boolean):
 boolean;
            var x1,y1:integer;
            ymax,ymin,pasgrilley:extended;

           old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;
  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
            x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 point:=false;
 exit;
 end;
     x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
if rayon=0 then image_pointee^.picture.Bitmap.canvas.pixels[x1,y1]:=couleur;

     if rayon=0 then exit;


 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
  old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.Color;

 image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=1;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=pmcopy;
     image_pointee^.picture.Bitmap.canvas.brush.style:=bssolid;
     image_pointee^.picture.Bitmap.canvas.brush.Color:=couleur;
     image_pointee^.picture.Bitmap.canvas.ellipse(x1-rayon,y1-rayon,x1+rayon,y1+rayon);

     image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
     image_pointee^.picture.Bitmap.canvas.brush.Color:=old_brush_color;
     end;

function TMonBitmap.ellipse(x,y,rayonx,rayony:extended; epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;
var x1,y1,r1x,r1y:integer;
         ymax,ymin,pasgrilley:extended;

         old_pen_color,old_brush_color:tcolor;
old_pen_style:tpenstyle;
old_pen_width:integer;
old_pen_mode:tpenmode;
  old_brush_style:tbrushstyle;
  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
            x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 ellipse:=false;
 exit;
 end;
     x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
   r1x:= trunc(rayonx/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 r1y:=trunc((rayony)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));

 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
    image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
     ellipse:=true;
     image_pointee^.picture.Bitmap.canvas.brush.style:=bsclear;

image_pointee^.picture.Bitmap.canvas.arc(x1-r1x,y1-r1y,x1+r1x,y1+r1y,x1+r1x,
y1+r1y,x1+r1x,y1+r1y);
  image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
     end;


function TMonBitmap.ellipse2(xcentre,ycentre,rayonx,rayony,axe1_x,axe1_y,axe2_x,axe2_y:extended; epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;
var x1,y1,x2,y2,r1x,r1y,i:integer;
         ymax,ymin,pasgrilley:extended;

         old_pen_color,old_brush_color:tcolor;
old_pen_style:tpenstyle;
old_pen_width:integer;
old_pen_mode:tpenmode;
  old_brush_style:tbrushstyle;
  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
    x1:= trunc((xcentre-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-ycentre)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 ellipse2:=false;
 exit;
 end;


 {    x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
   r1x:= trunc(rayonx/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 r1y:=trunc((rayony)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
  }
 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
    image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
     ellipse2:=true;
     image_pointee^.picture.Bitmap.canvas.brush.style:=bsclear;

   self.invconvert(x1,y1,xcentre+rayonx*axe1_x,ycentre+rayonx*axe1_y,gauche);
   image_pointee^.picture.Bitmap.canvas.MoveTo(x1,y1);
   for i:=1 to 360 do begin
  self.invconvert(x2,y2,xcentre+rayonx*axe1_x*cos(i/360*2*pi)+rayony*axe2_x*sin(i/360*2*pi),
  ycentre+rayonx*axe1_y*cos(i/360*2*pi)+rayony*axe2_y*sin(i/360*2*pi),gauche);
  image_pointee^.picture.Bitmap.canvas.LineTo(x2,y2);
   end;




  image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;


end;
function TMonBitmap.cercle(x,y:extended; rayon,epaisseur:integer; couleur:tcolor
; penmod:tpenmode;gauche:boolean):
 boolean;
            var x1,y1:integer;
           ymax,ymin,pasgrilley:extended;

           old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;



  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
            x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 cercle:=false;
 exit;
 end;
     x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;

 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
    image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
     cercle:=true;
     image_pointee^.picture.Bitmap.canvas.brush.style:=bsclear;
     if rayon=0 then exit;
image_pointee^.picture.Bitmap.canvas.arc(x1-rayon,y1-rayon,x1+rayon,y1+rayon,x1+rayon,
y1+rayon,x1+rayon,y1+rayon);
  image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
     end;

     function TMonBitmap.disque(x,y:extended; rayon:extended; couleurbord,couleurf:tcolor;_transparent:boolean;gauche:boolean):
 boolean;
            var x1,y1,r1x,r1y:integer;
            ymax,ymin,pasgrilley:extended;
              old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;


  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
            x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 disque:=false;
 exit;
 end;
     x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
   r1x:= trunc(rayon/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 r1y:=trunc((rayon)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
      if rayon=0 then exit;
 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
   old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;


    image_pointee^.picture.Bitmap.canvas.pen.color:=couleurbord;
     image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
     image_pointee^.picture.Bitmap.canvas.pen.width:=1;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=pmcopy;
     disque:=true;

     image_pointee^.picture.Bitmap.canvas.brush.color:=couleurf;
   if not(_transparent) then  image_pointee^.picture.Bitmap.canvas.brush.style:=bssolid else
   image_pointee^.picture.Bitmap.canvas.brush.style:=bsclear;


image_pointee^.picture.Bitmap.canvas.ellipse(x1-r1x,y1-r1y,x1+r1x,
y1+r1y);


           image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
         image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;

     end;


function TMonBitmap.Trait(x1,y1,x2,y2:extended; epaisseur:integer;
 couleur:tcolor;sty:tpenstyle; penmod:tpenmode;gauche:boolean):boolean;
 var ymax,ymin,pasgrilley:extended;
     xi1,xi2,yi1,yi2:integer;
        old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;

  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
       if xmax=xmin then exit;
       if ymax=ymin then exit;
   old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;


 image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
 image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
 image_pointee^.picture.Bitmap.canvas.pen.Style:=sty;
 image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
 self.invconvert(xi1,yi1,x1,y1,gauche);
 self.invconvert(xi2,yi2,x2,y2,gauche);
  image_pointee^.picture.Bitmap.canvas.Line(xi1,yi1,xi2,yi2);
 {image_pointee^.picture.Bitmap.canvas.moveto(trunc((x1-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche,trunc((ymax-y1)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute);
 image_pointee^.picture.Bitmap.canvas.lineto(trunc((x2-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche,trunc((ymax-y2)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute);
}

 image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;

 end;


function TMonBitmap.MonRectangle(x1,y1,x2,y2:extended; couleur:tcolor; gauche:boolean):boolean;
 var ymax,ymin,pasgrilley:extended;
        old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;
   xi1,yi1,xi2,yi2:integer;

  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
       if xmax=xmin then exit;
       if ymax=ymin then exit;
   old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
 old_brush_color:=image_pointee^.picture.Bitmap.canvas.Brush.Color;


 image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
 image_pointee^.picture.Bitmap.canvas.pen.Style:=pssolid;
 image_pointee^.picture.Bitmap.canvas.pen.mode:=pmcopy;
 image_pointee^.picture.Bitmap.canvas.Brush.Color:=couleur;
 image_pointee^.picture.Bitmap.canvas.Brush.Style:=bssolid;
 self.invconvert(xi1,yi1,x1,y1,gauche);
 self.invconvert(xi2,yi2,x2,y2,gauche);
 if xi1>xi2 then echange_entiers(xi1,xi2);
 if yi1>yi2 then  echange_entiers(yi1,yi2);
 image_pointee^.picture.Bitmap.canvas.Rectangle(xi1,yi1,xi2,yi2);
 image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
      image_pointee^.picture.Bitmap.canvas.brush.Color:=old_brush_color;

 end;


function TMonBitmap.CroixP(x,y:extended;
 demi_longueur,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;
 var x1,y1:integer;
 ymax,ymin,pasgrilley:extended;
          old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;


  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 croixp:=false;
 exit;
 end;

 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;

 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
 old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;

image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
  image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
  image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
  image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
   image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1,y1+demi_longueur);
       image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1,y1-demi_longueur);
        image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1+demi_longueur,y1);
   image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1-demi_longueur,y1);
   croixp:=true;


 image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
     image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;
   end;


   procedure TMonBitmap.arronditalagrille(var x1,y1:extended;gauche:boolean);
  var newx,newy,divx,divy,fracx,fracy:extended;
  ymax,ymin,pasgrilley:extended;
  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;

  divx:=partieentiere((x1-xmin)/pasgrillex);
  divy:=partieentiere((y1-ymin)/pasgrilley);
  fracx:=x1-xmin-divx*pasgrillex;
  fracy:=y1-ymin-divy*pasgrilley;
  if fracx>0.5*pasgrillex then newx:=(divx+1)*pasgrillex else newx:=divx*pasgrillex;
  if fracy>0.5*pasgrilley then newy:=(divy+1)*pasgrilley else newy:=divy*pasgrilley;
  x1:=newx; y1:=newy;
                        end;




  procedure  TMonBitmap.ecrire(x,y:extended; s:string;gauche:boolean; police:tfont);
   var xi,yi:integer;
   begin
    invconvert(xi,yi,x,y,gauche);
    image_pointee^.picture.Bitmap.canvas.Font:=police;
    image_pointee^.picture.Bitmap.canvas.textout(xi,yi,s);
      end;


procedure TMonBitmap.background(couleur:tcolor);
var old_pen_color,old_brush_color:tcolor;
old_pen_style:tpenstyle;
old_pen_width:integer;
old_pen_mode:tpenmode;
   old_brush_style:tbrushstyle;
begin
old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;

 image_pointee^.picture.Bitmap.canvas.pen.style:=psclear;
image_pointee^.picture.Bitmap.canvas.Brush.style:=bssolid;
image_pointee^.picture.Bitmap.canvas.Brush.Color:=clwhite;
image_pointee^.picture.Bitmap.canvas.Rectangle(0,0,image_pointee^.picture.Bitmap.Width,image_pointee^.picture.Bitmap.Height);
image_pointee^.picture.Bitmap.canvas.Brush.Color:=couleur;
image_pointee^.picture.Bitmap.canvas.Rectangle(borduregauche,bordurehaute,
largeur-borduredroite,hauteur-bordurebasse);


image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
     image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;
end;


 function TMonBitmap.LimitesEtAxes(pointeur_sur_image:pimage;_xmin,_xmax,_ymin1,_ymax1,_ymin2,_ymax2:extended;
 _Largeur,_Hauteur:integer;
 _titre:string;
  _fontetitre:tfont;
  _Fond:boolean;
 _CouleurFond:tcolor;
 _Cadre:boolean; _EpaisseurCadre:integer;
 _CouleurCadre:tcolor;
 _Gradue:boolean;
 _EpaisseurGraduation,_LongueurGraduation:integer;
 _couleurgraduation:tcolor;
 _fontegraduation:tfont;
 _Grille1,_Grille2:boolean; _EpaisseurGrille:integer;
 _CouleurGrille1,_CouleurGrille2:tcolor;
 _labelx,_labely1,_labely2,_unitex,_unitey1,_unitey2:string;
  _borduresverticalessymetriques,
 _echelle_g,_echelle_d:boolean):boolean;


  var xi,xa,yi1,yi2,ya1,ya2,gi,ga:extended;
     t1,t2,i:integer;
     dixx,dixy1,dixy2,tt,aff:string;
     nbgx,nbgy1,nbgy2:integer;
     old_pen_color,old_brush_color:tcolor;
old_pen_style:tpenstyle;
old_pen_width:integer;
old_pen_mode:tpenmode;
   old_brush_style:tbrushstyle;
  rg_grad_first,rg_grad_last,rg_ssgrad_first,rg_ssgrad_last:integer;


 begin
 image_pointee:=pointeur_sur_image;
 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;
old_brush_color:=image_pointee^.picture.Bitmap.canvas.brush.color;

 fond:=_fond;        echelle_g:=_echelle_g; echelle_d:=_echelle_d;
  borduresverticalessymetriques:=_borduresverticalessymetriques;
 labelx:=_labelx;
 labely1:=_labely1;   labely2:=_labely2;
 unitex:=_unitex; unitey1:=_unitey1; unitey2:=_unitey2;
   fontetitre:=_fontetitre;
  largeur:=_largeur;
  hauteur:=_hauteur;
 image_pointee^.picture.Bitmap.Width:=largeur;
 image_pointee^.picture.Bitmap.Height:=hauteur;
    titre:=_titre;
  couleurfond:=_couleurfond;
  cadre:=_cadre; epaisseurcadre:=_epaisseurcadre;
  couleurcadre:=_couleurcadre;
  gradue:=_gradue; epaisseurgraduation:=_epaisseurgraduation;

  fontegraduation:=_fontegraduation;
  couleurgraduation:=_couleurgraduation;
  grille1:=_grille1;   grille2:=_grille2;
  epaisseurgrille:=_epaisseurgrille;
  couleurgrille1:=_couleurgrille1;
  couleurgrille2:=_couleurgrille2;

  bordurehaute:=0;
  bordurebasse:=0;
  borduregauche:=0;
  borduredroite:=0;



 if (echelle_g and ( (_ymin1=_ymax1) or (_xmax=_xmin))) then begin
 LimitesEtAxes:=false;
 exit;
 end;
   if (echelle_d and ( (_ymin2=_ymax2) or (_xmax=_xmin))) then begin
 LimitesEtAxes:=false;
 exit;
 end;

 LimitesEtAxes:=true;
 if (_xmin>_xmax ) then begin
 xmin:=_xmax;
 xmax:=_xmin;
 end else begin
 xmin:=_xmin;
 xmax:=_xmax;
 end;

 if (_ymin1>_ymax1 ) then begin
 ymin1:=_ymax1;
 ymax1:=_ymin1;
 end else begin
 ymin1:=_ymin1;
 ymax1:=_ymax1;
 end;

 if (_ymin2>_ymax2 ) then begin
 ymin2:=_ymax2;
 ymax2:=_ymin2;
 end else begin
 ymin2:=_ymin2;
 ymax2:=_ymax2;
 end;



   xi:=xmin; yi1:=ymin1; yi2:=ymin2; xa:=xmax; ya1:=ymax1;  ya2:=ymax2;

 graduation(xi,xa,xmin,xmax,graduationx,sousgraduationx,Rang_Premiere_Sous_Graduation_X,
 Rang_Derniere_Sous_Graduation_X,Rang_Premiere_Graduation_X,Rang_Derniere_Graduation_X);

if echelle_g then graduation(yi1,ya1,ymin1,ymax1,graduationY1,sousgraduationY1,Rang_Premiere_Sous_Graduation_Y1,
 Rang_Derniere_Sous_Graduation_Y1,Rang_Premiere_Graduation_Y1,Rang_Derniere_Graduation_Y1);
if echelle_d then  graduation(yi2,ya2,ymin2,ymax2,graduationY2,sousgraduationY2,Rang_Premiere_Sous_Graduation_Y2,
 Rang_Derniere_Sous_Graduation_Y2,Rang_Premiere_Graduation_Y2,Rang_Derniere_Graduation_Y2);

 { str(-puissancededixx+1,dixx);
 if echelle_g then str(-puissancededixy1+1,dixy1) else dixy1:='0';
 if echelle_d then   str(-puissancededixy2+1,dixy2)else dixy2:='0'; }
 dixx:='0';
 dixy1:='0';
 dixy2:='0';
 {determination taille bordure haute}
 image_pointee^.picture.Bitmap.canvas.font:=fontetitre;
 if (titre<>'') then begin
 t1:=trunc(image_pointee^.picture.Bitmap.canvas.textheight(titre))+10;
 end else t1:=10;

 if gradue then begin
 image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
if ((dixy1='0') and (dixy2='0')) then t2:=trunc(image_pointee^.picture.Bitmap.canvas.textheight(unitex+labelx)*1.5)
 else t2:=trunc(image_pointee^.picture.Bitmap.canvas.textheight(unitex+labelx)*2.2);
 end else t2:=10;

 if (t1>t2)  then bordurehaute:=t1 else bordurehaute:=t2;



 {taille bordure basse}
 if gradue then begin
 image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
 t1:=trunc(image_pointee^.picture.Bitmap.canvas.textheight('x10'))+10;
 end else t1:=10;
 bordurebasse:=t1;

 {taille bordure droite}

 if (gradue and echelle_d) then begin
 image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
 t1:=image_pointee^.picture.Bitmap.canvas.textwidth(floattostr(Rang_Premiere_Graduation_Y2*GraduationY2));
 for i:=Rang_Premiere_Graduation_Y2 to Rang_Derniere_Graduation_Y2 do
t1:=max(t1,image_pointee^.picture.Bitmap.canvas.textwidth(floattostr(i*GraduationY2)));
 t1:=t1+10+_longueurgraduation;
 end else begin
 t1:=10;
 end;




 if gradue then begin
 image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
 t2:=(image_pointee^.picture.Bitmap.canvas.textwidth(floattostr(Rang_Derniere_Graduation_X*GraduationX)) div 2)-
 trunc((xmax-Rang_Derniere_Graduation_X*GraduationX)/(xmax-xmin)*(largeur-borduredroite-borduregauche));
 end else t2:=10;
 borduredroite:=max(t1,t2);

 {taille bordure gauche}

 if (gradue and echelle_g) then begin
 image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;

 t1:=image_pointee^.picture.Bitmap.canvas.textwidth(floattostr(Rang_Premiere_Graduation_Y1*GraduationY1));
 for i:=Rang_Premiere_Graduation_Y1 to Rang_Derniere_Graduation_Y1 do
t1:=max(t1,image_pointee^.picture.Bitmap.canvas.textwidth(floattostr(i*GraduationY1)));
 t1:=t1+10+_longueurgraduation;
 end else begin
 t1:=10;
 end;


 if gradue then begin
 image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
  t2:=(image_pointee^.picture.Bitmap.canvas.textwidth(floattostr(Rang_Premiere_Graduation_X*GraduationX)) div 2)-
 trunc((Rang_Premiere_Graduation_X*GraduationX-xmin)/(xmax-xmin)*(largeur-borduredroite-borduregauche));
 end else t2:=10;
 borduregauche:=max(t1,t2);


 if borduresverticalessymetriques then begin
  borduregauche:=max(borduregauche,borduredroite);
  borduredroite:=borduregauche;
  end;


  if fond then background(couleurfond);


 {longueurgraduation}
  longueurgraduationX:=_longueurgraduation/largeur*(xmax-xmin);
  if echelle_g then
   longueurgraduationy1:=_longueurgraduation/hauteur*(ymax1-ymin1);
  if echelle_d then
   longueurgraduationy2:=_longueurgraduation/hauteur*(ymax2-ymin2);

 if grille1 then begin
    image_pointee^.picture.Bitmap.canvas.pen.style:=psdot;
    image_pointee^.picture.Bitmap.canvas.pen.color:=couleurgrille1;
    image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseurgrille;
       for i:=Rang_Premiere_Sous_Graduation_X to Rang_Derniere_Sous_Graduation_X do
          trait(i*sousgraduationx,ymin1,i*sousgraduationx,ymax1,
          epaisseurgrille,couleurgrille1,psdot,pmcopy,true);
         for i:=Rang_Premiere_Sous_Graduation_Y1 to Rang_Derniere_Sous_Graduation_Y1 do
          trait(xmin,i*sousgraduationy1,xmax,i*sousgraduationy1,
          epaisseurgrille,couleurgrille1,psdot,pmcopy,true);
          for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
          trait(i*graduationx,ymin1,i*graduationx,ymax1,
          epaisseurgrille,couleurgrille1,psdash,pmcopy,true);
         for i:=Rang_Premiere_Graduation_Y1 to Rang_Derniere_Graduation_Y1 do
          trait(xmin,i*graduationy1,xmax,i*graduationy1,
          epaisseurgrille,couleurgrille1,psdash,pmcopy,true);

            end;
   if grille2 then begin
    image_pointee^.picture.Bitmap.canvas.pen.style:=psdot;
    image_pointee^.picture.Bitmap.canvas.pen.color:=couleurgrille2;
    image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseurgrille;
     for i:=Rang_Premiere_Sous_Graduation_X to Rang_Derniere_Sous_Graduation_X do
          trait(i*sousgraduationx,ymin2,i*sousgraduationx,ymax2,
          epaisseurgrille,couleurgrille2,psdot,pmcopy,false);
         for i:=Rang_Premiere_Sous_Graduation_Y2 to Rang_Derniere_Sous_Graduation_Y2 do
          trait(xmin,i*sousgraduationy2,xmax,i*sousgraduationy2,
          epaisseurgrille,couleurgrille2,psdot,pmcopy,false);
          for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
          trait(i*graduationx,ymin2,i*graduationx,ymax2,
          epaisseurgrille,couleurgrille2,psdash,pmcopy,false);
         for i:=Rang_Premiere_Graduation_Y2 to Rang_Derniere_Graduation_Y2 do
          trait(xmin,i*graduationy2,xmax,i*graduationy2,
          epaisseurgrille,couleurgrille2,psdash,pmcopy,false);
            end;
 {cadre}
 if cadre then begin
  trait(xmin,ymin1,xmax,ymin1,epaisseurcadre,couleurcadre,pssolid,pmcopy,true);
  trait(xmax,ymin1,xmax,ymax1,epaisseurcadre,couleurcadre,pssolid,pmcopy,true);
  trait(xmax,ymax1,xmin,ymax1,epaisseurcadre,couleurcadre,pssolid,pmcopy,true);
  trait(xmin,ymax1,xmin,ymin1,epaisseurcadre,couleurcadre,pssolid,pmcopy,true);
    end;

    {affichage du titre}
 image_pointee^.picture.Bitmap.canvas.font:=fontetitre;
 image_pointee^.picture.Bitmap.canvas.Font.Size:=abs(image_pointee^.picture.Bitmap.canvas.Font.Size);

 while   (((image_pointee^.picture.Bitmap.canvas.textwidth(titre)>largeur-borduregauche-borduredroite) or
 (image_pointee^.picture.Bitmap.canvas.textheight(titre)>bordurehaute))  and
 (image_pointee^.picture.Bitmap.canvas.Font.Size>1)) do  begin
   { application.MessageBox(pchar(inttostr(image_pointee^.picture.Bitmap.canvas.Font.Size)),
 pchar(inttostr(image_pointee^.picture.Bitmap.canvas.textwidth(titre))),mb_ok);}
 image_pointee^.picture.Bitmap.canvas.Font.Size:= image_pointee^.picture.Bitmap.canvas.Font.Size-1;
 end;
 if  image_pointee^.picture.Bitmap.canvas.Font.Size<6 then  image_pointee^.picture.Bitmap.canvas.Font.Size:=6;
 image_pointee^.picture.Bitmap.canvas.textout(largeur div 2 -(image_pointee^.picture.Bitmap.canvas.textwidth(titre) div 2),
 2,titre);
    {graduation}

    if gradue then begin

                 if dixx='0' then aff:='' else begin
                 aff:='10';
                 if dixx<>'1' then for i:=1 to length(dixx) do aff:=aff+' ';
                 aff:=aff+' ';
                 end;
                 aff:=aff+labelx;
                 if ((unitex<>'1') and (unitex<>'')) then aff:=aff+' en '+unitex;
  image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
  image_pointee^.picture.Bitmap.canvas.textout(largeur-borduredroite-trunc(image_pointee^.picture.Bitmap.canvas.textwidth
  (aff)*1.3),hauteur-bordurebasse-
  trunc(image_pointee^.picture.Bitmap.canvas.textheight('x10')*1.3),aff);
  if ((dixx<>'0') and (dixx<>'1')) then
  image_pointee^.picture.Bitmap.canvas.textout(largeur-borduredroite-trunc(image_pointee^.picture.Bitmap.canvas.textwidth(aff)*1.3)+
  trunc(image_pointee^.picture.Bitmap.canvas.textwidth('10')),hauteur-bordurebasse
  -trunc(1.9*image_pointee^.picture.Bitmap.canvas.textheight('x10')),
  dixx);




      if echelle_g then begin
       if dixy1='0' then aff:='' else begin
                 aff:='10';
       if dixy1<>'1' then   for i:=1 to length(dixy1) do aff:=aff+' ';
                 aff:=aff+' ';
                 end;
                 aff:=aff+labely1;
                 if ((unitey1<>'1') and (unitey1<>'')) then aff:=aff+' en '+unitey1;
  image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
  image_pointee^.picture.Bitmap.canvas.textout(borduregauche,bordurehaute-trunc(image_pointee^.picture.Bitmap.canvas.textheight(aff)*1.2),aff);
  if ((dixy1<>'0') and (dixy1<>'1')) then
  image_pointee^.picture.Bitmap.canvas.textout(borduregauche+image_pointee^.picture.Bitmap.canvas.textwidth('10'),bordurehaute
  -trunc(image_pointee^.picture.Bitmap.canvas.textheight(aff)*1.8),
  dixy1); end;

  if echelle_d then begin
       if dixy2='0' then aff:='' else begin
                 aff:='10';
       if dixy2<>'1' then   for i:=1 to length(dixy2) do aff:=aff+' ';
                 aff:=aff+' ';
                 end;
                 aff:=aff+labely2;
                 if ((unitey2<>'1') and (unitey2<>'')) then aff:=aff+' en '+unitey2;
  image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;
   image_pointee^.picture.Bitmap.canvas.textout(largeur-borduredroite-trunc(image_pointee^.picture.Bitmap.canvas.textwidth(aff)*1.2),
  bordurehaute-trunc(image_pointee^.picture.Bitmap.canvas.textheight(aff)*1.2),aff);
  if ((dixy2<>'0') and (dixy2<>'1')) then
  image_pointee^.picture.Bitmap.canvas.textout(largeur-borduredroite-trunc(image_pointee^.picture.Bitmap.canvas.textwidth(aff)*1.2)+image_pointee^.picture.Bitmap.canvas.textwidth('10'),
  bordurehaute
  -trunc(image_pointee^.picture.Bitmap.canvas.textheight(aff)*1.8),
  dixy2);  end;

    image_pointee^.picture.Bitmap.canvas.font:=fontegraduation;

   for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
  //str(round((i*graduationx)),tt);
 begin  tt:=floattostr(i*graduationx);
  image_pointee^.picture.Bitmap.canvas.textout(
  trunc((i*graduationx-xmin)/(xmax-xmin)*(largeur-borduredroite-borduregauche))+
  borduregauche-image_pointee^.picture.Bitmap.canvas.textwidth(tt) div 2,
  hauteur-bordurebasse+_LongueurGraduation,tt);
              end;



  if echelle_g then
  for i:=Rang_Premiere_Graduation_Y1 to Rang_Derniere_Graduation_Y1 do begin
  //str( round((i*graduationy1)),tt);
  tt:=floattostr(i*graduationy1);

      image_pointee^.picture.Bitmap.canvas.textout( borduregauche-trunc(image_pointee^.picture.Bitmap.canvas.textwidth(tt)*1.1)-5
      -_LongueurGraduation,
  trunc((ymax1-i*graduationy1)/(ymax1-ymin1)*(hauteur-bordurehaute-bordurebasse))+bordurehaute
  -image_pointee^.picture.Bitmap.canvas.textheight(tt) div 2,
  tt);
              end;

              if echelle_d then
    for i:=Rang_Premiere_Graduation_Y2 to Rang_Derniere_Graduation_Y2 do begin
  //str( round((i*graduationy2)),tt);
   tt:=floattostr(i*graduationy2);
  image_pointee^.picture.Bitmap.canvas.textout( largeur-borduredroite+_LongueurGraduation+5,
  trunc((ymax2-i*graduationy2)/(ymax2-ymin2)*(hauteur-bordurehaute-bordurebasse))+bordurehaute
  -image_pointee^.picture.Bitmap.canvas.textheight(tt) div 2,
  tt);
              end;






 if echelle_g then begin
   for i:=Rang_Premiere_Sous_Graduation_X to Rang_Derniere_Sous_Graduation_X do
          trait(i*sousgraduationx,ymin1-longueurgraduationy1,i*sousgraduationx,
          ymin1+longueurgraduationy1,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,true);

            for i:=Rang_Premiere_Sous_Graduation_X to Rang_Derniere_Sous_Graduation_X do
          trait(i*sousgraduationx,ymax1+longueurgraduationy1,i*sousgraduationx,
          ymax1-longueurgraduationy1,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,true);

            for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
          trait(i*graduationx,ymin1-2*longueurgraduationy1,i*graduationx,
          ymin1+longueurgraduationy1*2,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,true);

            for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
          trait(i*graduationx,ymax1-2*longueurgraduationy1,i*graduationx,
          ymax1+longueurgraduationy1*2,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,true);


   for i:=Rang_Premiere_Sous_Graduation_Y1 to Rang_Derniere_Sous_Graduation_Y1 do
          trait(xmin-longueurgraduationx,i*sousgraduationy1,xmin+longueurgraduationx,i*sousgraduationy1,
          epaisseurgraduation,couleurgraduation,pssolid,pmcopy,true);



  for i:=Rang_Premiere_Graduation_Y1 to Rang_Derniere_Graduation_Y1 do
          trait(xmin-2*longueurgraduationx,i*graduationy1,xmin+longueurgraduationx*2,i*graduationy1,
          epaisseurgraduation,couleurgraduation,pssolid,pmcopy,true);


           end;


    if echelle_d then begin
   for i:=Rang_Premiere_Sous_Graduation_X to Rang_Derniere_Sous_Graduation_X do
          trait(i*sousgraduationx,ymin2-longueurgraduationy2,i*sousgraduationx,
          ymin2+longueurgraduationy2,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,false);

            for i:=Rang_Premiere_Sous_Graduation_X to Rang_Derniere_Sous_Graduation_X do
          trait(i*sousgraduationx,ymax2-longueurgraduationy2,i*sousgraduationx,
          ymax2-longueurgraduationy2,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,false);

            for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
          trait(i*graduationx,ymin2-2*longueurgraduationy2,i*graduationx,
          ymin2+longueurgraduationy2*2,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,false);

            for i:=Rang_Premiere_Graduation_X to Rang_Derniere_Graduation_X do
          trait(i*graduationx,ymax2+2*longueurgraduationy2,i*graduationx,
          ymax2-longueurgraduationy2*2,epaisseurgraduation,couleurgraduation,pssolid,pmcopy,false);



     for i:=Rang_Premiere_Sous_Graduation_Y2 to Rang_Derniere_Sous_Graduation_Y2 do
          trait(xmax+longueurgraduationx,i*sousgraduationy2,xmax-longueurgraduationx,i*sousgraduationy2,
          epaisseurgraduation,couleurgraduation,pssolid,pmcopy,false);




     for i:=Rang_Premiere_Graduation_Y2 to Rang_Derniere_Graduation_Y2 do
          trait(xmax+2*longueurgraduationx,i*graduationy2,xmax-longueurgraduationx*2,i*graduationy2,
          epaisseurgraduation,couleurgraduation,pssolid,pmcopy,false);

   end;   end;
 image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;
     image_pointee^.picture.Bitmap.canvas.brush.color:=old_brush_color;
 end;






    function TMonBitmap.Convert(xi,yi:integer; var x,y:extended;gauche:boolean):boolean;
   var  ymax,ymin,pasgrilley:extended;
  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
     x:=(xi-BordureGauche)*(xmax-xmin)/ (largeur-BordureGauche-BordureDroite)
     +xmin;
     y:=-(yi-BordureHaute)*(ymax-ymin)/(hauteur-BordureHaute-BordureBasse)
     +ymax;
     convert:=true;
     end;


function TMonBitmap.invconvert(var xi,yi:integer; x,y:extended;gauche:boolean):boolean;
var ymax,ymin,pasgrilley:extended;
  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;

 xi:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 yi:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;
invconvert:=true;
end;

function TMonBitmap.CroixX(x,y:extended;
 demi_diagonale,epaisseur:integer; couleur:tcolor; penmod:tpenmode;gauche:boolean):boolean;
 var x1,y1:integer;
 ymax,ymin,pasgrilley:extended;
          old_pen_color,old_brush_color:tcolor;
 old_pen_style:tpenstyle;
 old_pen_width:integer;
 old_pen_mode:tpenmode;
    old_brush_style:tbrushstyle;


  begin
  if gauche then begin
  ymin:=ymin1; ymax:=ymax1; pasgrilley:=pasgrilley1; end else begin
   ymin:=ymin2; ymax:=ymax2; pasgrilley:=pasgrilley2; end;
 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite));
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse));
 if ((x1<=-borduregauche) or (x1>=largeur-borduregauche)
 or (y1>hauteur-bordurehaute) or (y1<-bordurehaute))
  then begin
 croixx:=false;
 exit;
 end;

 x1:= trunc((x-xmin)/(xmax-xmin)*(largeur-BordureGauche-BordureDroite))+
 BordureGauche;
 y1:=trunc((ymax-y)/(ymax-ymin)*(hauteur-BordureHaute-BordureBasse))+
 BordureHaute;

 old_pen_color:=image_pointee^.picture.Bitmap.canvas.pen.color;
 old_pen_style:=image_pointee^.picture.Bitmap.canvas.pen.style;
 old_pen_width:=image_pointee^.picture.Bitmap.canvas.pen.width;
 old_pen_mode:=image_pointee^.picture.Bitmap.canvas.pen.mode;
 old_brush_style:=image_pointee^.picture.Bitmap.canvas.brush.style;


 image_pointee^.picture.Bitmap.canvas.pen.width:=epaisseur;
  image_pointee^.picture.Bitmap.canvas.pen.mode:=penmod;
  image_pointee^.picture.Bitmap.canvas.pen.style:=pssolid;
  image_pointee^.picture.Bitmap.canvas.pen.color:=couleur;
   image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1+demi_diagonale,y1+demi_diagonale);
       image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1-demi_diagonale,y1+demi_diagonale);
        image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1+demi_diagonale,y1-demi_diagonale);
   image_pointee^.picture.Bitmap.canvas.moveto(x1,y1);
   image_pointee^.picture.Bitmap.canvas.lineto(x1-demi_diagonale,y1-demi_diagonale);
   croixx:=true;


   image_pointee^.picture.Bitmap.canvas.pen.color:=old_pen_color;
     image_pointee^.picture.Bitmap.canvas.pen.style:=old_pen_style;
     image_pointee^.picture.Bitmap.canvas.pen.width:=old_pen_width;
     image_pointee^.picture.Bitmap.canvas.pen.mode:=old_pen_mode;
     image_pointee^.picture.Bitmap.canvas.brush.style:=old_brush_style;

   end;


end.