Janhouse Posted September 15, 2005 Report Share Posted September 15, 2005 Tatad Ideja tada. Bilde parveidota ar PHP + GD2. Kalendārs un kalendārā dienu īsto norāda rāmītis, kurš tiek apvilkts ap kalendāru. Lai rāmītis būtu īstajā vietā, īstajā laikā, vajag ramītim norādīt X un Y koordinātas. Ideja tāda, ja ir mēneša 04., 11., 19., 25 diena, tad rāmīša X koordinātas ir 751. Būtu jau labi, bet mana ideja nestrādā un laikam dēļ tās kļūdainās IF (... daļas. :) Ja kāds var izlabot šo kodu, vai ieteikt ko citu, lūdzu palīdziet! $diena=date("d");$parbaudeX1 = array( '' => '04', '' => '11', '' => '19', '' => '25'); if ($diena==$parbaudeX1){ $dst3_x=751; } Esmu iesacejs, bet esmu ari sarezgitakas lietas taisijis. Jocīgi, ka nemāku šito iedarbināt. :) Link to comment Share on other sites More sharing options...
v3rb0 Posted September 15, 2005 Report Share Posted September 15, 2005 (edited) vispirms http://lv.php.net/array un http://lv.php.net/manual/en/language.types.array.php Edited September 15, 2005 by v3rb0 Link to comment Share on other sites More sharing options...
Delfins Posted September 15, 2005 Report Share Posted September 15, 2005 1.) kalendāra dienas ieliekam iekš 2D masīva (Week,Day) 2.) sameklējam/atceramies kurā šūnā `sēž` izvēlētā/tekošā diena 3.) aprēķināt rāmja pozīzciju ir vareni vienkārši pēc šūnas koordinātes $X = $DayId * $CellWidth; $Y = $WeekNum * $CellHeight; foreach ( $monthDays AS $weekId => $weekData ) { foreach ( $weekData AS $dayId => $dayNum ) { $X = $DayId * $CellWidth; $Y = $WeekNum * $CellHeight; $color = ( $dayNum == $currentDayNum ) ? $curColor : $defColor; imagerectangle( $im, $color, $X, $Y, $X+cellWidth, $Y+$CellHeight ); imagestring( $im, 4, $color, ceil($X/2)-ceil(strlen($dayNum)/2), ceil($Y/2) ); } } Link to comment Share on other sites More sharing options...
Janhouse Posted September 15, 2005 Author Report Share Posted September 15, 2005 (edited) eeeee..... Man raamis ir nevis, kaa kvadratins, bet gan kaa PNG bilde. Un tapec es negribu likt taa, kaa tu paradiji to, bet es meginasu kaut ko izlabot. Un es velos saprastu kur ir kluuda tajaa ko es rakstiju. Tapec butu labi, ja kads varetu to manu kodinu vienkarsi izlabot. Viss, ko es velos saprast ir kaa to array iesaistit pie IF kipa if ($123=="1","2",3""... Cik saprotu taa, kaa te tikko uzrakstiju nekas nesanaks, tapec ar array meginaju, bet ari nesanaca. LUDSU izlabojiet kludu. Edited September 15, 2005 by Janhouse Link to comment Share on other sites More sharing options...
Delfins Posted September 15, 2005 Report Share Posted September 15, 2005 Kāda starpība, vai tas ir Rectangle vai bilde!???? Svarīgi ir tas ka es tev iedevu, kā aprēķināt pozīciju bez visādiem IF-iem! imagecopyresampled( $imSource, $imDest, .... ); Link to comment Share on other sites More sharing options...
Janhouse Posted September 15, 2005 Author Report Share Posted September 15, 2005 Vai tik es neatradu atbildi!!! :) if (in_array($diena, $parbaudeX1)) Izmeginasu tulit. :) Link to comment Share on other sites More sharing options...
Delfins Posted September 15, 2005 Report Share Posted September 15, 2005 njā, nelabojams tipiņš... PS: parādi visu kodu, kas tev tur ir... tīri intereses pēc... :) Link to comment Share on other sites More sharing options...
Janhouse Posted September 15, 2005 Author Report Share Posted September 15, 2005 Gatavs! Paldies jums es to delfina kodu gan velak izmeginasu, bet pats tiku ar savu galaa. :) Te rezultats. http://janhouse.miracle.lv/mob/uploaded/avatar/kalendars/ un piedod, bet visu kodu nedosu. Vel kads piesavinasies autortiesibas. :D Varat sleegt ciet. :) Link to comment Share on other sites More sharing options...
Delfins Posted September 15, 2005 Report Share Posted September 15, 2005 nu smuki, tikai tas tavs kalendars jau ne ar PHP tika drukāts? (shadow izmantots) Link to comment Share on other sites More sharing options...
Janhouse Posted September 15, 2005 Author Report Share Posted September 15, 2005 Protams, ka ne tikai ar PHP. Php visu tikai saliek kopaa un parvieto. ;) Tur 4 bildes apvieno vienaa. 1. apaksaa - fons (JPG) 2. saana - tas oranzais izzudosais sturitis (PNG ar transparency) 3. ramitis - parada dienu (PNG ar transparency) 4. spidums - atrodas virs oranzaa sturisa un virs ramisa (PNG ar transparency) PHP katru menesi mainis bildi un katru dienu radis isto dienu. Velak piekodesu klat ari tadu funkciju, kaa vardadienas un ja man izdosies sarunat kaut ko ar meteo.lv, lai vini man iedod iespeju paradit gaisa temperaturu riigaa, tad ari to. Tad jau manis. :D Un tad tikai cilvekiem bus jaizdoma, kaa uzlikt, lai katru dienu tas wallpaperis refreshojas no manas lapas. Pasam negribaas ari tadu progu taisit. ja kads tadu zin, iesakiet. Link to comment Share on other sites More sharing options...
Delfins Posted September 15, 2005 Report Share Posted September 15, 2005 (edited) http://no.good.lv/testi/gdcalendar.php Kods ir `uz ātro` <?php function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) { // draw rectangle without corners imagefilledrectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color); imagefilledrectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color); // draw circled corners imagefilledellipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color); imagefilledellipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color); imagefilledellipse($im, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color); imagefilledellipse($im, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color); } $firstDate = mktime( 0, 0, 0, date('m'), 1, date('Y') ); $firstDateArr = getdate( $firstDate ); $firstDay = $firstDateArr['wday']; $monthDayCnt = date('t'); $monthDays = Array(); $i = $j = 0; for ( $w=0; $w<5; $w++ ) { for ( $d=0; $d<7; $d++ ) { $i = $j - $firstDay+2; $ics = ( $i > 0 && $i<=$monthDayCnt ) ? $i : ''; $monthDays[$w][$d] = sprintf( '%02d', $ics ); $j++; } } //print_r($monthDays); $imageHeight = 500; $imageWidth = 800; $cellWidth = 100; $cellHeight = 80; $cellPitch = 10; $marginSize = 10; $currentDayNum = date('d'); $im = imagecreate( $imageWidth, $imageHeight ); $bgColor = imagecolorallocate( $im, 230, 230, 230 ); $cellColor = imagecolorallocate( $im, 170, 170, 170 ); $cellCurrColor = imagecolorallocate( $im, 100, 100, 150 ); $textColor = imagecolorallocate( $im, 255, 255, 255 ); foreach ( $monthDays AS $weekId => $weekData ) { foreach ( $weekData AS $dayId => $dayNum ) { $y = $marginSize + $weekId * ($cellHeight + $cellPitch); $x = $marginSize + $dayId * ($cellWidth + $cellPitch); $h = $x + $cellWidth; $w = $y + $cellHeight; if ( $dayNum == 0 ) { $color = $bgColor; } else { if ( $dayNum == $currentDayNum ) { $color = $cellCurrColor; } else { $color = $cellColor; } ImageRectangleWithRoundedCorners( $im, $x, $y, $h, $w, 5, $color ); imagestring( $im, 5, $x + ceil($cellHeight/2), $y-$cellPitch+ceil($cellHeight/2), $dayNum, $textColor ); } } //break; } header('Content-Type: image/png'); imagepng($im); ?> Edited September 15, 2005 by Delfins Link to comment Share on other sites More sharing options...
Delfins Posted September 15, 2005 Report Share Posted September 15, 2005 (edited) ^^ UPDATED PS: sory, parnākšu mājās, pārkompilēšu PHP :) izrādās no-jpeg support... :/ Fonā tagad ir wallpapers smuks :) Edited September 15, 2005 by Delfins Link to comment Share on other sites More sharing options...
Recommended Posts