当前位置:网站首页>07_ Handout on the essence and practical skills of text measurement and geometric transformation
07_ Handout on the essence and practical skills of text measurement and geometric transformation
2022-07-07 07:23:00 【Programmer base camp】
07_ The essence and practical skills of character measurement and geometric transformation The notes
- HenCoder Plus The first 7 course The notes draw ( Two )
- Text measurement 量
- Text measurement 量 One of the difficulties : Centered longitudinal measurement 量
- Text measurement 量 Difficulty 2 : Align left
- Text measurement 量 The third difficulty : in 行
- Canvas Range cutting
- Canvas The geometric transformation of
- Matrix The geometric transformation of
- Use Camera Do three-dimensional rotation
- setLocation()
HenCoder Plus The first 7 course The notes draw ( Two )
Text measurement 量
Draw text :drawText()
Text measurement 量 One of the difficulties : Centered longitudinal measurement 量
- Mode one :Paint.getTextBounds() after , Use (bounds.top + bounds.bottom) / 2
- Mode two :Paint.getFontMetrics() after , Use (fontMetrics.ascend + fontMetrics.descend) / 2
Text measurement 量 Difficulty 2 : Align left
use getTextBounds() After that left To calculate
Text measurement 量 The third difficulty : in 行
use breakText() To calculate
Canvas Range cutting
- clipRect()
- clipPath() clipPath() Why does the cut circle have no anti aliasing effect ? because 「 Forced edge cutting 」
- clipOutRect() / clipOutPath()
Canvas The geometric transformation of
- translate(x, y)
- rotate(degree)
- scale(x, y)
- skew(x, y)
a key :Canvas The geometric transformation method of refers to View The coordinate system of , And the drawing method (drawXxx()) The reference is Canvas Own coordinate system .
About multiple transformations :
Canvas When the transformation method of is called many times , because Canvas The coordinate system of will be transformed as a whole , So when translating 、 rotate 、 Shrinkage 、 When there are multiple transformations such as staggering ,Canvas The transformation parameters of will be very difficult to calculate , Therefore, we can use the way of understanding in reverse order :
take Canvas The transformation of is understood as Canvas The coordinate system of 不 change , Each transformation is only for the internal drawing content 行 Transformation , At the same time Canvas The transformation order of is regarded as reverse ( That is, the transformation written below is executed first ), It can be more convenient 便 Into the 行 Parameter calculation of multiple transformations .
Matrix The geometric transformation of
- preTranslate(x, y) / postTranslate(x, y)
- preRotate(degree) / postRotate(degree)
- preScale(x, y) / postScale(x, y)
- preSkew(x, y) / postSkew(x, y)
among preXxx() Effect and Canvas The method of quasi homonymy is the same , postXxx() Effect and Canvas The order of quasi homonymous methods is opposite .
Be careful
If used repeatedly Matrix, Before use, you need to use Matrix.reset() Come and take Matrix Reset .
Use Camera Do three-dimensional rotation
- rotate() / rotateX() / rotateY() / rotateZ()
- translate()
- setLocation()
among , Generally only rotateX() and rorateY() To do along x Axis or y The rotation of the shaft , And the use of setLocation() To adjust the visual amplitude of zoom .
Yes Camera After the change , Use Camera.applyToCanvas(Canvas) To apply to Canvas.
setLocation()
Generally, the first two parameters of this method are filled 0, The third parameter is negative . Because the unit of this value is hard coded , Therefore, the higher the pixel density of mobile phones , amount to Camera distance View Closer , So it's best to write this value as machine 器 Of density A negative value in direct proportion , for example -6 * density.
边栏推荐
- Fast quantitative, abbkine protein quantitative kit BCA method is coming!
- sql中对集合进行非空校验
- Lvs+kept (DR mode) learning notes
- Precise space-time travel flow regulation system - ultra-high precision positioning system based on UWB
- 2018 Jiangsu Vocational College skills competition vocational group "information security management and evaluation" competition assignment
- 计算机服务中缺失MySQL服务
- SQLMAP使用教程(四)实战技巧三之绕过防火墙
- Release notes of JMeter version 5.5
- Exception of DB2 getting table information: caused by: com ibm. db2.jcc. am. SqlException: [jcc][t4][1065][12306][4.25.13]
- At the age of 20, I got the ByteDance offer on four sides, and I still can't believe it
猜你喜欢
Communication between non parent and child components
Le Service MySQL manque dans le service informatique
我理想的软件测试人员发展状态
弹性布局(一)
组件的嵌套和拆分
RuntimeError: CUDA error: CUBLAS_ STATUS_ ALLOC_ Failed when calling `cublascreate (handle) `problem solving
Composition API premise
深度学习花书+机器学习西瓜书电子版我找到了
Fast quantitative, abbkine protein quantitative kit BCA method is coming!
Use of completable future
随机推荐
Software acceptance test
子组件传递给父组件
C language (high-level) data storage + Practice
Leetcode t1165: log analysis
transform-origin属性详解
Modify the jupyter notebook file path
LC 面试题 02.07. 链表相交 & LC142. 环形链表II
LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
Tool class: object to map hump to underline underline hump
1090: integer power (multi instance test)
js小练习----分时提醒问候、表单密码显示隐藏效果、文本框焦点事件、关闭广告
Abnova circulating tumor DNA whole blood isolation, genomic DNA extraction and analysis
toRefs API 与 toRef Api
Stack Title: nesting depth of valid parentheses
[Luogu p1971] rabbit and egg game (bipartite game)
Détailler le bleu dans les tâches de traduction automatique
Master-slave replication principle of MySQL
Abnova membrane protein lipoprotein technology and category display
FullGC问题分析及解决办法总结
"Xiaodeng in operation and maintenance" meets the compliance requirements of gdpr