TAILIEUCHUNG - Lập trình iphone chuyên nghiệp part 11

Drawing an Image Ngoài đường và hình dạng khác, bạn cũng có thể vẽ lên một hình ảnh canvas của bạn bằng cách sử dụng drawImage () phương pháp. Các hình ảnh có thể tham khảo hoặc là một hình ảnh bên ngoài hoặc yếu tố khác vải trên trang. | Chapter 6 Advanced Programming Topics Canvas and Video Drawing an Image In addition to lines and other shapes you can also draw an image onto your canvas by using the drawlmage method. The image can reference either an external image or another canvas element on the page. There are actually three ways in which you can call this method. The first variant simply draws an image at the specified coordinates using the size of the image image x y The second method enables you to specify the dimensions of the image with the w and h arguments image x y width height To do a basic image draw define the Image object and assign an src. Next you want to draw the image but only after you are certain the image is fully loaded. Therefore the drawlmage method is placed inside of the image s onload handler DOCTYPE html PUBLIC - W3C DTD XHTML Strict EN http TR xhtml1 DTD html xmlns http 1999 xhtml head title Draw Image title meta name viewport content width 320 initial-scale maximum-scale user-scalable 0 script type application x-javascript function drawImg var canvas myCanvas var context 2d var img new Image images function img 0 0 script head body onload drawImg canvas id myCanvas width 300 height 300 style position absolute left 0px top 0px z-index 1 body html Figure 6-4 shows the image displayed inside of the canvas. Keep in mind that this is not an HTML img element but the external image file drawn onto the context of the canvas. 131 Chapter 6 Advanced Programming Topics Canvas and Video Figure 6-4 Drawing an image onto the canvas Additionally there is a final drawImage option that is slightly more complex image sourcex sourcey sourceWidth sourceHeight destx desty destWidth destHeight In this variant the method draws a subsection of the image specified by the source rectangle sourcex .

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.