整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          52天奇速記完高考3500詞匯第15天

          52天奇速記完高考3500詞匯第15天

          . corn popcorn wheat born corner

          記憶:1. corn [ kC:n ] n. <美>玉米The young corn is delicious.嫩玉米非??煽?。

          2. popcorn [ 5pCpkC:n ] n. 爆米花 Popcorn is popular with various people.爆米花受到各種人的歡迎。

          3. wheat [ wi:t, hw- ] n. 小麥 Bread is mainly made from wheat.面包主要是用小麥做的。

          4. born [ bC:n ] adj. 天生的, 出生 Could you tell me when Luxun was born?你能告訴我魯迅是什么時候出生的嗎?

          5. corner [ 5kC:nE ] n. 角落, (街道)拐角處, 偏僻處, 困境vt.使陷入絕境, 把...難住Children’s Day is just around the corner. 兒童節就要到了。around the corner 很快的,臨近的 in the corner在角落里 at/on the corner在拐角處

          另類閱讀:The born cook in the corner can cook corn and wheat in scores of ways.

          2. correct correction incorrect direct direction indirect rectangle

          記憶詞根rect [ 5rektE ]含義是“正,直”

          1. cor是con的變體,correct [ kE5rekt ] adj.正確的 vt. 糾正 You should correct the mistakes in your writing.你應糾正你寫作中的錯誤。

          2. correction [ kE5rekFEn ] n. 糾正 The correction is necessary for our development.在我們的發展過程中糾正錯誤是必不可少的。

          3. incorrect [ 7inkE5rekt ] in-correct adj. 不正確的I’m sorry your answer is incorrect.恐怕你的答案并不正確。

          4. direct [ di5rekt, dai5rekt ] di-rect vt. 指導(讓做正確),指點 adj. 直接的Who directs the firm these days?現在誰當導演?

          5. direction [ di5rekFEn, dai5rekFEn ] n. 方向,指導 The travelers come in all directions.旅客來自四面八方。

          6. director [ di5rektE, dai5rektE ] n. 主任, 主管, 導演 Mr. Zhang Yimou has set up his status as a successful director.張藝謀先生作為一名成功的導演已確立了他的地位。

          7. indirect [ 7indi5rekt, indai5rekt ] adj. 間接的 The teacher just gave us an indirect answer.老師只是給了我們一個間接的回答。

          8. rectangle [ 5rektAN^l ] rect-angle(角)n. 正方形(四個角都是直角) Can you draw a rectangle with one hand and a circle with the other?你能一手畫方一手畫圓嗎?

          另類閱讀:After the boy corrected the rectangle he drew, the teacher saw no incorrect lines. She praised him and gave him more directions.

          3. success succeed successful successfully unsuccessful successor excess proceed process procedure access accessible

          記憶:1. 詞根ced, ceed, cess, 含義是“行,讓步”前綴suc 即sub的變體,下面,success [ sEk5ses ] 走在了下面,成功, Everyone is after success. But success belongs to those who use both his hands and brains.每個人都在追逐成功,但成功屬于那些既動手又動腦的人。

          2. succeed [ sEk5si:d ] vi, 成功, 繼...之后, 繼任 注意: succeed in doing something. Finally we succeeded in getting to the top.最后我們成功地到達了頂峰。

          3. successful [ sEk5sesful ] adj. 成功的 Many factors make a successful writer.多種因素造就了一名成功的作家。

          4. successfully [sEk5sesfJlI] adv. 成功地 China has launched manned space travel successfully.中國已成功地進行了載人太空飛行。

          5. unsuccessful [ 5QnsEk5sesful ] adj. 不成功的 The project turned out to be unsuccessful.那項工程結果并不成功。

          6. successor [ sEk5sesE ] n.繼承者, 接任者, 后續的事物 The successors of the films are not all successful. 電影的續集并非都成功。

          7. ex- 表示“out”, excess [ ik5ses, 5ekses ] n. & v. 過度,超過 The noise is in excess of what we can stand.我們受不了那噪音。

          8. pro- 表示“向前” proceed [ prE5si:d ] To go forward or onward, especially after an interruption vi.進行, 繼續下去, 發生 The speech contest proceeded. 演講比賽繼續。

          9. process [ prE5ses ] A series of actions, changes, or functions bringing about a result n. 過程, 作用, 方法 vt.加工, 處理 I’m afraid the process is too complicated for you.恐怕這種方法對你過于復雜。

          10. procedure [ prE5si:dVE ] A manner of proceeding n.程序, 手續 Finishing the procedure, he felt too tired. 完成手續后,他感到太累。

          11. access [ 5Akses ] ac-cess n. 通路, 訪問, 入門 vt.存取, 接近 No access to the house is given to common civilians.普通人不許進那房子。

          12. accessible [ Ek5sesEbl ] adj. 易接近的, 可到達的, 易受影響的, 可理解的 The palace is not accessible for us.那宮殿我們去不了。

          4.cough fever headache backache suffer suffering ill illness sick sickness dizzy disease patient patience bacterium virus

          記憶:1. cough [ kC:f ] co,音“咳”,咳嗽 Every one of us has ever suffered from cough.我們每個人咳嗽過。

          2. fever [ 5fi:vE ] n. 發燒, 發熱, 狂熱 The boy is running a high fever. Send for a doctor at once!孩子在發高燒。馬上找醫生來!

          3. headache [5hedeIk] n.頭疼 Is the war in Iraq a glory or a headache for Jorge W Bush?伊拉克戰爭對布什來說是榮光還是頭疼?

          4. backache [5bAkeIk] n. 背疼 The backache makes it hard to turn over.背疼之后,翻身不便。

          5. suffer [ 5sQfE ] suf-fer vt.遭受, 經歷, 忍受 vi.受痛苦, 受損害 Whenever a war breaks out, it’s the civilians who suffer.每一場戰爭都是老百姓遭殃。

          6. suffering [ 5sQfEriN ] n. 痛苦 Who brought all these sufferings to the ordinary people?是誰把這些痛苦加在老百姓身上的?

          7. ill [ il ] adj. 有病的(作表語), 壞的, 惡意的 Hearing the ill boy fell ill, we couldn’t help having a pity over him.聽說那個愛搗亂的男子病倒了,我們還是忍不住同情他。

          8. illness [ 5ilnis ] Disease of body or mind; poor health n. 病 The leaves of it can help cure many illnesses. 它的葉子有助于治療多種疾病。

          9. sick [ sik ] adj. 不舒服, 有病的, 惡心的, 厭惡的 I’m sick of his dull and empty talk. 對討厭他的空洞單調的講話。

          10. sickness [ 5siknis ] The condition of being sick; illness n. 病 Fortunately his sickness is not serious.幸運的是他的病不嚴重。

          11. disease [ di5zi:z ] ease, 安逸, 安心 disease, 不安逸,有病 n. 病 Doctors deal with physical diseases. Then, who can deal with social diseases?醫生解決身體毛病,那么,誰能解決社會毛病?

          12. dizzy [ 5dizi ] 聯想disease, 有病的人頭暈的。 adj. 暈眩的, 昏亂的 Looking down from the tower top, I found myself dizzy.在塔頂上往下看,我頭暈目眩。

          13. patient [ 5peiFEnt ] n. 病人, 患者 adj. 忍耐的, 耐心的 The doctor is supposed to be patient to any patient.醫生對任何病人都應該有耐心。

          14. patience [ 5peiFEns ] n. 耐心 Patience is one of the conditions of the final success. 耐心是最終成功的條件之一。 格言: Patience is a virtue.耐心即是寶。

          15. bacterium [ bAk5tiEriEm ] n. 細菌 注意復數:bacteria Bacteria are almost everywhere.細菌幾乎無處不在。

          16. virus [ 5vaiErEs ] n. 病毒 People have found the virus causing SARS.人們發現了引起非典的病毒。

          5.count counter account accountant discount county country

          記憶:1. count [kaJnt] n. 數, 計算 Having counted the books, he realized they were far from enough.他數完書后,意識到它們遠遠不夠。

          2. counter [ 5kauntE ] n.計算器, 計數器, 計算者, 柜臺 The customer can drink by the counter of the bar.顧客可在在酒吧的柜臺邊喝酒。

          3. account [ E5kaunt ] ac-count n.計算, 帳目, 說明, 理由 vi. 說明 The accounts are very clear. 帳目非常清楚。He paid the money into his bank account.

          4. accountant [ E5kauntEnt ] account-ant n.會計(員), 會計師 The accountant’s innocence has been proved once more.會計的清白又一點得到證實。

          5. discount [ 5diskaunt ] dis-count n.折扣 The more you buy, the larger discount we can offer. 你買得越多,我們給你打折越多。

          6. country [ 5kQntri ] n. 國家, 國土 It’s everyone’s duty to protect his country. 保衛祖國,匹夫有責。

          7. county [ 5kaunti ] n. 縣 Shuangliu is one of the richest counties in Sichuan Province.雙流是四川省最富的縣之一。

          6.course cause result consequence effect effective affect affection perfect influence effort

          記憶:1. course [ kC:s ] n. 過程, 進程, 路線, 課程, 一道菜 He was quite doubtful during the course of the experiment.在實驗過程中他一直都很懷疑。

          2. cause [ kC:z ] n. 原因, 事業 vt.引起 What caused him to act so rashly?什么東西使得他行動如此草率?

          3. result [ ri5zQlt ] n. 結果, 成效, 計算結果 vi. 起因, 由于, 導致 result in以...為結果,result from 起因于 What you are today is the result of what you did yesterday.你今天的狀況是你昨天行動的結果。

          4. consequence [ 5kCnsikwEns ] con-sequ-ence 詞根sequ, 即follow, consequence, 跟在后面的, n.結果, 推理 If you continue this way, you must consider its consequence.如果你繼續這樣,你要考慮它的后果。

          5. effect [ i5fekt ] 詞根fect 含義為“做,創造”,前綴e-, 表示“出”,effect, 做出來的,n.結果, 效果, 作用, 影響 The medicine has no effect on my cold.這種藥對我的感冒不起作用。

          6. effective [ i5fektiv ] adj. 有效的 Some effective measure must be taken at once.必須馬上采取有效措施。

          7. affect [ E5fekt ] 前綴af-即ab-的變體,vt.影響, 感動 When we are quiet in heart, nothing outside can affect us.心靜自然涼。

          8. affection [ E5fekFEn ] n.友愛, 愛情, 影響 How can I show my deep affection to her?我怎樣才能表達對她的深深愛戀呢?

          9. perfect [ 5pE:fikt ] 前綴per- 表示“完成”,perfect,做完了的,完美的 Nothing is perfect and nobody is perfect.金無赤足,人無完人。

          10. influence [ 5influEns ] in-flu-ence, 詞根flu表示“流動”,influence, 在里面流過,有影響,n.影響 vt.影響, 改變 His experiences in his childhood influenced him more than anything else.他童年時代的經歷對他影響最大。

          11. effort n. 努力 Great efforts should be made to ensure the project goes on well.應該付出努力保證工程的順利進行。

          7.cover discover discovery discoverer uncover expose betray detect detective recover lid

          記憶:1. cover [ 5kQvE ] n. 蓋子, 封面 vt. 覆蓋,報道 What do you think of the phenomenon that beautiful women take up nearly all magazine covers? 美女幾乎占據了所有的雜志封面,你對這一現象怎么看? 格言:You can't tell a book by its cover. 不能以貌取人。

          2. discover [ dis5kQvE ] vt. 發現, 發覺 Some people doubt whether it is Columbus who first discovered America.一些人懷疑是不是由哥倫布首先發現美洲的。

          3. discovery [ dis5kQvEri ] n. 發現 His discovery resulted in a industrial revolution.他的發現引起了一場工業革命。

          4. discoverer [ dis5kQvErE ] n. 發現者 Who was the discoverer of Radium?誰是鐳的發現者?

          5. uncover [ Qn5kQvE ] vt.揭開, 揭露 Uncovering the basket, she was moved to find her favorite fish there.她揭開籃子,發現里面是她最愛吃的魚,很受感動。

          6. recover [ ri5kQvE ] re-cover vi. 痊愈, 復原 I hope you can recover soon.我希望你很快康復。

          7. expose [ iks5pEuz ] 詞根pose表示“放”;ex-, 外;expose, 放在外面,vt.使暴露, 使曝光 As a reporter, I think it’s my duty to expose the scandal and praise the kindness.作為記者,我認為我有責任揚善懲惡。

          8. betray [ bi5trei ] be-tray vt.出賣, 背叛, 泄露 When you betray your motherland, you are not worthy of being human.如果你背叛祖國,你就不是人。

          9. detect [ di5tekt ]  詞根tect含義是“遮蔽,掩蓋”;前綴de-含義為“反,去”,detect, 去掉遮掩,探測,偵探 In my childhood, I dreamed that I could invent some equipment to detect mushrooms in the wild.童年時候,我夢想我能發明一種設備來探測野外的蘑菇。

          10. detective [ di5tektiv ] n. 偵探 Holms is the best-known detective. However, he was not a real man.福爾摩斯是最有名的偵探,但他卻非真人。

          11. protect [ prE5tekt ] 前綴pro-為“先”,事先遮蓋起來,保護 Everyone should form the sense of protecting life, no matter whose it is.每個人都應有保護生命的意識,不論那是誰的生命。

          12. lid [ lid ] n. 蓋子 Sorry, but the lid refuses to be removed. 對不起,但蓋子挪不動。

          8;cream scream stream butter milk yoghurt

          記憶:1. cream [ kri:m ] n. 乳酪, 奶油, (護膚)面霜 Cream is rich in fat. You’d better not have too much.奶油富含脂肪,你最好不要吃得太多。

          2. scream [ skri:m ] v. 尖聲叫, 尖聲喊叫 n. 尖叫聲, 喊叫聲 The girl screamed at the sight of the snake.一看到蛇,女孩驚叫起來。

          3. stream [ stri:m ] n. 溪, 川, 流, 一股 The water in that stream is quite clear and sort of sweet.那小溪里的水清徹見底,有點甜。

          4. butter [ 5bQtE ] n. 黃油, 牛油 The birthcake is covered with butter.生日蛋糕上面覆蓋著一層黃油。

          5. milk [ milk ] n. 乳, 牛奶 v. 擠(奶) A cup of milk a day keeps the doctor away.一天一杯牛奶,醫生不用再見。

          6. yoghurt [`jC^Et,`jEJ-] n. 酸乳 Yoghurt has become popular because of its special taste.酸乳因其味道獨特而受人喜愛。

          9. crop drop stop fall fell felt

          記憶:1. crop [ krCp ] n. 農作物 vt. 收割 Not every farmer lives on crops.并非每個農民都以莊稼為生。

          2. drop [ drCp ] d, 音“滴,掉”,v.滴下, 落下 n. 落下, 下降, 滴 You can’t drop English though your English is quite poor at present.雖然你目前英語差,但是你不能放棄英語。

          3. drip [ drip ] n. 水滴 v. (使)滴下 Some water is dripping from the roof.一些水正從屋頂上滴下來。

          4. stop [ stCp ] n. 停止, 車站 vi. 停止 Nobody can stop me loving my country. 沒人能阻攔我愛我的祖國!

          5. fall [ fC:l ] n. 秋天, 落下 vi. 倒下, 落下 Four fools fell asleep on a fall afternoon. 在一個秋天下午四個傻瓜睡著了。 fall to the ground掉到地上 fall off sth從……上掉下來 fall ill生病了 fall asleep睡著了 fall in love with sb愛上

          6. fell [ fel ] vt. 砍伐 How can you fell so many trees at a time?你一次怎能砍倒那么多樹?

          7. felt [ felt ] feel的過去式,感到 I felt embarrassed when I saw her.我看到她時感到有些尷尬。

          10. crowd crowded squeeze coward people population popular populous

          記憶:1. crowd [ kraud ] n. 人群, 一堆(東西), 一伙 v. 群集, 擁擠 Don’t crowd! Wait in line and everyone can get what he wants.別擠!排好隊,每個人都能得到他想要的東西。

          2. crowded [ 5kraudid ] adj. 擁擠的, 塞滿的 The buses used to be too crowded when holidays came.過去當假期來臨的時候,公共汽車曾很擁擠。

          3. squeeze [ skwi:z ] v. 壓榨, 擠, 擠榨 Don't squeeze my finger. It hurts!別擠壓我的手指,很疼!

          4. coward [ 5kauEd ] cow, 奶牛;d, 音“倒”, coward, 看見溫順的奶牛呵也倒的人,膽小鬼;n.懦弱的人, 膽小的人 A young rat scared him so! I have never seen such a coward.一只小老鼠就把他嚇成這樣!我從來沒有見過這樣膽小的人。

          5. people [ 5pi:pl ] n. 人們 The government should be of the people, by the people and for the people.政府應是民有,民治,民享。

          6. population [ 7pCpju5leiFEn ] popul表示人;population, 人口 What’s the population in your hometown? 你家鄉有多少人?

          7. 加形容詞后綴-ar, popular [ 5pCpjulE ] adj. 通俗的, 流行的, 受歡迎的 When scientists are more popular than the singers with the young, the nation will be unconquerable. 如果科學家比歌手更受年輕人歡迎,那么這個民族是不可戰勝的。

          8. 加表示“充滿”的形容詞后綴-ous, populous [ 5pCpjulEs ] adj. 人口多的, 人口稠密的 Big cities are often populous.大城市常常人口稠密。

          11. slave slavery cruel cruelty savage kind mercy merciful

          記憶:1. slave [ sleiv ] n. 奴隸 Slaves should be liberated both politically and mentally.奴隸既要從政治上解放,也要從精神上解放。 格言: Do business,but be not a slave to it.要做事,但不要做事務的奴隸。

          2. slavery [ 5sleivEri ] n. 奴隸身分, 奴隸制度 The slavery should be abolished completely.應該徹底廢除奴隸制。

          3. cruel [ 5kruEl ] 音似“刻肉”,在肉體上刻劃,殘酷;adj. 殘酷的, 悲慘的 What made a young boy with such a cruel heart?什么東西使得一個小男孩心腸如此殘忍?

          4. cruelty [5kru:EltI] n. 殘忍, 殘酷 The mercy on the devil is the cruelty to the kind.對壞人的同情就是對好人的殘忍。

          5. savage [ 5sAvidV ] sav-age sav-音似“殺無”,殺的一個不留,野蠻兇狠 adj. 野蠻的, 兇猛的, 殘忍的 Be careful of the savage in the area.當心這一帶的野人。

          6. kind [ kaind ] adj. 善良的 The kind shouldn’t be regard as the weak.善良不應被看作是軟弱。 be kind to sb It’s kind of sb to do sth

          7. mercy [ 5mE:si ] mer-cy聯想:妹兒是有同情心的, n. 仁慈, 寬恕, 憐憫 Have mercy on others and you will get more in the future.對別人有同情心,你將得到更多的回報。

          8. merciful [ 5mE:siful ] adj. 仁慈的, 慈悲的 A merciful heart is to be treasured.應珍惜仁慈之心。

          12. cry tear sob weep laugh laughter smile

          記憶:1. cry [ krai ] vi. 哭, 流淚 n. 叫, 喊 n. 哭泣, 喊聲 It’s no use crying over spilt milk.后悔無用。

          2. tear [ tiE ] n. 眼淚, vi. 流淚, 撕破 [tZE] vt. 扯, 撕 Life doesn’t believe tears.生活不相信眼淚。

          3. sob [ sCb ] n. 嗚咽, 哭泣 n. 嗚咽, 哭泣 The boy is still sobbing. He will get better soon.男孩還在抽泣。他不久會好一些。

          4. weep [ wi:p ] n. 哭, 哭泣, 滴下 vi. 哭泣, 流淚 A healthy society never allows a hero weeping.一個健康的社會絕不會讓英雄流淚。

          5. laugh [ lB:f ] vi. 笑, 譏笑 Laughing help keeping us healthy.大笑有助于我們的健康。 格言: He laughs best who laughs last. 最后笑的人笑得最好。

          6. laughter [ 5lB:ftE ] n. 笑, 笑聲 burst into laughter 突然大笑起來 Her laughter is my greatest delight.她的笑聲是我最大的歡樂。 格言: Laughter is the best medicine.笑聲是最佳的藥。

          7. smile [ smail ] n.& vi. 微笑 When you smile, the life smiles, too.你笑的時候,生活也在笑。

          13. cup glass glasses cut carve sculpture split

          記憶:1. cup [ kQp ] n. 杯子, 酒杯, 獎杯 vt.使成杯狀 Fetch me another five cups, please.請再給我取五個杯子來。

          2. glass [ ^lB:s ] n. 玻璃, 玻璃制品, 玻璃杯 The crystal palace is made of glass.水晶宮是用玻璃做的。

          3. glasses n. 眼鏡 The man with a pair of thick glasses is a professor from Tsinghua University.帶深度眼鏡的那個人是來自清華大學的教授。

          4. cut [ kQt ] vt. 切(割、削), 剪, n.削減, 刪節, 傷口, 切口 Wrap your cut with this bandage quickly. 快點用這繃帶把你的傷口包起來。

          5. carve [ kB:v ] vt. 雕刻, 切開 He carved a face in the trunk. 他在樹干上雕刻了一張臉。

          6. sculpture [ 5skQlptFE ] cu, 音似“刻”n. 雕刻, 雕刻品, 雕塑, 雕塑品 The city sculptures are another attraction to me.城市雕塑是另一個吸引我的地方。

          7. split [ split ] p, 音“劈”,v. 劈開 n. 裂開, 裂痕 The woodcutter split the trunk into halves.樵夫把樹干劈成了兩半。

          14. danger dangerous emergency safety safe safely save rescue secure security

          記憶:1. danger [ 5deindVE ] n. 危險, 危險物 Look out! There is danger ahead.小心,前面有危險!

          2. dangerous [ 5deindVrEs ] adj. 危險的 The tiger in danger is still a dangerous animal.處于危險境地的老虎仍是危險的動物。

          3. emergency [ i5mE:dVnsi ] emerg-ency emerge,出現;emergency, 突然出現 n. 緊急情況, 突然事件 The special police forces keep alert all the time in case of any emergency.特種警察部隊一直保持著警惕,以防任何緊急情況的出現。

          4. emerge [ i5mE:dV ] vi. 顯現, 浮現, (由某種狀態)脫出, (事實)顯現出來 The truth will emerge sooner or later.真相盡早出浮出水面。

          5. safe [ seif ] adj. 安全的 n. 保險箱 Precautious attacking can’t keep the county really safe.先發制人并不能真正保證國家的安全。

          6. safely [`seIflI] adv. 安全地 The ship landed safely in the end.船最后平安靠岸了。

          7. safety [ 5seifti ] n. 安全,安全地帶 He hurried to take the boy to safety.他急忙把孩子帶到安全地帶。

          8. save [ seiv ] vt. 解救, 保存, 節省, 儲蓄 vi. 挽救, 節省 prep. 除...之外 How can I thank you enough for saving my life?你救了我的命,我真不知該怎樣感謝你。 格言:Saving is getting. 節省就是獲得。

          9. rescue [ 5reskju: ] vt. & n. 援救, 營救 The firemen have tried their best to rescue the man trapped 消防隊員已盡了力去營救受困的那個人。

          10. secure [ si5kjuE ] se-cure, 治好的, adj. 安全的, 可靠的 You may be relaxed now. The secret is absolutely secure.你可以放松點。那個秘密絕對安全。

          11. security [ si5kjuEriti ] n.安全 National security is the first matter for any government.國家安全是任何政府的首要問題。

          15. dare daring afraid fright frighten frightened fear fearful

          記憶:1. dare [ dZE ] vi. 敢, 膽敢 He dares to challenge any famous singer.他敢于向任何著名的歌手折挑戰。

          2. daring [ 5dZEriN ] adj. 大膽的 The daring words surprised his parents.那番大膽的話讓他父母吃了一驚。

          3. afraid [ E5freid ] adj. 害怕, 擔心 I’m afraid to see his angry face.我不敢看他生氣的臉。

          4. fear [ fiE ] n. 恐怖, 害怕, 擔心 v. 害怕, 畏懼 What I fear is not bears but tears.我怕的不是大笨熊,而是眼淚。 格言:Fear of death is worse than death itself. 對死亡的恐懼比死亡本身更可怕。

          5. fearful [ 5fiEful ] adj. 可怕的, 恐怕的 A dark night may be fearful for a lonely girl.也許對一個孤獨的女孩來說,漆黑的夜晚是可怕的。

          6. fearless [5fIElIs] adj. 勇敢的, 無畏的 Mandela is a fearless fighter to get rid of racial discrimination.曼德拉為消除種族歧視進行了無畏的戰斗。

          7. fright [ frait ] f+right 不對的,讓人驚駭的 n. 驚駭, 吃驚 The fright on his face is quite obvious.他臉上的驚訝感十分明顯。

          8. frighten [ 5fraitn ] vt. 使驚嚇 Don't frighten the boy with your disgusting story!別用你那討厭的故事嚇住孩子。

          9. frightened [5fraIt(E)nd] adj. 受驚的, 受恐嚇的 It’s strange that I should find myself frightened at that time.真奇怪,那時候我居然很害怕!

          記單詞有困難的同學,推薦學習《奇速英語24個故事串記中學3500詞匯》 ,讓你在輕松愉快的故事中掌握單詞的讀音、漢語意思和拼寫哦!單詞逆襲鏈接:

          24個故事第一講鏈接:http://v.qq.com/page/g/s/7/g0139goxls7.html

          24個故事第二講鏈接:http://v.qq.com/page/y/4/7/y0140zjnc47.html ;

          24個故事第三講鏈接:http://v.qq.com/page/c/a/c/c0140y0r0ac.html

          奇速英語官方旗艦店:http://abc366.taobao.com

          記得小時候的萬花尺吧?這么畫:

          一點也不費腦筋,就可以出來這么多豐富多彩的復雜幾何圖形。

          具體而言,可以用萬花尺玩具(如圖2-1所示)來繪制數學曲線。這種玩具由兩個不同尺寸的塑料齒輪組成,一大一小。小的齒輪有幾個孔。把鋼筆或鉛筆放入一個孔,然后在較大齒輪(內部有齒)內旋轉里面的小齒輪,保持筆與外輪接觸,可以畫出無數復雜而奇妙的對稱圖案。

          圖2-1 萬花尺

          現在,在電腦里,用Python也可以這么玩了,讓我們看看Python的萬花尺效果吧。(不用急,程序在后哦)

          $ python spiro.py

          默認情況下,spiro.py程序繪制隨機螺線,如圖2-5所示。按S鍵保存繪制。

          圖2-5 spiro.py的運行示例

          再次運行程序,這次在命令行傳入參數,畫出特定的螺線。

          $ python spiro.py --sparams 300 100 0.9

          圖2-6展示了輸出結果。如你所見,這段代碼根據用戶指定的參數繪制了一條螺線,圖2-5和它不同,展示了幾個隨機螺線的動畫。

          圖2-6 用具體參數運行spiro.py的示例

          這么神奇又好玩的萬花尺,在Python里怎么玩呢?

          不要走開,讓我們繼續下面的Python之旅。

          在這個項目中,我們將用Python來創建動畫,像萬花尺一樣繪制曲線。我們的spiro.py程序將用Python和參數方程來描述程序的萬花尺齒輪的運動,并繪制曲線(我稱之為螺線)。我們可以將完成的畫圖保存為PNG圖像文件,并用命令行選項來指定參數或生成隨機螺線。

          在這個項目中,我們將學習如何在計算機上繪制螺線。還將學習以下幾點:

          • 用turtle模塊創建圖形;
          • 使用參數方程;
          • 利用數學方程來生成曲線;
          • 用線段來畫曲線;
          • 用定時器來生成圖形動畫;
          • 將圖形保存為圖像文件。

           參數方程

          在本節中,你將看到用參數方程來畫圓的簡單例子。參數方程將曲線上點的坐標表示為一個變量的函數,該變量稱為參數。參數方程讓繪制曲線變得容易,因為只要將參數代入方程就能產生曲線。

          注意

          如果你現在不想學習這部分數學知識,可以跳到下一部分,討論針對萬花尺項目的方程。

          我們開始考慮用半徑 r 來描述一個圓的方程,圓心位于二維平面的原點。 x 、 y 坐標滿足該方程的所有點構成了圓。

          現在,請考慮下面的方程:

          x=r cos( θ )

          y=r sin( θ )

          這些方程是圓的參數表示,其中角 θ 是參數。這些方程中(X,Y)的任何值,都滿足前面描述的圓的方程,X 2 + Y 2=R 2 。如果讓 θ 從0變到2π,可以用這些方程來計算圓上對應的 x 和 y 坐標。圖2-2展示了這種方案。

          圖2-2 用參數方程描述圓

          記住,這兩個方程適用于圓心在坐標系原點的圓。將圓心轉換到點( a , b ),就可以將圓置于 xy 平面的任何位置。所以更一般的參數方程就變成 x=a + r cos( θ )和 y=b + r cos( θ )。現在,讓我們來看看描述螺線的方程。

          萬花尺方程

          圖2-3展示了類似萬花尺運動的數學模型。該模型沒有齒輪,因為玩具中的齒輪只是為了防止打滑,而在這里不必擔心打滑。

          圖2-3 萬花尺數學模型

          在圖2-3中,C是較小的圓的圓心,P是筆尖。較大的圓半徑為 R ,較小的圓半徑為 r 。半徑之比表示如下:

          將線段PC與小圓半徑 r 之比作為變量l(l=PC / r ),它決定了筆尖離小圓圓心有多遠。然后,組合這些變量來表示P的運動,得到如下的參數方程:

          注意

          這些曲線稱為內旋輪線和外旋輪線。雖然方程可能看起來有點嚇人,但推導是非常簡單的。如果你想探索其中的數學,請參見維基百科。

          圖2-4展示了如何用這些方程,基于參數的變化,產生一條曲線。通過改變參數 R 、 r 和 l ,可以產生變化無窮的迷人曲線。

          圖2-4 示例曲線

          將曲線繪制為一系列點之間的線段。如果這些點足夠接近,圖看起來就像平滑的曲線。真正玩過萬花尺就知道,這取決于使用的參數,萬花尺可能需要許多轉數來完成。要確定何時停止繪圖,就要利用萬花尺的周期性(即萬花尺圖案多久開始重復),研究內外圓的半徑之比:

          分子分母除以它們的最大公約數(GCD),化簡該分數,分子就告訴我們需要多少圈才能完成曲線。例如,在圖2-4中,( r , R )的GCD是5。

          下面是該分數化簡后的形式:

          這告訴我們,13圈后,曲線將開始重復。44告訴我們小圓圍繞其中心旋轉的圈數,它提示了曲線的形狀。在圖2-4中數一下,會看到圖形中花瓣或葉的數目恰好是44!

          一旦用簡化形式表示了半徑比 r / R ,畫出螺線的參數 θ 范圍就是[0,2πr]。這告訴我們何時停止繪制特定的螺線。不知道該角度的結束范圍,就會循環不止,不必要地重復該曲線。

          海龜畫圖

          我們可以用Python的turtle模塊來創建圖案。這是一個簡單的繪圖程序,模型是一只海龜拖著尾巴穿過沙灘,留下圖案。turtle模塊包括了一些方法,用于設置筆(海龜的尾巴)的位置和顏色,以及其他有用的繪圖函數。如你所見,只要少量繪圖函數,就可以創建漂亮的螺線。

          例如,這個程序用turtle畫圓。輸入以下代碼,保存為drawcircle.py,在Python中運行它:

           import math
          ① import turtle
          
            # draw the circle using turtle
            def drawCircleTurtle(x, y, r):
            # move to the start of circle
          ② turtle.up()
          ③ turtle.setpos(x + r, y)
          ④ turtle.down()
          
            # draw the circle
          ⑤ for i in range(0, 365, 5):
          ⑥ a=math.radians(i)
          ⑦ turtle.setpos(x + r*math.cos(a), y + r*math.sin(a))
          
          ⑧ drawCircleTurtle(100, 100, 50)
          ⑨ turtle.mainloop()

          在①行,從導入turtle模塊開始。接下來,定義drawCircleTurtle()方法,它在②行調用up()。這告訴Python提筆。換句話說,讓筆離開虛擬的紙,這樣移動海龜也不會畫圖。開始繪圖之前,先定位海龜。

          在③行,將海龜的位置設置為橫軸上的第一個點:(x + r, y),其中(x,y)是該圓的圓心?,F在準備好畫圖了,所以在④行調用down()。在⑤行,利用range(0, 365, 5)開始循環,以5為步長遞增變量i,從0到360,變量i是角度參數,將傳入圓的參數方程,但首先在⑥行將它從度轉為弧度(大多數計算機程序的角度計算需要弧度)。

          在⑦行,利用前面討論過的參數方程計算圓的坐標,并設置相應的海龜位置,這樣就從海龜上一個位置畫線到新計算的位置(從技術上講,產生的是N邊多邊形,但因為用了很小的角度,N將非常大,多邊形看起來像一個圓)。

          在⑧行,調用drawCircleTurtle()來畫圓,在⑨行,調用mainloop(),它保持tkinter窗口打開,讓你可以欣賞你畫的圓(Tkinter是Python默認的GUI庫)。

          現在,我們準備好畫一些螺線了!

          所需模塊

          我們將利用下面的模塊創建螺線:

          • turtle模塊用于繪圖;
          • pillow,這是Python圖像庫(PIL)的一個分支,用于保存螺線圖像。

          代碼

          首先,定義類Sipro,來繪制這些曲線。我們會用這個類一次畫一條曲線(利用draw()方法),并利用一個定時器和update()方法,產生一組隨機螺線的動畫。為了繪制Spiro對象并產生動畫,我們將使用SpiroAnimator類。

          要查看完整的項目代碼,請直接跳到2.4節。

           Spiro構造函數

          下面是Spiro構造函數:

            # a class that draws a Spirograph
            class Spiro:
            # constructor
            def __init__(self, xc, yc, col, R, r, l):
          
            # create the turtle object
          ① self.t=turtle.Turtle()
            # set the cursor shape
          ② self.t.shape('turtle')
            # set the step in degrees
          ③ self.step=5
            # set the drawing complete flag
          ④ self.drawingComplete=False
          
            # set the parameters
          ⑤ self.setparams(xc, yc, col, R, r, l)
          
            # initialize the drawing
          ⑥ self.restart()

          在①行,Spiro構造函數創建一個新的turtle對象,這將有助于我們同時繪制多條螺線。在②行,將光標的形狀設置為海龜(在 https://docs.python.org/3.3/library/ turtle.html ,你可以在turtle文檔中找到其他選項)。在③行,將參數繪圖角度的增量設置為5度,在④行,設置了一個標志,將在動畫中使用它,它會產生一組螺線。

          在⑤和⑥行,調用設置函數,接下來討論該函數。

          設置函數

          現在讓我們看看getParams()方法,它幫助初始化Spiro對象,如下所示:

            # set the parameters
            def setparams(self, xc, yc, col, R, r, l):
            # the Spirograph parameters
          ① self.xc=xc
            self.yc=yc
          ② self.R=int(R)
            self.r=int(r)
            self.l=l
            self.col=col
            # reduce r/R to its smallest form by dividing with the GCD
          ③ gcdVal=gcd(self.r, self.R)
          ④ self.nRot=self.r//gcdVal
            # get ratio of radii
            self.k=r/float(R)
            # set the color
            self.t.color(*col)
            # store the current angle
          ⑤ self.a=0

          在①行,保存曲線中心的坐標。然后在②行,將每個圓的半徑( R 和 r )轉換為整數并保存這些值。在③行,用Python模塊fractions內置的gcd()方法來計算半徑的GCD。我們將用這些信息來確定曲線的周期性,在④行將它保存為self.nRot。最后,在⑤行,保存當前的角度,我們將用它來創建動畫。

          restart()方法

          接下來,restart()方法重置Spiro對象的繪制參數,讓它準備好重畫:

            # restart the drawing
            def restart(self):
            # set the flag
          ① self.drawingComplete=False
            # show the turtle
          ② self.t.showturtle()
            # go to the first point
          ③ self.t.up()
          ④ R, k, l=self.R, self.k, self.l
            a=0.0
          ⑤ x=R*((1-k)*math.cos(a) + l*k*math.cos((1-k)*a/k))
            y=R*((1-k)*math.sin(a) - l*k*math.sin((1-k)*a/k))
          ⑥ self.t.setpos(self.xc + x, self.yc + y)
          ⑦ self.t.down()

          這里用了布爾標志drawingComplete,來確定繪圖是否已經完成,在①行初始化該標志。繪制多個Spiro對象時,這個標志是有用的,因為它可以追蹤某個特定的螺線是否完成。在②行,顯示海龜光標,以防它被隱藏。在③行提起筆,這樣就可以在⑥行移動到第一個位置而不畫線。在④行,使用了一些局部變量,以保持代碼緊湊。然后,在⑤行,計算角度a設為0時的 x 和 y 坐標,以獲得曲線的起點。最后,在⑦行,我們已完成,并落筆。Setpos()調用將繪制實際的線。

           draw()方法

          draw()方法用連續的線段繪制該曲線。

            # draw the whole thing
            def draw(self):
            # draw the rest of the points
            R, k, l=self.R, self.k, self.l
          ① for i in range(0, 360*self.nRot + 1, self.step):
            a=math.radians(i)
          ② x=R*((1-k)*math.cos(a) + l*k*math.cos((1-k)*a/k))
            y=R*((1-k)*math.sin(a) - l*k*math.sin((1-k)*a/k))
            self.t.setpos(self.xc + x, self.yc + y)
            # drawing is now done so hide the turtle cursor
          ③ self.t.hideturtle()

          在①行,迭代遍歷參數i的完整范圍,它以度表示,是360乘以nRot。在②行,計算參數i的每個值對應的 X 和 Y 坐標。在③行,隱藏光標,因為我們已完成繪制。

           創建動畫

          update()方法展示了一段一段繪制曲線來創建動畫時所使用的繪圖方法。

            # update by one step
            def update(self):
            # skip the rest of the steps if done
          ① if self.drawingComplete:
            return
            # increment the angle
          ② self.a +=self.step
            # draw a step
            R, k, l=self.R, self.k, self.l
            # set the angle
          ③ a=math.radians(self.a)
            x=self.R*((1-k)*math.cos(a) + l*k*math.cos((1-k)*a/k))
            y=self.R*((1-k)*math.sin(a) - l*k*math.sin((1-k)*a/k))
            self.t.setpos(self.xc + x, self.yc + y)
            # if drawing is complete, set the flag
          ④ if self.a >=360*self.nRot:
            self.drawingComplete=True
            # drawing is now done so hide the turtle cursor
            self.t.hideturtle()

          在①行,update()方法檢查drawingComplete標志是否設置。如果沒有設置,則繼續執行代碼其余的部分。在②行,update()增加當前的角度。從③行開始,它計算當前角度對應的(X,Y)位置并將海龜移到那里,在這個過程中畫出線段。

          討論萬花尺方程時,我提到了曲線的周期性。在一定的角度后,萬花尺的圖案開始重復。在④行,檢查角度是否達這條特定曲線計算的完整范圍。如果是這樣,就設置drawingComplete標志,因為繪圖完成了。最后,隱藏海龜光標,你可以看到自己美麗的創作。

          SpiroAnimator類

          SpiroAnimator類讓我們同時繪制隨機的螺線。該類使用一個計時器,每次繪制曲線的一段。這種技術定期更新圖像,并允許程序處理事件,如按鍵、鼠標點擊,等等。但是,這種計時器技術需要對繪制代碼進行一些調整。

            # a class for animating Spirographs
            class SpiroAnimator:
            # constructor
            def __init__(self, N):
            # set the timer value in milliseconds
          ① self.deltaT=10
            # get the window dimensions
          ② self.width=turtle.window_width()
            self.height=turtle.window_height()
            # create the Spiro objects
          ③ self.spiros=[]
            for i in range(N):
            # generate random parameters
          ④ rparams=self.genRandomParams()
            # set the spiro parameters
          ⑤ spiro=Spiro(*rparams)
            self.spiros.append(spiro)
            # call timer
          ⑥ turtle.ontimer(self.update, self.deltaT)

          在①行,該SpiroAnimator構造函數將DeltaT設置為10,這是以毫秒為單位的時間間隔,將用于定時器。在②行,保存海龜窗口的尺寸。然后在③行創建一個空數組,其中將填入一些Spiro對象。這些封裝的萬花尺繪制,然后循環N次(N傳入給構造函數SpiroAnimator),在⑤行創建一個新的Spiro對象,并將它添加到Spiro對象的列表中。這里的rparams是一個元組,需要傳入到Spiro構造函數。但是,構造函數需要一個參數列表,所以用Python的*運算符將元組轉換為參數列表。

          最后,在⑥行,設置turtle.ontimer()方法每隔DeltaT毫秒調用update()。

          請注意,在④行調用了一個輔助方法,名為genRandomParams()。接下來就看看這個方法。

          genRandomParams()方法

          我們用genRandomParams()方法來生成隨機參數,在每個Spiro對象創建時發送給它,來生成各種曲線。

            # generate random parameters
            def genRandomParams(self):
            width, height=self.width, self.height
          ① R=random.randint(50, min(width, height)//2)
          ② r=random.randint(10, 9*R//10)
          ③ l=random.uniform(0.1, 0.9)
          ④ xc=random.randint(-width//2, width//2)
          ⑤ yc=random.randint(-height//2, height//2)
          ⑥ col=(random.random(),
            random.random(),
            random.random())
          ⑦ return (xc, yc, col, R, r, l)

          為了生成隨機數,利用來自Python的random模塊的兩個方法:randint(),它返回指定范圍內的隨機整數,以及uniform(),它對浮點數做同樣的事。在①行,將R設置為50至窗口短邊一半長度的隨機整數,在②行,將r設置為R的10%至90%之間。

          然后,在③行,將l設置為0.1至0.9之間的隨機小數。在④和⑤行,在屏幕邊界內隨機選擇 x 和 y 坐標,選擇屏幕上的一個隨機點作為螺線的中心。在⑥行隨機設置為紅、綠和藍顏色的成分,為曲線指定隨機的顏色。最后,在⑦行,所有計算的參數作為一個元組返回。

           重新啟動程序

          我們將用另一個restart()方法來重新啟動程序。

          # restart spiro drawing
           def restart(self):
           for spiro in self.spiros:
           # clear
           spiro.clear()
           # generate random parameters
           rparams=self.genRandomParams()
           # set the spiro parameters
           spiro.setparams(*rparams)
           # restart drawing
           spiro.restart()

          它遍歷所有的Spiro對象,清除以前繪制的每條螺線,分配新的螺線參數,然后重新啟動程序。

           update()方法

          下面的代碼展示了SproAnimator中的update()方法,它由定時器調用,以動畫的形式更新所有的Spiro對象:

            def update(self):
            # update all spiros
          ① nComplete=0
            for spiro in self.spiros:
            # update
          ② spiro.update()
            # count completed spiros
          ③ if spiro.drawingComplete:
            nComplete +=1
            # restart if all spiros are complete
          ④ if nComplete==len(self.spiros):
            self.restart()
            # call the timer
          ⑤ turtle.ontimer(self.update, self.deltaT)

          update()方法使用一個計數器nComplete來記錄已畫的Spiro對象的數目。在①行初始化后,它遍歷Spiro對象的列表,在②行更新它們,如果一個Spiro完成,就在③行將計數器加1。

          在循環外的④行,檢查計數器,看看是否所有對象都已畫完。如果已畫完,調用restart()方法重新開始新的螺線動畫。在⑤行restart()的末尾,調用計時器方法,它在DeltaT毫秒后再次調用update()。

          顯示或隱藏光標

          最后,使用下面的方法來打開或關閉海龜光標。這可以讓繪圖更快。

           # toggle turtle cursor on and off
           def toggleTurtles(self):
           for spiro in self.spiros:
           if spiro.t.isvisible():
           spiro.t.hideturtle()
           else:
           spiro.t.showturtle()

           保存曲線

          使用saveDrawing()方法,將繪制保存為PNG圖像文件。

            # save drawings as PNG files
            def saveDrawing():
            # hide the turtle cursor
          ① turtle.hideturtle()
            # generate unique filenames
          ② dateStr=(datetime.now()).strftime("%d%b%Y-%H%M%S")
            fileName='spiro-' + dateStr
            print('saving drawing to %s.eps/png' % fileName)
            # get the tkinter canvas
          ③ canvas=turtle.getcanvas()
            # save the drawing as a postscipt image
          ④ canvas.postscript(file=fileName + '.eps')
            # use the Pillow module to convert the postscript image file to PNG
          ⑤ img=Image.open(fileName + '.eps')
          ⑥ img.save(fileName + '.png', 'png')
            # show the turtle cursor
          ⑦ turtle.showturtle()

          在①行,隱藏海龜光標,這樣就不會在最后的圖形中看到它。然后,在②行,使用datetime(),利用當前時間和日期(以“日—月—年—時—分—秒”的格式),以生成圖像文件的唯一名稱。將這個字符串加在spiro-后面,生成文件名。

          turtle程序采用tkinter創建的用戶界面(UI)窗口,在③和④行,利用tkinter的canvas對象,將窗口保存為嵌入式PostScript(EPS)文件格式。由于EPS是矢量格式,你可以用高分辨率打印它,但PNG用途更廣,所以在⑤行用Pillow打開EPS文件,并在⑥行將它保存為PNG文件。最后,在⑦行,取消隱藏海龜光標。

          解析命令行參數和初始化

          像第1章中一樣,在main()方法中用argparse來解析傳入程序的命令行選項。

          ① parser=argparse.ArgumentParser(description=descStr)
          
            # add expected arguments
          ② parser.add_argument('--sparams', nargs=3, dest='sparams', required=False,
            help="The three arguments in sparams: R, r, l.")
          
            # parse args
          ③ args=parser.parse_args()

          在①行,創建參數解析器對象,在②行,向解析器添加--sparams可選參數。在③行,調用函數進行實際的解析。

          接下來,代碼設置了一些turtle參數。

            # set the width of the drawing window to 80 percent of the screen width
          ① turtle.setup(width=0.8)
          
            # set the cursor shape to turtle
          ② turtle.shape('turtle')
          
            # set the title to Spirographs!
          ③ turtle.title("Spirographs!")
            # add the key handler to save our drawings
          ④ turtle.onkey(saveDrawing, "s")
            # start listening
          ⑤ turtle.listen()
          
            # hide the main turtle cursor
          ⑥ turtle.hideturtle()

          在①行,用setup()將繪圖窗口的寬度設置為80%的屏幕寬度(你也可以給setup指定高度和原點參數)。在②行,設置光標形狀為海龜,在③行,設置程序窗口的標題為Spirographs!,在④行,利用onkey()和saveDrawing,在按下S時保存圖畫。然后,在⑤行,調用listen()讓窗口監聽用戶事件。最后,在⑥行,隱藏海龜光標。

          命令行參數解析后,代碼的其余部分進行如下:

            # check for any arguments sent to --sparams and draw the Spirograph
          ① if args.sparams:
          ② params=[float(x) for x in args.sparams]
            # draw the Spirograph with the given parameters
            col=(0.0, 0.0, 0.0)
          ③ spiro=Spiro(0, 0, col, *params)
          ④ spiro.draw()
            else:
            # create the animator object
          ⑤ spiroAnim=SpiroAnimator(4)
            # add a key handler to toggle the turtle cursor
          ⑥ turtle.onkey(spiroAnim.toggleTurtles, "t")
            # add a key handler to restart the animation
          ⑦ turtle.onkey(spiroAnim.restart, "space")
          
           # start the turtle main loop
          ⑧ turtle.mainloop()

          在①行,首先檢查是否有參數賦給--sparams。如果有,就從字符串中提取它們,用“列表解析”將它們轉換成浮點數②(列表解析是一種Python結構,讓你以緊湊而強大的方式創建一個列表,例如,a=[2*x for x in range(1, 5)]創建前4個偶數的列表)。

          在③行,利用任何提取的參數來構造Spiro對象(利用Python的*運算符,它將列表轉換為參數)。然后,在④行,調用draw(),繪制螺線。

          現在,如果命令行上沒有指定參數,就進入隨機模式。在⑤行,創建一個SpiroAnimator對象,向它傳入參數4,告訴它創建4幅圖畫。在⑥行,利用onkey()來捕捉按鍵T,這樣就可以用它來切換海龜光標(toggleTurtles),在⑦行,處理空格鍵(space),這樣就可以用它在任何時候重新啟動動畫。最后,在⑧行,調用mainloop()告訴tkinter窗口保持打開,監聽事件。

          完整代碼

          可以從公眾號pythondada輸入萬花尺索取完成代碼。

          些函數系統也幫忙打包好,以xxx.dll文件存放在ext、extras文件夾中,需要開啟配置才能使用。這些函數稱為擴展函數(extend)。

          一、解決中文截取亂碼mb_substr

          echo mb_substr("中abc",0,2,"utf-8");

          二、圖片處理函數GD2

          GD(graphic device,圖形設備),負責在屏幕和打印機上輸出信息。GD2是GDI的后續版本。要使用GD2,首先應該把網頁打散作為圖像(header),接著創建Graphics類對象(簡單的來說,Graphics類對象就相當于畫布,沒畫布我們在什么地方繪圖呢?),然后調用一系列繪圖方法即可,最后再生成圖片、釋放資源(destroy)??聪旅娴拇a

          步驟:

          1、聲明:把當前頁面通過寫代碼的方式作為圖片生成,語法:

          header(“content-type:image/jpeg”);

          2、繪圖

          3、生成圖片(注意格式對應)

          語法: imagejpeg();

          4、釋放資源(銷毀材料)

          語法:imagedestory();

          其中繪圖重要函數

          //畫點

          Imagesetpixel

          //畫線

          Imageline

          //畫矩形

          Imagerectangle

          //畫圓

          Imageellipse

          //畫實心矩形

          Imagefilledrectangle

          //畫實心圓

          imagefilledellipse

          //畫文字 不支持中文

          Imagestring

          //畫豎排文字

          Imagestringup

          //畫文字支持中文

          Imagettftext

          所有的繪畫工作完成,可以使用img標簽調用!??!

          <img src=”xxxx.php”>

          示例源碼:

          <?php

          header("content-type:image/jpeg");

          //執行繪圖

          //創建畫布

          $im=imagecreate(200,100);

          //填充背景色

          imagecolorallocate($im,100,100,100);

          //定義顏色

          $red=imagecolorallocate($im,255,255,255);

          //畫點

          imagesetpixel($im,5,5,$red);

          //畫線

          imageline($im,0,50,200,50,$red);

          //畫矩形

          imagerectangle($im,100,10,130,40,$red);

          //畫圓

          imageellipse($im,50,50,10,30,$red);

          //畫實心的矩形

          imagefilledrectangle($im,70,10,100,40,$red);

          //畫實心圓

          imagefilledellipse($im,40,20,10,30,$red);

          //定義字體

          $font="STXINGKA.TTF";

          //畫文字

          imagestring($im,$font,100,30,'I LIKE TEACHER HE!',$red);

          //畫豎排文字

          imagestringup($im,$font,180,90,'I LOVE TEACHER HE!',$red);

          //畫支持中文的文字

          imagettftext($im,14,30,80,70,$red,$font,'我愛何老師!');

          //生成圖片

          imagejpeg($im);

          //想一想為什么在生成圖片之后無法繪畫

          imagesetpixel($im,15,15,$red);

          //釋放資源

          imagedestroy($im);

          ?>

          TIPS:練習下多邊形的多點坐標,可以使用圖片熱點技術。

          利用GD2和前面的知識畫標準驗證碼:

          <?php

          header("content-type:image/jpeg");

          include_once("CheckNum.php");

          $chnCount=6;//驗證碼位數

          $chn=CreateCheckNumber($chnCount,7);

          $fontSize=40;//字體的大?。▽挾龋?/p>

          $width=ceil($chnCount*($fontSize+0.5));//驗證碼寬度

          $height=$fontSize*2-2;//驗證碼高度

          $im=imagecreate($width,$height);

          imagecolorallocate($im,243,243,243);

          $fontColor=imagecolorallocate($im,70,147,251);

          $font='STXINGKA.TTF';

          imagettftext($im,$fontSize,0,($width-$fontSize*$chnCount+$fontSize)/2,($height-$fontSize)/2+$fontSize,$fontColor,$font,$chn);

          //畫邊框 注意邊框粗細

          imagerectangle($im,0,0,$width-1,$height-1,$fontColor);

          //畫干擾線

          $lineColor=imagecolorallocate($im,249,62,89);

          for($i=0;$i<2;$i++)

          imageline($im,0,rand(1,$height-1),$width,rand(1,$height-1),$lineColor);

          //畫干擾點

          for($i=0;$i<100;$i++){

          $pixelColor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));

          imagesetpixel($im,rand(1,$width-1),rand(1,$height-1),$pixelColor);

          }

          imagejpeg($im);

          imagedestroy($im);

          ?>

          文字水印:

          以現有的圖片作為畫布再畫上文字。

          Imagecreatefromjpeg

          <?php

          header("content-type:image/gif");

          //以現有的圖片作為背景來創建畫布

          $im=imagecreatefromgif("menggou.gif");

          $color=imagecolorallocate($im,255,255,255);

          $font='STKAITI.TTF';

          imagestring($im,$font,5,5,'http://www.xuewanwang.com',$color);

          imagegif($im);

          imagedestroy($im);

          ?>

          圖片水?。?/p>

          把.png圖片作為水印使用imagecopy函數即可。

          獲取圖片的寬度和高度

          Imagesx、imagesy

          <?php

          header("content-type:image/jpeg");

          //創建背景,作業:根據背景圖創建對應格式的畫布

          $bgurl="bg.jpg";//改變背景圖片格式

          //$extName=mb_substr($bgurl,strrpos($bgurl,'.'),strlen($bgurl)-strrpos($bgurl,'.'));//背景圖片擴展名

          $extName=strrchr($bgurl,'.');

          switch(strtolower($extName)){

          case '.jpg':$bg=imagecreatefromjpeg($bgurl);break;

          }

          $water=imagecreatefrompng('logo.png');

          //獲取水印圖片的寬高度

          $w=imagesx($water);

          $h=imagesy($water);

          //作業:要求水印圖片出現在右上角、做下角、右下角、居中

          imagecopy($bg,$water,0,0,0,0,$w,$h);

          //作業完善:背景圖片水印圖片的2倍及以上大才生成水印,否則不生成是原圖

          imagejpeg($bg);

          imagedestroy($bg);

          ?>

          作業:

          1、在網站根目錄下放4個圖片,分別命名為1.gif.png.bmp.jPg、 2.gif、3.png、4.bmp 生成圖片水印

          2、圖片水印圖片可以在不同的位置出現,定義變量控制為左上角、右上角、左下角、右下角、居中

          3、背景圖片水印圖片的2倍及以上大才生成水印,否則不生成是原圖。

          統計圖:

          柱狀圖實現思路:

          用戶傳遞的參數為數組,數組中元素個數為多少個單位;縱方向一般劃分10個等距離單位意味數組100%,數組中的值在縱方向按百分比顯示;縮放柱狀圖控制單位距離。

          實現效果如下:

          完整代碼:

          <?php

          header("content-type:image/jpeg");

          /* 建議按300*550來縮放,否則會變形 */

          $pSize=50;//單位距離,控制縮放

          $pNameArr=explode(',',$_REQUEST['dw']);//單位名稱

          $arr=explode(',',$_REQUEST['sj']);//需要生成統計圖的數組數據

          $im=imagecreate($pSize*(count($arr)+2),$pSize*(10+1));

          imagecolorallocate($im,243,243,243);

          $black=imagecolorallocate($im,0,0,0);

          //畫X軸

          imageline($im,0,imagesy($im)-1,imagesx($im),imagesy($im)-1,$black);

          //畫Y軸

          imageline($im,1,0,1,imagesy($im),$black);

          //算出數組元素中所有元素的值

          $sum=0;

          foreach($arr as $v){

          $sum+=$v;

          }

          //畫X軸上等距線

          $lheight=10;//等距線高度

          //字體

          $font="../fonts/STKAITI.TTF";

          for($i=0;$i<count($arr);$i++){

          imageline($im,$pSize*($i+1),imagesy($im)-1,$pSize*($i+1),imagesy($im)-1-$lheight,$black);

          //畫矩形

          imagerectangle($im,$pSize*($i+1)-$pSize/2+3,imagesy($im)-$arr[$i]/$sum*$pSize*10-1-1,$pSize*($i+1)+$pSize/2-3,imagesy($im)-1,$black);

          $rcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));

          imagefilledrectangle($im,$pSize*($i+1)-$pSize/2+4,imagesy($im)-$arr[$i]/$sum*$pSize*10-1,$pSize*($i+1)+$pSize/2-4,imagesy($im)-2,$rcolor);

          imagettftext($im,16,30,$pSize*($i+1)-$pSize/2+4,imagesy($im)-$arr[$i]/$sum*$pSize*10-4,$rcolor,$font,$arr[$i].$pNameArr[$i]);

          }

          //畫Y軸上等距線

          for($i=1;$i<=10;$i++){

          imageline($im,1,imagesy($im)-$pSize*$i,1+$lheight,imagesy($im)-$pSize*$i,$black);

          imagestring($im,2,10,imagesy($im)-$pSize*$i-5,$i*10,$black);

          }

          imagestringup($im,5,$pSize/2-5,$pSize*5,'(%)',$black);

          imagejpeg($im);

          imagedestroy($im);

          ?>

          餅狀圖實現效果如下:

          <?php

          header("content-type:image/jpeg");

          /* 建議按350*200來縮放,否則會變形 */

          //定義圓半徑

          $raduis=100;

          $arr=explode(',',$_REQUEST['sj']);//需要生成統計圖的數組數

          $pNameArr=explode(',',$_REQUEST['dw']);//單位名稱

          //計算數組總值

          $sum=0;

          //$maxFontSize=strlen($arr[0]);//最大文字內容長度

          foreach($arr as $v){

          $sum+=$v;

          //$maxFontSize=strlen($v)>$maxFontSize?strlen($v):$maxFontSize;

          }

          //foreach($pNameArr as $v)

          //$maxFontSize=strlen($v)>$maxFontSize?strlen($v):$maxFontSize;

          //字體

          $font="../fonts/STKAITI.TTF";

          $fontSize=13;//字體大小

          $im=imagecreate($raduis*2+180,$raduis*2);

          imagecolorallocate($im,243,243,243);

          $black=imagecolorallocate($im,0,0,0);

          imageellipse($im,$raduis,$raduis,$raduis*2-1,$raduis*2-1,$black);

          $startP=0;//起始角度

          for($i=0;$i<count($arr);$i++){

          $pieColor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));

          imagefilledarc($im,$raduis,$raduis,$raduis*2-3,$raduis*2-3,$startP,$startP+$arr[$i]/$sum*360,$pieColor,IMG_ARC_EDGED);

          $startP+=$arr[$i]/$sum*360;

          //數據提示

          imagettftext($im,$fontSize,0,$raduis*2+$fontSize*3,$fontSize*($i+1)+6,$pieColor,$font,$arr[$i].$pNameArr[$i].'('.round($arr[$i]/$sum*100).'%)');

          imagefilledrectangle($im,$raduis*2+$fontSize,10+$fontSize*$i,$raduis*2+$fontSize*2,6+$fontSize*$i+$fontSize,$pieColor);

          }

          imagejpeg($im);

          imagedestroy($im);

          ?>

          補充:好吧,驗證碼比較難看,應大家要求,換個好看點的

          復制代碼

          1.<?php

          2.session_start();

          3.header("content-type:image/png"); //設置創建圖像的格式

          4.$image_width=70; //設置圖像寬度

          5.$image_height=18; //設置圖像高度

          6.srand(microtime()*100000); //設置隨機數的種子

          7.for($i=0;$i<4;$i++){ //循環輸出一個4位的隨機數

          8. $new_number.=rand(0,9);

          9.}

          10.$_SESSION[check_checks]=$new_number; //將獲取的隨機數驗證碼寫入到SESSION變量中

          11.

          12.$num_image=imagecreate($image_width,$image_height); //創建一個畫布

          13.imagecolorallocate($num_image,255,255,255); //設置畫布的顏色

          14.for($i=0;$i<strlen($_SESSION[check_checks]);$i++){ //循環讀取SESSION變量中的驗證碼

          15. $font=mt_rand(3,5); //設置隨機的字體

          16. $x=mt_rand(1,8)+$image_width*$i/4; //設置隨機字符所在位置的X坐標

          17. $y=mt_rand(1,$image_height/4); //設置隨機字符所在位置的Y坐標

          18. $color=imagecolorallocate($num_image,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200)); //設置字符的顏色

          19. imagestring($num_image,$font,$x,$y,$_SESSION[check_checks][$i],$color); //水平輸出字符

          20.}

          21.imagepng($num_image); //生成PNG格式的圖像

          22.imagedestroy($num_image); //釋放圖像資源

          23.?>

          三、header函數、iconv、get_loaded_extensions函數

          header函數

          1、聲明圖片

          Header(“content-type:image/xxxx”);

          2、當前頁面強制轉碼

          header("content-type:text/html;charset=utf-8");

          3、強制跳轉

          header("location:http://www.xuewanwang.com");

          ……

          詳細請參閱 學玩網 header函數的用法

          注意事項:header函數前不能有空格、回車(\n)、換行(\r)等非法內容;也不能包含任何輸出的語句;不能放任何HTML標簽,但是可以放到<html>之前

          iconv字符串強制轉碼:

          iconv("原來的編碼","轉出后的編碼",$str);

          Get_loaded_extensions() 判斷是否開啟對應函數庫,返回支持庫字符串數組


          主站蜘蛛池模板: 成人中文字幕一区二区三区| 亚洲一区二区久久| 精品少妇人妻AV一区二区| 国产成人综合一区精品| 99久久精品国产高清一区二区 | 一区二区高清在线| 国产精品视频一区二区猎奇| 熟女性饥渴一区二区三区| 精品一区二区ww| 亚洲国产成人久久综合一区| 中文字幕一区二区三区永久 | 国产精品无码不卡一区二区三区| 日本精品无码一区二区三区久久久 | 国产免费一区二区视频| 亚洲男人的天堂一区二区| 国产嫖妓一区二区三区无码| 国产手机精品一区二区| 人妻体内射精一区二区三四| 日韩AV无码一区二区三区不卡毛片| 动漫精品第一区二区三区| 亚洲爆乳精品无码一区二区| 欧洲无码一区二区三区在线观看| 日韩AV无码一区二区三区不卡毛片| 亚洲AV无码一区二三区 | 日亚毛片免费乱码不卡一区| 精品日韩一区二区| 日韩一区二区三区不卡视频 | 国语对白一区二区三区| 国产精品视频分类一区| 国产日韩精品视频一区二区三区| 中文字幕日韩丝袜一区| 亚洲影视一区二区| 在线成人一区二区| 男插女高潮一区二区| 亚洲日韩AV一区二区三区中文| 中文字幕精品一区二区2021年| 亚洲AV香蕉一区区二区三区| 无码少妇一区二区浪潮免费| 无码视频一区二区三区| 波多野结衣一区在线| 成人国产精品一区二区网站|