TAILIEUCHUNG - PHP 5 Recipes A Problem-Solution Approach 2005 phần 6

Vậy đâu là những giới hạn của PHP 3 và 4? Giới hạn lớn nhất (làm nền cho các giới hạn khác) là ở chỗ ngữ nghĩa của việc sao chép (copy) trên các đối tượng không khác gì so với các kiểu native. Vậy thì điều này có tác động ra sao đến các nhà phát triển PHP? Khi bạn gán một biến (trỏ đến một đối tượng) vào một biến khác, thì một bản sao của đối tượng đó sẽ được tạo ra. | 8-5 CREATING AND USING COLORS 329 How It Works This particular example is a matter of aesthetics. By using the imagefilledrectangle function you create what is essentially a white image with a 1-pixel line around the edge. This will serve as the basic template for outputting the bar graph which we will explain in more detail in the next example. The prototype for imagefilledrectangle is as follows int imagefilledrectangle resource img int x1 int y1 int x2 int y2 int color Figure 8-4 shows some output of recipe 8-4. Figure 8-4. Output of recipe 8-4 8-5. Creating and Using Colors Because we are dealing with a graphical topic the concept of what color to display it in is a rather important one. As mentioned colors for dynamic imaging are handled in an RGB method. To apply colors to a particular element of a dynamic image you must first allocate the color to a variable resource that can then be used on other image elements. You use the imagecolorallocate function to facilitate this necessity. The following example shows how to start using the new colors to create a title for the graph. 330 8-5 CREATING AND USING COLORS The Code php The first thing you do is check for GD compatibility. try First you create a blank canvas. if animage imagecreate 500 500 Now let s allocate the background color and line color. Here is the way to do it with RGB. white imagecolorallocate animage 255 255 255 And here is an example with hex. black imagecolorallocate animage 0x00 0x00 0x00 Now let s draw the rectangle over the background and surround it with a black line. imagefilledrectangle animage 0 0 500 500 black imagefilledrectangle animage 1 1 498 498 white Now let s create some more colors for the title. blue imagecolorallocate animage 0 0 255 green imagecolorallocate animage 0 255 0 Now let s center the text at the top of the image. title A Sample Poll imagestring animage 4 500 - strlen title imagefontwidth 4 2 5 title blue copy Copyright Lee Babin imagestring animage 4 .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.