0
A
回答
2
最好的老師是圖像本身。如果你在CircleMorph上打開一個瀏覽器,你會看到它的超類EllipseMorph定義了#drawOn :,這是變形如何繪製自己。從那裏,你可以得到所有的信息和靈感,讓你的自定義變身。
更新:我的第一個想法是手工繪製(完全覆蓋#drawOn :),但Canvas中沒有任何明顯的候選項。通過讓圓圈在將剪裁矩形設置爲四分之一的同時繪製自己,它幾乎變成了一行。
更新2:四分之一圈的技巧是讓CircleMorph爲您完成大部分工作!我想出的最好的是:
QuarterCircleMorph>>drawOn: aCanvas
| realBounds |
"Save the actual bounds of the morph"
realBounds := bounds.
"Pretend the bounds are 4x as big"
bounds := bounds bottom: bounds bottom + bounds height.
bounds := bounds right: bounds right + bounds width.
"Let CircleMorph handle the drawing"
super drawOn: aCanvas.
"Restore the actual bounds"
bounds := realBounds.
其中QuarterCircleMorph是CircleMorph的子類。因爲你無法通過它的真實界限,所有事情都可以實現。注:在實際的代碼中,評論將是過度殺傷(除了可能是4x的,但是,那麼這是一個標誌,可能是重構:))
相關問題
- 1. ImageMagick Crop Circle from Circle?
- 2. Circle Summation(30分)InterviewStree益智
- 3. OpenGL C++ Circle vs Circle Collision
- 4. DACircularProgress Track Circle比Progress Circle大
- 5. Squeak FFI在新Squeak中的語法是什麼(5.0)
- 6. Circle ProgressBar
- 7. cv :: circle
- 8. Java - Circle Fractal
- 9. iphone uiview circle?
- 10. Responsive circle image bootstrap
- 11. CGContextClearRect with circle
- 12. CSS Progress Circle
- 13. ImageViews in circle
- 14. android circle progressbar
- 15. C#Circle Pathfinding
- 16. NullPointerException java circle project
- 17. HTML5 Canvas Circle Text
- 18. JavaFX Circle和ImageView
- 19. CSS circle-progress-bar
- 20. boundingMapRect for a circle
- 21. Image of the circle
- 22. istanbul和Circle-CI
- 23. Bootstrap Circle Modal
- 24. UITableViewCell circle imageview
- 25. JavaFX Canvas clear Circle
- 26. hough circle opencv iOS
- 27. Circle to tangent mapping
- 28. Android:ProgressDialog Circle not showing
- 29. progress circle UIControll iPhone
- 30. jQuery Draggable area(Circle)
謝謝,但它沒有那麼有用。我不明白這一點。該EllipseMorphs繪製方法:'code' drawOn:aCanvas \t aCanvas isShadowDrawing \t \t ifTrue:[^ aCanvas fillOval:邊界填充樣式:自我填充樣式邊框寬度:0 BORDERCOLOR:無]。 \t aCanvas fillOval:bounds fillStyle:self fillStyle borderWidth:borderWidth borderColor:borderColor。 'code' 但是如何繪製圓或弧的一部分? 這將是很好,如果你可以給我一個代碼snipplet。 – Janus
並且讓你擺脫所有的樂趣! –
現在你知道Morphs自己畫的地方,你如何調整你的子圖中的方法來做你想做的事? –