当前位置:网站首页>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.
边栏推荐
- Unity C function notes
- [explanation of JDBC and internal classes]
- Select the product attribute pop-up box to pop up the animation effect from the bottom
- Master-slave replication principle of MySQL
- Jesd204b clock network
- Chinese and English instructions prosci LAG-3 recombinant protein
- js小练习----分时提醒问候、表单密码显示隐藏效果、文本框焦点事件、关闭广告
- FullGC问题分析及解决办法总结
- 修改Jupyter Notebook文件路径
- Multidisciplinary integration
猜你喜欢

Precise space-time travel flow regulation system - ultra-high precision positioning system based on UWB

$parent(获取父组件) 和 $root(获取根组件)

Wechat applet full stack development practice Chapter 3 Introduction and use of APIs commonly used in wechat applet development -- 3.9 introduction to network interface (IX) extending the request3 met

Answer to the second stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition

How can brand e-commerce grow against the trend? See the future here!

虚拟机的作用

非父子组件的通信

IP address

深度学习花书+机器学习西瓜书电子版我找到了

面试官:你都了解哪些开发模型?
随机推荐
Blue Bridge Cup Netizen age (violence)
Apache AB stress test
Networkx drawing and common library function coordinate drawing
LC 面试题 02.07. 链表相交 & LC142. 环形链表II
js小练习----分时提醒问候、表单密码显示隐藏效果、文本框焦点事件、关闭广告
[explanation of JDBC and internal classes]
Multidisciplinary integration
Sword finger offer high quality code
计算机服务中缺失MySQL服务
抽絲剝繭C語言(高階)數據的儲存+練習
Sqlserver multithreaded query problem
Introduction to abnova's in vitro mRNA transcription workflow and capping method
How DHCP router works
main函数在import语句中的特殊行为
Tujia, muniao, meituan... Home stay summer war will start
Esxi attaching mobile (Mechanical) hard disk detailed tutorial
MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
软件验收测试
transform-origin属性详解
詳解機器翻譯任務中的BLEU