GD - variabele per blokje
Ik wil dat per blokje (rectangle) er 1 kleur wordt bepaald vanuit de database. Hij moet dus zelf achterhalen wat de kleur moet worden.
Deze is afhankelijk van de groep waar iemand in zit.
Hoe kan ik zoiets doen, want ik ben nog niet zo bekend met GD, al vindt ik het wel leuk werken.
Code (php)
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
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
<?php
$x = 40 ;
$y = 40 ;
$img = imagecreatefromjpeg('belgie.jpg');
$c1 = imagecolorallocatealpha($img, 255,0,0, 20);
$black = ImageColorAllocate($img,0,0,0);
//Horizontale-lijnen
imageline($img, 0, $y+0.5*$y, 7.5*$x, $y+0.5*$y, $black);
imageline($img, 0, 2*$y+0.5*$y, 7.5*$x, 2*$y+0.5*$y, $black);
imageline($img, 0.5*$x, 3*$y+0.5*$y, 8.5*$x, 3*$y+0.5*$y, $black);
imageline($img, 1.5*$x, 4*$y+0.5*$y, 8.5*$x, 4*$y+0.5*$y, $black);
imageline($img, 2.5*$x, 5*$y+0.5*$y, 7.5*$x, 5*$y+0.5*$y, $black);
imageline($img, 4.5*$x, 6*$y+0.5*$y, 7.5*$x, 6*$y+0.5*$y, $black);
//Verticale-lijnen
imageline($img, $x, 0, $x, 3.5*$x, $black);
imageline($img, 2*$x, 0, 2*$x, 4.5*$y+0.5*$y, $black);
imageline($img, 3*$x, 0, 3*$x, 5.5*$y+0.5*$y, $black);
imageline($img, 4*$x, 0, 4*$x, 5.5*$y+0.5*$y, $black);
imageline($img, 5*$x, 0, 5*$x, 8.5*$y+0.5*$y, $black);
imageline($img, 6*$x, 0, 6*$x, 8.5*$y+0.5*$y, $black);
imageline($img, 7*$x, 0.5*$y+0.5*$y, 7*$x, 8.5*$y+0.5*$y, $black);
imageline($img, 8*$x, 0, 8*$x, 8.5*$y+0.5*$y, $black);
//Rij 1
$v = 0;
$w = 1;
ImageFilledRectangle ($img,0*$x,$v*$y+0.5*$y,1*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,1*$x,$v*$y+0.5*$y,2*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,2*$x,$v*$y+0.5*$y,3*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
//Rij 2
$v = 1;
$w = 2;
ImageFilledRectangle ($img,0*$x,$v*$y+0.5*$y,1*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,1*$x,$v*$y+0.5*$y,2*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,2*$x,$v*$y+0.5*$y,3*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
//Rij 3
$v = 2;
$w = 3;
ImageFilledRectangle ($img,1*$x,$v*$y+0.5*$y,2*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,2*$x,$v*$y+0.5*$y,3*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
//Rij 4
$v = 3;
$w = 4;
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
//Rij 5
$v = 4;
$w = 5;
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
imagePng($img);
imageDestroy($img);
?>
$x = 40 ;
$y = 40 ;
$img = imagecreatefromjpeg('belgie.jpg');
$c1 = imagecolorallocatealpha($img, 255,0,0, 20);
$black = ImageColorAllocate($img,0,0,0);
//Horizontale-lijnen
imageline($img, 0, $y+0.5*$y, 7.5*$x, $y+0.5*$y, $black);
imageline($img, 0, 2*$y+0.5*$y, 7.5*$x, 2*$y+0.5*$y, $black);
imageline($img, 0.5*$x, 3*$y+0.5*$y, 8.5*$x, 3*$y+0.5*$y, $black);
imageline($img, 1.5*$x, 4*$y+0.5*$y, 8.5*$x, 4*$y+0.5*$y, $black);
imageline($img, 2.5*$x, 5*$y+0.5*$y, 7.5*$x, 5*$y+0.5*$y, $black);
imageline($img, 4.5*$x, 6*$y+0.5*$y, 7.5*$x, 6*$y+0.5*$y, $black);
//Verticale-lijnen
imageline($img, $x, 0, $x, 3.5*$x, $black);
imageline($img, 2*$x, 0, 2*$x, 4.5*$y+0.5*$y, $black);
imageline($img, 3*$x, 0, 3*$x, 5.5*$y+0.5*$y, $black);
imageline($img, 4*$x, 0, 4*$x, 5.5*$y+0.5*$y, $black);
imageline($img, 5*$x, 0, 5*$x, 8.5*$y+0.5*$y, $black);
imageline($img, 6*$x, 0, 6*$x, 8.5*$y+0.5*$y, $black);
imageline($img, 7*$x, 0.5*$y+0.5*$y, 7*$x, 8.5*$y+0.5*$y, $black);
imageline($img, 8*$x, 0, 8*$x, 8.5*$y+0.5*$y, $black);
//Rij 1
$v = 0;
$w = 1;
ImageFilledRectangle ($img,0*$x,$v*$y+0.5*$y,1*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,1*$x,$v*$y+0.5*$y,2*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,2*$x,$v*$y+0.5*$y,3*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
//Rij 2
$v = 1;
$w = 2;
ImageFilledRectangle ($img,0*$x,$v*$y+0.5*$y,1*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,1*$x,$v*$y+0.5*$y,2*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,2*$x,$v*$y+0.5*$y,3*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
//Rij 3
$v = 2;
$w = 3;
ImageFilledRectangle ($img,1*$x,$v*$y+0.5*$y,2*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,2*$x,$v*$y+0.5*$y,3*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
//Rij 4
$v = 3;
$w = 4;
ImageFilledRectangle ($img,3*$x,$v*$y+0.5*$y,4*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
//Rij 5
$v = 4;
$w = 5;
ImageFilledRectangle ($img,4*$x,$v*$y+0.5*$y,5*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,5*$x,$v*$y+0.5*$y,6*$x,$w*$y+0.5*$y,$c1);
ImageFilledRectangle ($img,6*$x,$v*$y+0.5*$y,7*$x,$w*$y+0.5*$y,$c1);
imagePng($img);
imageDestroy($img);
?>
De kleuren in de database zijn in hex, maar het omzetten lukt wel, wil alleen weten hoe ik per vakje een kleur gehaald uit database kan maken
Ik begrijp niet helemaal wat je wil maar als je gewoon per vakje een ander kleurtje wilt moet je gewoon ee while{.. } functie gebruiken en dan random selecteren