[go: up one dir, main page]

CN118154721B - Smooth fillet generation method, image drawing method and related devices - Google Patents

Smooth fillet generation method, image drawing method and related devices Download PDF

Info

Publication number
CN118154721B
CN118154721B CN202410582636.5A CN202410582636A CN118154721B CN 118154721 B CN118154721 B CN 118154721B CN 202410582636 A CN202410582636 A CN 202410582636A CN 118154721 B CN118154721 B CN 118154721B
Authority
CN
China
Prior art keywords
coordinate point
smooth
fillet
point
bezier curve
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410582636.5A
Other languages
Chinese (zh)
Other versions
CN118154721A (en
Inventor
姚嘉
程广峰
陈航
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Meizu Telecom Equipment Co ltd
Original Assignee
Meizu Telecom Equipment Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Meizu Telecom Equipment Co ltd filed Critical Meizu Telecom Equipment Co ltd
Priority to CN202410582636.5A priority Critical patent/CN118154721B/en
Publication of CN118154721A publication Critical patent/CN118154721A/en
Application granted granted Critical
Publication of CN118154721B publication Critical patent/CN118154721B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The present disclosure relates to a smooth fillet generation method, a corresponding image drawing method, and a related apparatus. The smooth fillet generating method comprises the following steps: acquiring a smooth margin and a fillet radius value and determining a first coordinate point and a second coordinate point which are end points of the smooth fillet based on the sum of the smooth margin and the fillet radius value; determining a third coordinate point serving as a middle point of the smooth fillet according to the fillet radius; generating a first Bezier curve by taking the first coordinate point and the third coordinate point as endpoints, and generating a second Bezier curve by taking the third coordinate point and the second coordinate point as endpoints; the smoothly rounded corners are obtained based on the first and second bezier curves. The method and the device realize intuitive and smooth adjustable fillets by additionally adding smooth parameters representing the length in addition to the conventional fillet radius value and combining with a Bezier curve. The method can realize smooth fillets capable of lossless self-adaptive amplification with extremely low cost under the condition of not modifying the original Android implementation, and is suitable for various application development scenes.

Description

平滑圆角生成方法和图像绘制方法及相关装置Smooth rounded corner generation method and image drawing method and related device

技术领域Technical Field

本公开涉及终端领域,尤其涉及一种平滑圆角生成方法和图像绘制方法及相关装置。The present disclosure relates to the field of terminals, and in particular to a smooth rounded corner generation method and an image drawing method and related devices.

背景技术Background Art

在当前手机的操作系统(例如,Android系统)中,只需要指定一个圆角半径值,就可以在矩形的四个角上应用对应的圆角效果。但生成的圆角通常是直接画出与指定的圆角半径对应的圆,并把圆裁切出1/4段圆弧后替换套用在矩形四个角上,在视觉上会显得圆角过渡有凸出且不够平顺,从而影响用户体验。In current mobile phone operating systems (e.g., Android), you only need to specify a fillet radius value to apply the corresponding fillet effect to the four corners of a rectangle. However, the generated fillet is usually directly drawn by directly drawing a circle corresponding to the specified fillet radius, and then cutting out a 1/4 arc from the circle and replacing it with the four corners of the rectangle. Visually, the fillet transition will appear convex and not smooth, thus affecting the user experience.

发明内容Summary of the invention

根据本公开实施例的第一个方面,提供了一种平滑圆角生成方法,所述平滑圆角生成于相互垂直的第一边和第二边之间,并且所述方法包括:获取平滑余量和圆角半径值;根据所述平滑余量和所述圆角半径值之和确定位于所述第一边上的第一坐标点和位于所述第二边上的第二坐标点;根据所述圆角半径值确定第三坐标点,所述第三坐标点为所述平滑圆角的中间点;以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线,并以所述第三坐标点和所述第二坐标点为端点生成第二贝塞尔曲线;以及基于所述第一贝塞尔曲线和所述第二贝塞尔曲线得到所述平滑圆角。According to a first aspect of an embodiment of the present disclosure, a method for generating a smooth rounded corner is provided, wherein the smooth rounded corner is generated between a first side and a second side that are perpendicular to each other, and the method comprises: obtaining a smoothing margin and a rounded corner radius value; determining a first coordinate point located on the first side and a second coordinate point located on the second side according to the sum of the smoothing margin and the rounded corner radius value; determining a third coordinate point according to the rounded corner radius value, wherein the third coordinate point is the middle point of the smooth rounded corner; generating a first Bezier curve with the first coordinate point and the third coordinate point as endpoints, and generating a second Bezier curve with the third coordinate point and the second coordinate point as endpoints; and obtaining the smooth rounded corner based on the first Bezier curve and the second Bezier curve.

可选地,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线,包括:以所述第一坐标点和所述第三坐标点为端点,第四坐标点和第五坐标点为柄点,生成第一贝塞尔曲线,其中,所述第四坐标点和所述第五坐标点的坐标是基于所述圆角半径值确定的,以使所述第一贝塞尔曲线的斜率连续变化。Optionally, generating a first Bezier curve with the first coordinate point and the third coordinate point as endpoints includes: generating the first Bezier curve with the first coordinate point and the third coordinate point as endpoints and the fourth coordinate point and the fifth coordinate point as handle points, wherein the coordinates of the fourth coordinate point and the fifth coordinate point are determined based on the fillet radius value so that the slope of the first Bezier curve changes continuously.

可选地,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线之前,还包括:根据第一角度和所述圆角半径值确定所述第四坐标点的坐标;以及根据第二角度和所述圆角半径值确定所述第五坐标点的坐标;所述第一角度对应于所述第四坐标点与定位点之间的连线与第二边之间的夹角,所述定位点对应于具有所述圆角半径值的普通圆角的圆心,所述第二边为所述平滑圆角所处两边中第二坐标点所处的一边;所述第二角度对应于所述第五坐标点和所述定位点之间的连线与所述第三坐标点和所述定位点之间的连线所构成的夹角。Optionally, before generating the first Bezier curve with the first coordinate point and the third coordinate point as endpoints, it also includes: determining the coordinates of the fourth coordinate point according to the first angle and the fillet radius value; and determining the coordinates of the fifth coordinate point according to the second angle and the fillet radius value; the first angle corresponds to the angle between the line between the fourth coordinate point and the positioning point and the second side, the positioning point corresponds to the center of a common fillet with the fillet radius value, and the second side is one of the two sides where the second coordinate point is located; the second angle corresponds to the angle formed by the line between the fifth coordinate point and the positioning point and the line between the third coordinate point and the positioning point.

可选地,以所述第三坐标点和所述第二坐标点为端点生成第二贝塞尔曲线,包括:翻转生成的所述第一贝塞尔曲线,以获取所述第二贝塞尔曲线。Optionally, generating a second Bezier curve with the third coordinate point and the second coordinate point as endpoints includes: flipping the generated first Bezier curve to obtain the second Bezier curve.

可选地,坐标点的坐标以所述第一边和所述第二边之间的交点为原点,并且所述第三坐标点与半径为所述圆角半径值的普通圆角的中间点重合。Optionally, the coordinates of the coordinate point have the intersection of the first side and the second side as the origin, and the third coordinate point coincides with the middle point of a common fillet with a radius equal to the fillet radius value.

可选地,所述平滑余量为圆角平滑度和所述圆角半径值的乘积。Optionally, the smoothing margin is the product of the fillet smoothness and the fillet radius value.

可选地,所述平滑圆角绘制于矩形区域的一个直角位置,并且所述方法还包括:将所述平滑圆角旋转预定角度;以及将旋转的所述平滑圆角分别移至对应于所述矩形区域其余直角的位置。Optionally, the smooth rounded corner is drawn at a right angle in the rectangular area, and the method further comprises: rotating the smooth rounded corner by a predetermined angle; and moving the rotated smooth rounded corners to positions corresponding to the remaining right angles of the rectangular area.

根据本公开实施例的第二个方面,提供了一种图像绘制方法,包括:采用如第一个方面所述的方法生成路径,所述路径包括所述平滑圆角;以及根据绘制界面的对象类型和所述路径生成图像。其中:响应于对象类型为路径,将所述路径作为所述图像;响应于对象类型为画布,选择如下之一的调用:将画布剪裁至所述路径的范围内,并在所述路径的范围内绘制画布内容,或者绘制画布内容,并在绘制结束后将所述路径的范围之外的内容擦除;响应于对象类型为可绘制,使用画布对应的调用修改所述可绘制的绘制结果;响应于对象类型为位图,将位图设置为画布的绘制底图,绘制画布内容,并在绘制结束后将所述路径的范围之外的内容擦除;响应于对象类型为视图,设置视图的边界轮廓为对应于所述路径的平滑圆角曲线并根据所述边界轮廓剪裁该视图;响应于对象类型为视图组,使用设置的平滑圆角视图对象自动剪裁视图组内的视图以生成所述路径作为设定的平滑圆角边界。According to the second aspect of the embodiment of the present disclosure, there is provided an image drawing method, comprising: generating a path using the method described in the first aspect, the path including the smooth rounded corners; and generating an image according to the object type of the drawing interface and the path. Wherein: in response to the object type being a path, the path is used as the image; in response to the object type being a canvas, one of the following calls is selected: clipping the canvas to the range of the path, and drawing the canvas content within the range of the path, or drawing the canvas content, and erasing the content outside the range of the path after the drawing is completed; in response to the object type being a drawable, using the call corresponding to the canvas to modify the drawing result of the drawable; in response to the object type being a bitmap, setting the bitmap as the drawing base map of the canvas, drawing the canvas content, and erasing the content outside the range of the path after the drawing is completed; in response to the object type being a view, setting the boundary contour of the view to a smooth rounded corner curve corresponding to the path and clipping the view according to the boundary contour; in response to the object type being a view group, using the set smooth rounded corner view object to automatically clip the views in the view group to generate the path as the set smooth rounded corner boundary.

根据本公开实施例的第三个方面,提供了一种计算设备,包括:处理器;以及存储器,其上存储有可执行代码,当所述可执行代码被所述处理器执行时,使所述处理器执行基于如第一和/或第二个方面所述的方法。According to a third aspect of an embodiment of the present disclosure, a computing device is provided, comprising: a processor; and a memory on which executable code is stored, and when the executable code is executed by the processor, the processor executes the method based on the first and/or second aspects.

根据本公开实施例的第四个方面,提供了一种非暂时性机器可读存储介质,其上存储有可执行代码,当可执行代码被电子设备的处理器执行时,使处理器执行如上述第一和/或第二个方面所述的方法。According to a fourth aspect of an embodiment of the present disclosure, a non-temporary machine-readable storage medium is provided, on which an executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first and/or second aspect above.

根据本公开实施例的第五个方面,提供了一种计算机程序产品,包括计算机程序指令,当该计算机程序指令被处理器执行时实现基于如第一和/或第二个方面所述的方法。According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising computer program instructions, which, when executed by a processor, implement the method based on the first and/or second aspect.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

通过结合附图对本公开示例性实施方式进行更详细的描述,本公开的上述以及其它目的、特征和优势将变得更加明显,其中,在本公开示例性实施方式中,相同的参考标号通常代表相同部件。The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components in the exemplary embodiments of the present disclosure.

图1示意性地示出了根据本公开的实施例的终端设备的示例性硬件结构框图。FIG1 schematically shows an exemplary hardware structure block diagram of a terminal device according to an embodiment of the present disclosure.

图2示出了利用圆弧画出圆角矩形的一个例子。FIG. 2 shows an example of drawing a rounded rectangle using an arc.

图3示出了根据本公开一个实施例的平滑圆角生成方法的示意性流程图。FIG3 shows a schematic flowchart of a method for generating smooth rounded corners according to an embodiment of the present disclosure.

图4示出了根据本公开生成的平滑圆角及其对应普通圆角的一个例子。FIG. 4 shows an example of a smooth rounded corner and its corresponding normal rounded corner generated according to the present disclosure.

图5示出了根据由第一角度和第二角度结合圆角半径值确定的柄点绘制平滑圆角的例子。FIG. 5 shows an example of drawing a smooth rounded corner according to a handle point determined by a first angle and a second angle in combination with a rounded corner radius value.

图6示出了根据本公开一个实施例的图像绘制方法的示意性流程图。FIG6 shows a schematic flowchart of an image drawing method according to an embodiment of the present disclosure.

图7示出了根据本公开的平滑圆角生成方法得到的平滑圆角矩形。FIG. 7 shows a smooth rounded rectangle obtained according to the smooth rounded corner generation method disclosed in the present invention.

图8示出了本公开的图像绘制方法的一个例子。FIG. 8 shows an example of the image drawing method of the present disclosure.

图9示出了根据本公开至少一个实施例的可用于实现上述方法的计算设备的结构示意图。FIG. 9 shows a schematic diagram of the structure of a computing device that can be used to implement the above method according to at least one embodiment of the present disclosure.

具体实施方式DETAILED DESCRIPTION

下面将参照附图更详细地描述本公开的优选实施方式。虽然附图中显示了本公开的优选实施方式,然而应该理解,可以以各种形式实现本公开而不应被这里阐述的实施方式所限制。相反,提供这些实施方式是为了使本公开更加透彻和完整,并且能够将本公开的范围完整地传达给本领域的技术人员。The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

本公开实施例提供的平滑圆角生成方法和图像绘制方法可以应用于手机、平板电脑、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtualreality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等具有显示模组的电子设备上,还可以应用于数据库、服务器以及基于终端人工智能的具有显示模组的服务响应系统,本公开实施例对电子设备的具体类型不作任何限制。The smooth rounded corner generation method and image drawing method provided in the embodiments of the present disclosure can be applied to electronic devices with display modules, such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR)/virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc., and can also be applied to databases, servers, and service response systems with display modules based on terminal artificial intelligence. The embodiments of the present disclosure do not impose any restrictions on the specific types of electronic devices.

在一些实施例中,上述终端设备可以是具备如图1所示的示例性硬件结构的示例性的手机100,如图1所示,手机100具体可以包括:射频(Radio Frequency,RF)电路110、存储器120、输入单元130、显示单元140、传感器150、音频电路160、短距离无线通信模块170、处理器180、以及电源190等部件。本领域技术人员可以理解,图1中示出的手机100的结构并不构成对终端设备的限定,终端设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。In some embodiments, the terminal device may be an exemplary mobile phone 100 having an exemplary hardware structure as shown in FIG1 . As shown in FIG1 , the mobile phone 100 may specifically include components such as a radio frequency (RF) circuit 110, a memory 120, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a short-range wireless communication module 170, a processor 180, and a power supply 190. Those skilled in the art may understand that the structure of the mobile phone 100 shown in FIG1 does not limit the terminal device, and the terminal device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

下面结合图1对手机100的各个构成部件进行具体的介绍:The following is a detailed introduction to the various components of the mobile phone 100 in conjunction with FIG. 1 :

RF电路110可用于收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,给处理器180处理;另外,将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low NoiseAmplifier,LNA)、双工器等。此外,RF电路110还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,所述无线通信可以包括全球移动通讯系统(GlobalSystem For Mobile Communications,GSM),通用分组无线服务(General Packet RadioService,GPRS),码分多址接入(Code DivisionMultiple Access,CDMA),宽带码分多址(Wideband Code Division Multiple Access,WCDMA),时分码分多址(Time-DivisionCode Division Multiple Access,TD-SCDMA),长期演进(Long Term Evolution,LTE),新无线(New Radio,NR),GNSS,FM,低轨卫星连接和/或IR技术等。所述GNSS可以包括全球卫星定位系统(Global Positioning System,GPS),全球导航卫星系统(Global NavigationSatellite System,GLONASS),北斗卫星导航系统(BeiDou Navigation SatelliteSystem,BDS),准天顶卫星系统(Quasi-Zenithsatellite System,QZSS)和/或星基增强系统(Satellite Based Augmentation Systems,SBAS)等。The RF circuit 110 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 180 for processing; in addition, the uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the RF circuit 110 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, and the wireless communication may include Global System For Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), New Radio (NR), GNSS, FM, low-orbit satellite connection and/or IR technology, etc. The GNSS may include a Global Positioning System (GPS), a Global Navigation Satellite System (GLONASS), a BeiDou Navigation Satellite System (BDS), a Quasi-Zenith Satellite System (QZSS) and/or a Satellite Based Augmentation System (SBAS), etc.

存储器120可用于存储软件程序以及模块,处理器180通过运行存储在存储器120的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器120可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据手机的使用所创建的数据(比如图片、音频数据、电话本等)等。此外,存储器120可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。例如,存储器120可以存储操作系统和应用代码,并且可以存储用于实现本公开的平滑圆角生成方法和图像绘制方法的代码。The memory 120 can be used to store software programs and modules. The processor 180 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 120. The memory 120 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as pictures, audio data, phone books, etc.), etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. For example, the memory 120 may store an operating system and application codes, and may store codes for implementing the smooth fillet generation method and image drawing method disclosed in the present invention.

输入单元130可用于接收输入的数字或字符信息,以及产生与手机100的用户设置以及功能控制有关的键信号输入。具体地,输入单元130可包括触控面板131以及其他输入设备132。触控面板131,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指(例如单指或多指)、触控笔等任何适合的物体或附件在触控面板131上或在触控面板131附近的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触控面板131可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器180,并能接收处理器180发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板131。除了触控面板131,输入单元130还可以包括其他输入设备132。具体地,其他输入设备132可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。The input unit 130 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone 100. Specifically, the input unit 130 may include a touch panel 131 and other input devices 132. The touch panel 131, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 131 or near the touch panel 131 using any suitable object or accessory such as a finger (such as a single finger or multiple fingers), a stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 131 may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 180, and can receive and execute the command sent by the processor 180. In addition, the touch panel 131 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 131, the input unit 130 may also include other input devices 132. Specifically, other input devices 132 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.

显示单元140可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单,例如显示不同的应用。显示单元140可包括显示面板141,可选的,可以采用液晶显示器(Liquid CrystalDisplay,LCD)、发光二极管(Light Emitting Diode,LED)、有机发光二极管(Organic Light-Emitting Diode,OLED)、有源矩阵有机发光二极管(Active-MatrixOrganic Light Emitting Diode,AMOLED)等形式来配置显示面板141。进一步的,触控面板131可覆盖显示面板141,当触控面板131检测到在其上或附近的触摸操作后,传送给处理器180以确定触摸事件的类型,随后处理器180根据触摸事件的类型在显示面板141上提供相应的视觉输出。例如,当触控面板131检测到触控滑动事件时,处理器180根据用户的触控滑动轨迹在显示面板141上变换滑动对象的显示,例如,显示界面的上移或下移。虽然在图1中,触控面板131与显示面板141是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板131与显示面板141集成为触摸屏而实现手机的输入和输出功能。The display unit 140 may be used to display information input by the user or information provided to the user and various menus of the mobile phone, such as displaying different applications. The display unit 140 may include a display panel 141. Optionally, the display panel 141 may be configured in the form of a liquid crystal display (LCD), a light emitting diode (LED), an organic light emitting diode (OLED), an active-matrix organic light emitting diode (AMOLED), etc. Further, the touch panel 131 may cover the display panel 141. When the touch panel 131 detects a touch operation on or near it, it is transmitted to the processor 180 to determine the type of touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of touch event. For example, when the touch panel 131 detects a touch sliding event, the processor 180 changes the display of the sliding object on the display panel 141 according to the touch sliding track of the user, for example, the display interface moves up or down. Although in FIG. 1 , the touch panel 131 and the display panel 141 are two independent components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 131 and the display panel 141 may be integrated into a touch screen to implement the input and output functions of the mobile phone.

手机100还可包括至少一种传感器150,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板141的亮度,接近传感器可在手机移动到耳边时,关闭显示面板141和/或背光。作为运动传感器的一种,加速计传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于手机还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。The mobile phone 100 may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 141 and/or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

音频电路160、扬声器161,传声器162可提供用户与手机之间的音频接口。音频电路160可将接收到的音频数据转换后的电信号,传输到扬声器161,由扬声器161转换为声音信号输出;另一方面,传声器162将收集的声音信号转换为电信号,由音频电路160接收后转换为音频数据,再将音频数据输出处理器180处理后,经RF电路110以发送给比如另一电子设备,或者将音频数据输出至存储器120以便进一步处理。The audio circuit 160, the speaker 161, and the microphone 162 can provide an audio interface between the user and the mobile phone. The audio circuit 160 can transmit the received audio data to the speaker 161 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, and then the audio data is output to the processor 180 for processing, and then sent to another electronic device through the RF circuit 110, or the audio data is output to the memory 120 for further processing.

Wi-Fi、蓝牙、近距离无线通信(Near Field Communication,NFC)以及超宽带(Ultra Wide Band,UWB)等通信技术属于短距离无线传输技术,手机通过短距离无线模块170可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。上述短距离无线模块170可以包括Wi-Fi芯片、蓝牙芯片、NFC芯片以及UWB芯片,通过该Wi-Fi芯片可以实现手机100与其他电子设备进行Wi-Fi Direct连接的功能,也可以使手机100工作在能够提供无线接入服务,允许其它无线设备接入的AP模式(AccessPoint模式)或工作在可以连接到AP不接受无线设备接入的STA模式(Station模式),从而建立手机100与其他Wi-Fi设备的点对点通信。Communication technologies such as Wi-Fi, Bluetooth, Near Field Communication (NFC) and Ultra Wide Band (UWB) belong to short-range wireless transmission technologies. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the short-range wireless module 170, which provides users with wireless broadband Internet access. The above-mentioned short-range wireless module 170 may include a Wi-Fi chip, a Bluetooth chip, an NFC chip and a UWB chip. The Wi-Fi chip can realize the function of Wi-Fi Direct connection between the mobile phone 100 and other electronic devices, and can also make the mobile phone 100 work in an AP mode (Access Point mode) that can provide wireless access services and allow other wireless devices to access, or work in a STA mode (Station mode) that can connect to an AP but does not accept wireless devices to access, thereby establishing point-to-point communication between the mobile phone 100 and other Wi-Fi devices.

处理器180是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器120内的软件程序和/或模块,以及调用存储在存储器120内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。可选的,处理器180可包括一个或多个处理单元;可选地,处理器180例如可以包括应用处理器(ApplicationProcessor,AP),调制解调处理器,图形处理器(Graphics ProcessingUnit,GPU),图像信号处理器(Image Signal Processor,ISP),控制器,视频编解码器,数字信号处理器(DigitalSignal Processor,DSP),基带处理器,和/或神经网络处理器(Neural-NetworkProcessing Unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 180 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and/or modules stored in the memory 120, and calling data stored in the memory 120, it executes various functions of the mobile phone and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 180 may include one or more processing units; optionally, the processor 180 may include, for example, an application processor (Application Processor, AP), a modem processor, a graphics processor (Graphics Processing Unit, GPU), an image signal processor (Image Signal Processor, ISP), a controller, a video codec, a digital signal processor (Digital Signal Processor, DSP), a baseband processor, and/or a neural network processor (Neural-Network Processing Unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors.

手机100还包括给各个部件供电的电源190(比如电池),优选的,电源可以通过电源管理系统与处理器180逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。The mobile phone 100 also includes a power source 190 (such as a battery) for supplying power to various components. Preferably, the power source can be logically connected to the processor 180 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.

手机100还可以包括摄像头。可选地,摄像头在手机上的位置可以为前置的,也可以为后置的,本公开实施例对此不作限定。The mobile phone 100 may further include a camera. Optionally, the camera may be located at the front or rear of the mobile phone, which is not limited in the embodiments of the present disclosure.

手机100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构等,例如安卓(Android)系统或者IOS(I Operating System)都采用分层架构。The software system of the mobile phone 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture, etc. For example, the Android system or the IOS (I Operating System) both adopt a layered architecture.

圆角是指对象边角的设计或处理方式,使其边缘呈现圆滑的外观而不是尖锐的直角。在计算机领域中,圆角通常指的是界面设计中的一种视觉效果,用于使元素(例如,矩形元素)的边角看起来圆滑而不是尖锐。圆角的应用广泛,特别是在用户界面设计中,它可以提升视觉美感、降低硬性边缘的锐利感,使用户界面更加友好和现代化。Rounded corners refer to the design or treatment of the corners of an object so that its edges appear rounded rather than sharp right angles. In the computer field, rounded corners usually refer to a visual effect in interface design, which is used to make the corners of elements (for example, rectangular elements) look rounded rather than sharp. Rounded corners are widely used, especially in user interface design, where they can enhance visual beauty, reduce the sharpness of hard edges, and make the user interface more friendly and modern.

在现有的终端设备操作系统中(例如,Android系统中),圆角通常是通过绘制圆弧(arc)或者使用特定的形状(如,Android系统中表示圆角矩形的类RoundRectShape)来实现的,这些方法更直接且易于控制圆角的半径和位置。无论是绘制圆弧还是使用RoundRectShape,操作系统生成的圆角是直接画出与指定的圆角半径对应的圆,并把圆裁切出1/4段圆弧后替换套用在矩形四个角上。图2示出了利用圆弧画出圆角矩形的一个例子。In existing terminal device operating systems (e.g., Android systems), rounded corners are usually achieved by drawing arcs or using specific shapes (e.g., the RoundRectShape class that represents a rounded rectangle in the Android system). These methods are more direct and easy to control the radius and position of the rounded corners. Whether drawing an arc or using RoundRectShape, the rounded corners generated by the operating system are directly drawn by drawing a circle corresponding to the specified rounded corner radius, and then cutting out a 1/4 arc from the circle and replacing it with the four corners of the rectangle. Figure 2 shows an example of using an arc to draw a rounded rectangle.

在此,“圆角矩形”指的是四个直角被替换成圆角的矩形。在用户或是系统指定了一个圆角半径r(radius)后,可以生成一个半径为r的圆,并把圆裁切出1/4段圆弧后替换套用在矩形右上、右下、左下和左上四个角,由此得到图中右侧示出的圆角矩形。在此,为了方便说明,可以设矩形由图示的四条边(边1~4)组成,并且可以在图示的矩形左下角处,选取与边1和边2都相距r的点作为圆心C点。由此绘制1/4段圆弧用于替代直角。可以对其他几个直角也进行类似的操作。由此得到圆角矩形。在其他实现中,也可以先得到半径为r的1/4段圆弧再移至矩形的四个角的对应位置。通过如上1/4段圆弧替换直角得到的圆角矩形在视觉上会显得圆角过渡有凸出且不够平顺,并且由此得到的圆角也不够美观。Here, "rounded rectangle" refers to a rectangle whose four right angles are replaced with rounded corners. After the user or the system specifies a fillet radius r (radius), a circle with a radius of r can be generated, and a 1/4 arc is cut out of the circle and then replaced and applied to the upper right, lower right, lower left and upper left corners of the rectangle, thereby obtaining the rounded rectangle shown on the right side of the figure. Here, for the convenience of explanation, it can be assumed that the rectangle is composed of the four sides (sides 1 to 4) shown in the figure, and a point r away from both side 1 and side 2 can be selected at the lower left corner of the rectangle as the center point C. Thus, a 1/4 arc is drawn to replace the right angle. Similar operations can be performed on several other right angles. Thus, a rounded rectangle is obtained. In other implementations, a 1/4 arc with a radius of r can also be obtained first and then moved to the corresponding positions of the four corners of the rectangle. The rounded rectangle obtained by replacing the right angle with the 1/4 arc as above will visually appear to have a convex and not smooth transition of the rounded corners, and the rounded corners obtained are not beautiful enough.

为了实现过渡更加平顺的平滑圆角,就必须用另外一种方式按需生成对应大小的“圆角”,此时的“圆角”将不再使用“圆”构建,而是使用另外的数学形状或方法。在现有技术中,使用从椭圆公式推导出来的一种圆角生成方法,因此它被称为“超椭圆曲线”。但是超椭圆曲线方法生成的圆角和最终期望的仍然有差异:它的形状往往不够平滑、并且拟合超椭圆曲线的代码几乎只能是逐点计算和连接——即,需要循着圆周不断计算。期望绘制出的圆角越平滑,计算精度就需要随之增加,并且精度在像素级。换言之,超椭圆曲线法无法用简单的规则表示出一条曲线,因此性能消耗会随着图形的增大、平滑精度的增加而显著增加。In order to achieve a smoother rounded corner with a smoother transition, it is necessary to use another method to generate a "rounded corner" of the corresponding size on demand. At this time, the "rounded corner" will no longer be constructed using a "circle", but using another mathematical shape or method. In the prior art, a rounded corner generation method derived from an ellipse formula is used, so it is called a "super elliptic curve". However, the rounded corners generated by the super elliptic curve method are still different from the final expectation: its shape is often not smooth enough, and the code for fitting the super elliptic curve can only be calculated and connected point by point-that is, it needs to be calculated continuously along the circumference. The smoother the rounded corners are expected to be drawn, the higher the calculation accuracy needs to be, and the accuracy is at the pixel level. In other words, the super elliptic curve method cannot express a curve with simple rules, so the performance consumption will increase significantly as the graphics increase and the smoothing accuracy increases.

有鉴于此,本公开提出一种平滑圆角生成方法,通过在常规的圆角半径值之外,额外增加一个表示圆角平滑程度的参数,再结合贝塞尔曲线,实现平滑可调的圆角。如下为了方便表述,可以将如图2所示仅基于1/4段圆弧生成的圆角称为“普通圆角”或“圆角”,将本公开额外基于个圆角平滑度并结合贝塞尔曲线生成的圆角称为“平滑圆角”。In view of this, the present disclosure proposes a method for generating smooth rounded corners, by adding a parameter indicating the smoothness of the rounded corners in addition to the conventional rounded corner radius value, and then combining the Bezier curve to achieve a smooth and adjustable rounded corner. For the sake of convenience, the rounded corner generated based only on a 1/4 arc segment as shown in FIG2 may be referred to as a "normal rounded corner" or "rounded corner", and the rounded corner generated based on the rounded corner smoothness and combined with the Bezier curve in the present disclosure may be referred to as a "smooth rounded corner".

图3示出了根据本公开一个实施例的平滑圆角生成方法的示意性流程图。平滑圆角生成于相互垂直的第一边和第二边之间,例如,可以生成与矩形的四个角。在平滑圆角生成方法可由如上图1的终端设备用于圆角绘制,进而得到相比于普通圆角具有更平滑曲线的平滑圆角矩形。一般来讲,这种平滑圆角矩形更符合大众审美。为了方便理解,图4示出了根据本公开生成的平滑圆角及其对应普通圆角的一个例子。在图4的例子中,设两条直角边(边1和边2,可以分别对应于第一边和第二边)的交点为O。普通圆角的圆角半径值为r,并且可以是选取与两条边都相距r的点作为圆心C点做1/4段圆弧得到的,圆角端点分别位于两条边上,且与O的距离都为r。FIG3 shows a schematic flow chart of a method for generating smooth rounded corners according to an embodiment of the present disclosure. A smooth rounded corner is generated between a first side and a second side that are perpendicular to each other. For example, four corners of a rectangle can be generated. The method for generating smooth rounded corners can be used by a terminal device such as FIG1 above for drawing rounded corners, thereby obtaining a smooth rounded rectangle with a smoother curve than an ordinary rounded corner. Generally speaking, such a smooth rounded rectangle is more in line with the public aesthetics. For ease of understanding, FIG4 shows an example of a smooth rounded corner generated according to the present disclosure and its corresponding ordinary rounded corner. In the example of FIG4 , the intersection of two right-angled sides (side 1 and side 2, which can correspond to the first side and the second side, respectively) is set to O. The radius value of the ordinary rounded corner is r, and it can be obtained by selecting a point r away from both sides as the center point C to make a 1/4 arc. The end points of the rounded corners are respectively located on the two sides, and the distance from O is r.

在步骤S310,获取平滑余量和圆角平滑度。In step S310, the smoothing margin and the rounded corner smoothness are obtained.

“圆角半径值”通常指的是圆角的半径大小,表示了一个角被变为圆角时所使用的圆的半径大小。在图4左侧所示的普通圆角的例子中,圆角半径值为r。在本公开的平滑圆角生成方法中,圆角半径值可以用于如下确定平滑圆角的中间点(即,如下的第三坐标点)的位置。例如,在一个实施例中,平滑圆角的中间点可以与半径为r的普通圆角的中间点重合。进一步地,圆角半径值还可以如下用于第一贝塞尔曲线和/或第二贝塞尔曲线的生成。"Fillet radius value" generally refers to the radius of the fillet, indicating the radius of the circle used when a corner is rounded. In the example of a common fillet shown on the left side of FIG. 4, the fillet radius value is r. In the smooth fillet generation method disclosed in the present invention, the fillet radius value can be used to determine the position of the middle point of the smooth fillet (i.e., the third coordinate point shown below) as follows. For example, in one embodiment, the middle point of the smooth fillet can coincide with the middle point of the common fillet with a radius of r. Further, the fillet radius value can also be used to generate the first Bezier curve and/or the second Bezier curve as follows.

“平滑余量” (也可称为“平滑值”或“平滑量”)是本公开为相比于常规的1/4段圆弧圆角生成曲度更平滑圆角而额外引入的参数。该参数可以用于平滑圆角的平滑度的调整。在使用普通圆角的场景中,1/4段圆弧直接替换掉第一边和第二边靠近交点的长度为r的线段。而在使用平滑圆角的场景中,平滑圆角替换掉第一边和第二边靠近交点的线段长度要大于r,如图4所示,可以是长度d。该长度d可以与平滑余量结合圆角半径值确定。平滑余量m可以是一个确定的长度,用于结合圆角半径值确定圆角的开始和结束的位置。相比于普通圆角,平滑余量的加入可以使得绘制的平滑圆角曲线通过更长的距离来到达平滑圆角的中间点,由此实现更为平滑的圆角曲线。"Smoothing margin" (also referred to as "smoothing value" or "smoothing amount") is an additional parameter introduced by the present disclosure to generate a smoother rounded corner than the conventional 1/4 arc rounded corner. This parameter can be used to adjust the smoothness of the smoothed rounded corner. In the scenario using ordinary rounded corners, the 1/4 arc directly replaces the line segment of the first side and the second side near the intersection with a length of r. In the scenario using smoothed rounded corners, the length of the line segment near the intersection of the first side and the second side replaced by the smoothed rounded corner is greater than r, as shown in Figure 4, which can be a length d. The length d can be determined in combination with the smoothing margin and the fillet radius value. The smoothing margin m can be a determined length, which is used to determine the start and end positions of the fillet in combination with the fillet radius value. Compared with ordinary fillets, the addition of a smoothing margin can make the drawn smooth fillet curve reach the middle point of the smooth fillet through a longer distance, thereby achieving a smoother fillet curve.

在一个实施例中,首先直接获取的可以是作为一个比例值的“圆角平滑度”。该比例值s可以用于结合圆角半径值确定平滑余量。平滑余量可以是圆角平滑度和圆角半径值的乘积。例如,在圆角平滑度s为0.5时,平滑余量m可以为0.5r。In one embodiment, the first thing directly obtained may be the "rounding smoothness" as a ratio value. The ratio value s may be used to determine the smoothing margin in combination with the rounding radius value. The smoothing margin may be the product of the rounding smoothness and the rounding radius value. For example, when the rounding smoothness s is 0.5, the smoothing margin m may be 0.5r.

在一个实施例中,可以直接获取预先设置的圆角半径值和平滑余量。在另一个实施例中,可以获取预先设置的圆角半径值和圆角平滑度,并根据圆角半径值和圆角平滑度求取平滑余量。由此,可以基于预先输入的具体值来生成具有平滑圆角的矩形。在另一个实施例中,圆角半径值和平滑余量可以是按照预定规则确定的,例如,在一个长为a,宽为b的矩形中,在该矩形的角形成平滑圆角,此时,圆角半径值和平滑余量可以与a和/或b相关(例如,具有预定比例),平滑余量可以与圆角半径值呈一个固定比例,也可以是a和/或b相关(例如,具有预定比例)的值。In one embodiment, the preset fillet radius value and smoothing margin can be directly obtained. In another embodiment, the preset fillet radius value and fillet smoothness can be obtained, and the smoothing margin can be calculated based on the fillet radius value and fillet smoothness. Thus, a rectangle with smooth rounded corners can be generated based on a specific value input in advance. In another embodiment, the fillet radius value and the smoothing margin can be determined according to a predetermined rule. For example, in a rectangle with a length of a and a width of b, a smooth rounded corner is formed at the corner of the rectangle. At this time, the fillet radius value and the smoothing margin can be related to a and/or b (for example, with a predetermined ratio), and the smoothing margin can be a fixed ratio with the fillet radius value, or it can be a value related to a and/or b (for example, with a predetermined ratio).

随后,可以根据圆角半径值和平滑余量确定所要被替换的直角边的范围。于是,在步骤S320,可以平滑余量和圆角半径值之和确定位于第一边的第一坐标点和位于第二边的第二坐标点。此时,第一坐标点和第二坐标点为平滑圆角的端点。Subsequently, the range of the right-angled side to be replaced can be determined according to the fillet radius value and the smoothing margin. Thus, in step S320, the first coordinate point located at the first side and the second coordinate point located at the second side can be determined by the sum of the smoothing margin and the fillet radius value. At this time, the first coordinate point and the second coordinate point are the endpoints of the smooth fillet.

为了保证添加圆角后的平滑外观,第一坐标点和第二坐标点需要位于用于替换直角的两个直角边上。例如,为了将图4所示的直角替换为平滑圆角,第一坐标点和第二坐标点需要分别位于边1和边2上(才能保证平滑圆角曲线与直角边相连不断开),并且第一坐标点和第二坐标点各自相距两边的交点(即,边1和边2的交点,也就是左下直角的交点处)要比普通圆角的距离r更远。In order to ensure a smooth appearance after adding rounded corners, the first coordinate point and the second coordinate point need to be located on the two right-angled sides used to replace the right angle. For example, in order to replace the right angle shown in Figure 4 with a smooth rounded corner, the first coordinate point and the second coordinate point need to be located on side 1 and side 2 respectively (to ensure that the smooth rounded corner curve is connected to the right angle side without disconnection), and the first coordinate point and the second coordinate point are each farther from the intersection of the two sides (that is, the intersection of side 1 and side 2, that is, the intersection of the lower left right angle) than the distance r of the ordinary rounded corner.

在此,可以设第一坐标点相距两边交点的距离为d1,第二坐标点相距两边交点的距离为d2。此时,由于平滑余量m的存在,d1>r且d2>r。当针对第一边和第二边使用不同的平滑余量(例如,分别为m1和m2)时,d1=r+ m1,且d2=r+ m1,即,此时,d1和d2的值可以不同。Here, the distance between the first coordinate point and the intersection of the two sides can be set as d 1 , and the distance between the second coordinate point and the intersection of the two sides can be set as d 2 . At this time, due to the existence of the smoothing margin m, d 1 >r and d 2 >r. When different smoothing margins are used for the first side and the second side (for example, m 1 and m 2 , respectively), d 1 =r+ m 1 , and d 2 =r+ m 1 , that is, at this time, the values of d 1 and d 2 can be different.

在其他实施例中,出于对称美观的考虑,生成的平滑圆角为相对于中间点对称的曲线,此时圆角平滑度针对矩形的长边和短边可以具有相同的值,且d1和d2的值相同,m1和m2的值也相同。在图4右侧的例子中,d1= d2。可以设m1=m2=m,由此d1= d2=d,即,第一坐标点(坐标点1)和第二坐标点(坐标点2)各自相距两边交点O的距离都为d。在以O点为原点(0,0),两条边为坐标轴时(例如,边1对应于第一坐标轴,边2对应于第二坐标轴),坐标点1的坐标为(0,d)且坐标点2的坐标为(d,0),且d=r+m。在使用圆角平滑度代替平滑余量作为初始参数时,由于m= s×r,因此d= r + s×r。In other embodiments, for the sake of symmetry and beauty, the generated smooth fillet is a curve symmetrical with respect to the middle point. In this case, the fillet smoothness can have the same value for the long side and the short side of the rectangle, and the values of d1 and d2 are the same, and the values of m1 and m2 are also the same. In the example on the right side of Figure 4, d1 = d2 . It can be assumed that m1 = m2 = m, so d1 = d2 = d, that is, the distance between the first coordinate point (coordinate point 1) and the second coordinate point (coordinate point 2) and the intersection point O of the two sides is d. When point O is the origin (0,0) and the two sides are the coordinate axes (for example, side 1 corresponds to the first coordinate axis and side 2 corresponds to the second coordinate axis), the coordinates of coordinate point 1 are (0,d) and the coordinates of coordinate point 2 are (d,0), and d=r+m. When the fillet smoothness is used instead of the smoothing margin as the initial parameter, since m= s×r, d= r + s×r.

在步骤S330,可以根据圆角半径确定第三坐标点,所述第三坐标点为所述平滑圆角的中间点。在本公开中,平滑圆角的中间点可以与普通圆角的中间点位置相同。即,在图4的例子中,绘制平滑圆角所需的第三坐标点(坐标点3)可以与普通圆角的中间点处于相同位置。在以O点为原点(0,0),两条边为坐标轴时,图示左侧的圆角中间点和右侧的坐标点3的坐标都可以是(,),即,由圆角半径确定平滑圆角的中间点。在图示的例子中,为了方便理解,在与普通圆角的圆心C相同位置的定位点与O点之间连接了一条辅助线g(图中灰色虚线),辅助线g上与定位点相距r的位置即为坐标点3的位置。In step S330, a third coordinate point may be determined according to the fillet radius, and the third coordinate point is the middle point of the smooth fillet. In the present disclosure, the middle point of the smooth fillet may be at the same position as the middle point of the ordinary fillet. That is, in the example of FIG. 4 , the third coordinate point (coordinate point 3) required for drawing the smooth fillet may be at the same position as the middle point of the ordinary fillet. When point O is the origin (0,0) and the two sides are the coordinate axes, the coordinates of the middle point of the fillet on the left side of the figure and the coordinate point 3 on the right side may be ( , ), that is, the middle point of the smooth fillet is determined by the fillet radius. In the example shown in the figure, for ease of understanding, an auxiliary line g (gray dotted line in the figure) is connected between the positioning point at the same position as the center C of the ordinary fillet and point O, and the position on the auxiliary line g that is r away from the positioning point is the position of coordinate point 3.

在确定了平滑圆角的两个端点(例如,坐标点1和坐标点2)和一个中间点(例如,坐标点3)之后,可以选择一种能够生成平滑曲线的方法来基于这些点生成平滑曲线。在本公开中,选择具有良好平滑性的贝塞尔曲线来生成平滑圆角。After determining the two endpoints (e.g., coordinate point 1 and coordinate point 2) and an intermediate point (e.g., coordinate point 3) of the smooth fillet, a method capable of generating a smooth curve can be selected to generate a smooth curve based on these points. In the present disclosure, a Bezier curve with good smoothness is selected to generate the smooth fillet.

于是,在步骤S340,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线,以及,以所述第三坐标点和所述第二坐标点为端点生成第二贝塞尔曲线。由此,在步骤S350,基于所述第一贝塞尔曲线和所述第二贝塞尔曲线得到所述平滑圆角。Thus, in step S340, a first Bezier curve is generated with the first coordinate point and the third coordinate point as endpoints, and a second Bezier curve is generated with the third coordinate point and the second coordinate point as endpoints. Thus, in step S350, the smooth fillet is obtained based on the first Bezier curve and the second Bezier curve.

在图4的例子中,坐标点1和坐标点3之间的曲线对应于第一贝塞尔曲线,坐标点3和坐标点2之间的曲线对应于第二贝塞尔曲线。第一贝塞尔曲线和第二贝塞尔曲线整体作为平滑圆角。由此,坐标点1和坐标点2之间的曲线对应于生成的平滑圆角。In the example of FIG. 4 , the curve between coordinate point 1 and coordinate point 3 corresponds to the first Bezier curve, and the curve between coordinate point 3 and coordinate point 2 corresponds to the second Bezier curve. The first Bezier curve and the second Bezier curve are used as a smooth fillet as a whole. Thus, the curve between coordinate point 1 and coordinate point 2 corresponds to the generated smooth fillet.

由于第一坐标点和第二坐标点的位置比普通圆角的圆点端点位置更远,而第三坐标点的位置与普通圆角的中间点相同,因此由此生成的第一贝塞尔曲线和第二贝塞尔曲线,以及由第一贝塞尔曲线和第二贝塞尔曲线组合得到的平滑圆角相比于普通圆角可以具有更加平滑的曲度,从而提供更为平滑美观的圆角。Since the positions of the first coordinate point and the second coordinate point are farther than the end points of the ordinary rounded corner, and the position of the third coordinate point is the same as the middle point of the ordinary rounded corner, the first Bezier curve and the second Bezier curve generated thereby, and the smooth rounded corner obtained by combining the first Bezier curve and the second Bezier curve can have a smoother curvature than the ordinary rounded corner, thereby providing a smoother and more beautiful rounded corner.

如前所述,平滑圆角生成于相互垂直的第一边(例如,边1)和第二边(例如,边2)之间,并且用于生成平滑圆角的贝塞尔曲线的各个控制点的坐标点可以以第一边和第二边之间的交点为原点(例如,点O)。此时,第三坐标点可以与半径为所述圆角半径值的普通圆角的中间点重合。As mentioned above, a smooth rounded corner is generated between a first side (e.g., side 1) and a second side (e.g., side 2) that are perpendicular to each other, and the coordinate points of each control point of the Bezier curve used to generate the smooth rounded corner can be based on the intersection between the first side and the second side as the origin (e.g., point O). At this time, the third coordinate point can coincide with the middle point of a common rounded corner with a radius equal to the rounded corner radius value.

在本公开中,在生成的平滑圆角为相对于中间点对称的曲线,即,d1= d2=d时,为了降低在获取平滑圆角的同时降低计算量,可以基于第一坐标点和第三坐标点(作为端点)以及一个或多个柄点通过如上贝塞尔曲线参数方程来生成第一贝塞尔曲线,并且通过翻转生成的第一贝塞尔曲线来获取第二贝塞尔曲线。由此,以第三坐标点和第二坐标点为端点生成第二贝塞尔曲线可以包括:翻转生成的所述第一贝塞尔曲线,以获取第二贝塞尔曲线。In the present disclosure, when the generated smooth rounded corner is a curve symmetrical with respect to the middle point, that is, d1 = d2 = d, in order to reduce the amount of calculation while obtaining the smooth rounded corner, a first Bezier curve can be generated based on the first coordinate point and the third coordinate point (as endpoints) and one or more handle points through the above Bezier curve parameter equation, and the second Bezier curve can be obtained by flipping the generated first Bezier curve. Thus, generating the second Bezier curve with the third coordinate point and the second coordinate point as endpoints may include: flipping the generated first Bezier curve to obtain the second Bezier curve.

在图4的例子中,位于坐标点3和坐标点2之间的第二贝塞尔曲线是可以通过翻转生成的第一贝塞尔曲线得到的。在以O点为原点(0,0),坐标点1的坐标为(0,d)且坐标点2的坐标为(d,0)时,可以直接通过交换第一贝塞尔曲线每个坐标各自的两个坐标值的位置(第一和第二坐标轴的值互换,即,(x i,yi)转换成(yi,x i))得到第二贝塞尔曲线。由此,通过组合第一和第二贝塞尔曲线,得到平滑圆角。In the example of FIG. 4 , the second Bezier curve between coordinate point 3 and coordinate point 2 can be obtained by flipping the generated first Bezier curve. When point O is the origin (0,0), the coordinates of coordinate point 1 are (0,d) and the coordinates of coordinate point 2 are (d,0), the second Bezier curve can be obtained directly by exchanging the positions of the two coordinate values of each coordinate of the first Bezier curve (the values of the first and second coordinate axes are interchanged, that is, ( xi , yi ) is converted to ( yi , xi ) ). Thus, by combining the first and second Bezier curves, a smooth rounded corner is obtained.

为了进一步降低为矩形绘制四个平滑圆角所需的计算量,可以通过对平滑圆角进行预定角度的旋转和移位来得到用于矩形其他直角的平滑圆角(应该理解,矩形也涵盖长宽相等的方形情况,因此本公开的方法也可以用于为方形绘制四个平滑圆角)。即,通过如上步骤S310~S350生成所述平滑圆角可以绘制于矩形区域的一个直角位置,并且所述方法还包括:将所述平滑圆角旋转预定角度;以及将旋转的所述平滑圆角分别移至对应于所述矩形区域其余直角的位置。具体地,在首先为矩形生成例如左下角的平滑圆角时,可以将该生成的平滑圆角顺时针旋转90°,并移至矩形的左上角,并使得旋转的平滑圆角同时与边1和边4相切(或是直接根据圆角半径值和圆角平滑度确定左上角的平滑圆角的起始位置,再将旋转的平滑圆角相连)。可以将该生成的平滑圆角顺时针旋转180°和270°,再分别移至矩形的右上角和右下角。由此,得到四个角都被替换了平滑圆角的平滑圆角矩形。应该理解的是,对生成的平滑圆角进行逆时针旋转90°、180°和270°并移位亦可得到平滑圆角矩形。In order to further reduce the amount of calculation required to draw four smooth rounded corners for a rectangle, the smooth rounded corners for other right angles of the rectangle can be obtained by rotating and shifting the smooth rounded corners by a predetermined angle (it should be understood that a rectangle also includes a square with equal length and width, so the method disclosed in the present invention can also be used to draw four smooth rounded corners for a square). That is, the smooth rounded corner generated by steps S310 to S350 above can be drawn at a right angle position in a rectangular area, and the method also includes: rotating the smooth rounded corner by a predetermined angle; and moving the rotated smooth rounded corners to positions corresponding to the remaining right angles of the rectangular area. Specifically, when first generating a smooth rounded corner for a rectangle, such as the lower left corner, the generated smooth rounded corner can be rotated 90° clockwise and moved to the upper left corner of the rectangle, and the rotated smooth rounded corner is made tangent to both edge 1 and edge 4 (or the starting position of the smooth rounded corner of the upper left corner is directly determined according to the rounded corner radius value and the rounded corner smoothness, and then the rotated smooth rounded corner is connected). The generated smooth rounded corners can be rotated 180° and 270° clockwise and then moved to the upper right corner and the lower right corner of the rectangle respectively. Thus, a smooth rounded rectangle with four corners replaced by smooth rounded corners is obtained. It should be understood that the generated smooth rounded corners can also be rotated 90°, 180° and 270° counterclockwise and then shifted to obtain a smooth rounded rectangle.

应该理解的是,虽然在此结合图4所示的对应于矩形左下角的两条边和直角来描述了本公开平滑圆角的例子(在如下的图5中亦是如此),但在其他实施例中,也可以使用矩形的其他任意直角来进行描述,并且矩形本身也可以与例如绘制的画面方向呈一定角度(例如,锐角)。无论直角及其两个边的朝向如何,都可以利用本公开的如上方法来生成平滑圆角。进一步地,虽然为了方便说明将坐标系限定为以构成直角的两条边的交点为原点,这两条边分别为第一和第二坐标轴,但该坐标系可以是相对坐标系,并且可以使用任何位置作为原点,在该原点相交的两条相互垂直的线作为第一和第二坐标轴。在这些坐标轴下,仍然可以利用本公开的原理绘制平滑圆角。It should be understood that although the example of smooth rounded corners of the present disclosure is described here in conjunction with the two sides and the right angle corresponding to the lower left corner of the rectangle shown in Figure 4 (the same is true in Figure 5 below), in other embodiments, any other right angles of the rectangle can also be used for description, and the rectangle itself can also be at a certain angle (for example, an acute angle) to the direction of the drawn screen, for example. Regardless of the orientation of the right angle and its two sides, the above method of the present disclosure can be used to generate smooth rounded corners. Further, although for the convenience of explanation, the coordinate system is limited to the intersection of the two sides forming the right angle as the origin, and these two sides are the first and second coordinate axes, respectively, the coordinate system can be a relative coordinate system, and any position can be used as the origin, and the two mutually perpendicular lines intersecting at the origin are used as the first and second coordinate axes. Under these coordinate axes, the principle of the present disclosure can still be used to draw smooth rounded corners.

如前所述,本公开的平滑圆角可以利用贝塞尔曲线绘制。贝塞尔曲线(Beziercurve)是一种数学曲线,并由一系列控制点定义。对于二维贝塞尔曲线,通常由两个端点和一个或多个柄点定义。As mentioned above, the smooth rounded corners of the present disclosure can be drawn using a Bezier curve. A Bezier curve is a mathematical curve defined by a series of control points. For a two-dimensional Bezier curve, it is usually defined by two endpoints and one or more handle points.

贝塞尔曲线的端点是曲线的起始点和终止点。对于二维贝塞尔曲线,用两个端点来定义曲线的起始和结束位置。这些端点是曲线的两个极限点,确定了曲线的起始方向和终止方向。柄点是位于端点之间的控制点,也称为中间点。在贝塞尔曲线中,柄点用于控制曲线的形状和方向。对于二维贝塞尔曲线,除了端点外还可以有一个或多个柄点。这些柄点通过其位置和数量,影响曲线在端点之间的路径和曲率。在此,可以将端点和柄点共同称为贝塞尔曲线的控制点。The endpoints of a Bezier curve are the starting and ending points of the curve. For a 2D Bezier curve, two endpoints are used to define the starting and ending positions of the curve. These endpoints are the two extreme points of the curve, which determine the starting and ending directions of the curve. Handles are control points located between the endpoints, also known as midpoints. In a Bezier curve, handles are used to control the shape and direction of the curve. For a 2D Bezier curve, in addition to the endpoints, there can be one or more handles. These handles affect the path and curvature of the curve between the endpoints through their position and number. Here, the endpoints and handles can be collectively referred to as the control points of the Bezier curve.

贝塞尔曲线的次数取决于控制点的数量。一般来说,n个控制点定义了一个n-1次的贝塞尔曲线。曲线的次数决定了曲线的灵活性和平滑性,次数越高,曲线越复杂,可以更精细地描述各种形状但计算量也相应增大。The degree of a Bezier curve depends on the number of control points. Generally speaking, n control points define an n-1 degree Bezier curve. The degree of a curve determines its flexibility and smoothness. The higher the degree, the more complex the curve is, and it can describe various shapes more precisely, but the amount of calculation also increases accordingly.

贝塞尔曲线的形状是通过控制点计算得出的。具体计算过程使用贝塞尔曲线的插值公式,这些公式基于控制点的位置和曲线的次数来确定曲线上每个点的位置。贝塞尔曲线具有局部控制性,由此某一柄点的调整只会影响曲线上某一段的形状,而不会对整条曲线产生全局影响。The shape of a Bezier curve is calculated using control points. The calculation process uses the interpolation formula of the Bezier curve, which determines the position of each point on the curve based on the position of the control points and the degree of the curve. The Bezier curve has local control, so the adjustment of a handle point will only affect the shape of a certain section of the curve, and will not have a global impact on the entire curve.

贝塞尔曲线通过控制点和多项式插值的方式来生成平滑的曲线。具体地,贝塞尔曲线由一系列控制点定义。对于二维贝塞尔曲线,通常有在此,可将贝塞尔曲线的一系列控制点定义为:起始点(P 0)、终止点(P n)以及中间的控制点(P 1,P 2, ...,P n-1)。这些控制点的位置决定了曲线的形状。对于一维的贝塞尔曲线,曲线的参数方程可以表示为:Bezier curves generate smooth curves by means of control points and polynomial interpolation. Specifically, a Bezier curve is defined by a series of control points. For a two-dimensional Bezier curve, there are usually a series of control points for the Bezier curve that can be defined as: the starting point ( P 0 ), the end point ( P n ), and the middle control points ( P 1 , P 2 , ..., P n-1 ). The positions of these control points determine the shape of the curve. For a one-dimensional Bezier curve, the parametric equation of the curve can be expressed as:

其中,是控制点,是Bernstein多项式,并且可被定义为:in, is the control point, is a Bernstein polynomial and can be defined as:

其中,是组合数,n+1表示控制点的数量,t为给定参数,表示点 B(t)在贝塞尔曲线上的相对位置。in, is the number of combinations, n+1 represents the number of control points, and t is a given parameter, which represents the relative position of point B( t ) on the Bezier curve.

具体地,在贝塞尔曲线的计算公式中,t通常用来表示曲线上的一个位置或点的位置参数。在贝塞尔曲线的参数化表示中,t的取值范围是 0≤t≤1。当t=0时,贝塞尔曲线计算公式给出的是曲线的起点位置;当t=1 时,公式给出的是曲线的终点位置。因此,通过在t取值范围内逐步增加t的值,可以计算出曲线上各个位置的点B(t),从而绘制出完整的贝塞尔曲线。Specifically, in the calculation formula of the Bezier curve, t is usually used to represent the position parameter of a position or point on the curve. In the parametric representation of the Bezier curve, the value range of t is 0≤ t ≤1. When t = 0, the Bezier curve calculation formula gives the starting position of the curve; when t = 1, the formula gives the end position of the curve. Therefore, by gradually increasing the value of t within the range of t , the point B( t ) at each position on the curve can be calculated, thereby drawing a complete Bezier curve.

在本公开中,可以将第一坐标点和第三坐标点作为端点,并且通过选择一个或多个柄点来生成第一贝塞尔曲线。在一个实施例中,可以设置两个柄点用于绘制第一贝塞尔曲线。为此,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线,包括:以所述第一坐标点和所述第三坐标点为端点,第四坐标点和第五坐标点为柄点,生成第一贝塞尔曲线,其中,所述第四坐标点和所述第五坐标点的坐标是基于所述圆角半径值确定的,以使所述第一贝塞尔曲线的斜率连续变化。In the present disclosure, the first coordinate point and the third coordinate point can be used as endpoints, and a first Bezier curve can be generated by selecting one or more handle points. In one embodiment, two handle points can be set for drawing the first Bezier curve. To this end, the first Bezier curve is generated with the first coordinate point and the third coordinate point as endpoints, including: the first Bezier curve is generated with the first coordinate point and the third coordinate point as endpoints, and the fourth coordinate point and the fifth coordinate point as handle points, wherein the coordinates of the fourth coordinate point and the fifth coordinate point are determined based on the fillet radius value so that the slope of the first Bezier curve changes continuously.

在一个实施例中,柄点具体位置可以根据圆角半径值r对应的普通圆角以及两条直角边来确定。为了确定第四坐标点和第五坐标点的位置,可以额外确定用于定位第四坐标点的第一角度和用于定位第五坐标点的第二角度。为此,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线之前,本公开的平滑圆角生成方法还包括:根据第一角度和所述圆角半径值确定所述第四坐标点的坐标;以及根据第二角度和所述圆角半径值确定所述第五坐标点的坐标。In one embodiment, the specific position of the handle point can be determined based on the common fillet corresponding to the fillet radius value r and the two right-angled sides. In order to determine the positions of the fourth coordinate point and the fifth coordinate point, a first angle for locating the fourth coordinate point and a second angle for locating the fifth coordinate point can be additionally determined. To this end, before generating the first Bezier curve with the first coordinate point and the third coordinate point as endpoints, the smooth fillet generation method disclosed in the present invention also includes: determining the coordinates of the fourth coordinate point based on the first angle and the fillet radius value; and determining the coordinates of the fifth coordinate point based on the second angle and the fillet radius value.

图5示出了根据由第一角度和第二角度结合圆角半径值确定的柄点绘制平滑圆角的例子。在图示的例子中,第一角度和第二角度可以是基于具有获取的圆角半径值r的普通圆角定位的角度。在此,为了方便说明,可以将平滑圆角所处的两边(即,对应于要生成平滑圆角的那个直角的两条垂直边)称为第一边和第二边。例如,可以将第一坐标点位于的边称为第一边,将第二坐标点位于的边称为第二边。在图5的例子中,第一边和第二边分别对应于边1和边2。所述定位点对应于具有所述圆角半径值的普通圆角的圆心位置。即,在将交点O视为原点,第一边和第二边分别视为第一坐标轴和第二坐标轴的情况下,定位点的坐标为(r, r)。在图5的例子中,d=平滑余量m+圆角半径值r,并由此得到第一坐标点(坐标点1)和第二坐标点(坐标点2)的位置。进一步地,与图4所示的例子类似,在图5中,同样可以根据定位点和原点之间的连线(第一辅助线g 1)和圆角半径值r来确定平滑圆角中间点,即,第三坐标点(坐标点3)的位置。FIG5 shows an example of drawing a smooth fillet according to a handle point determined by a first angle and a second angle in combination with a fillet radius value. In the illustrated example, the first angle and the second angle may be angles based on a common fillet positioning with an acquired fillet radius value r. Here, for the convenience of explanation, the two sides where the smooth fillet is located (i.e., the two vertical sides corresponding to the right angle to generate the smooth fillet) may be referred to as the first side and the second side. For example, the side where the first coordinate point is located may be referred to as the first side, and the side where the second coordinate point is located may be referred to as the second side. In the example of FIG5 , the first side and the second side correspond to side 1 and side 2, respectively. The positioning point corresponds to the center position of a common fillet with the fillet radius value. That is, when the intersection O is regarded as the origin, and the first side and the second side are regarded as the first coordinate axis and the second coordinate axis, respectively, the coordinates of the positioning point are (r, r). In the example of FIG5 , d=smoothing margin m+fillet radius value r, and the positions of the first coordinate point (coordinate point 1) and the second coordinate point (coordinate point 2) are obtained. Further, similar to the example shown in FIG. 4 , in FIG. 5 , the position of the smooth fillet middle point, ie, the third coordinate point (coordinate point 3 ), can also be determined according to the line between the positioning point and the origin (the first auxiliary line g 1 ) and the fillet radius value r.

如图所示,第一角度α可以对应于所述第四坐标点与定位点之间的连线与第二边之间的夹角(图中虽然示出了第四坐标点与定位点之间的连线l 1与第二辅助线g 2之间的夹角为α,但由于第二辅助线g 2与边2平行,因此显然第四坐标点与定位点之间的连线与边2之间的夹角也为α)。由于在实际操作中是在基于第一角度α来确定第四坐标点的位置,因此可以认为第四坐标点位于从定位点伸出且与第二辅助线g 2之间的夹角为α的线l 1上的某一位置处。在图5的例子中,为了保证第一贝塞尔曲线的平滑度,可以将线l 1与边1的交点作为第四坐标点,即,图中示出的坐标点4。根据三角函数知识可知,坐标点4与定位点之间的距离为r/cosα。在其他实施例中,第四坐标点也可以位于线l 1的其他位置处,例如,线l 1上与定位点的距离不小于r且不大于r/cosα的范围内的任意点处。As shown in the figure, the first angle α may correspond to the angle between the line connecting the fourth coordinate point and the positioning point and the second side (although the figure shows that the angle between the line connecting the fourth coordinate point and the positioning point and the second auxiliary line g 2 is α, since the second auxiliary line g 2 is parallel to the side 2, it is obvious that the angle between the line connecting the fourth coordinate point and the positioning point and the side 2 is also α). Since the position of the fourth coordinate point is determined based on the first angle α in actual operation, it can be considered that the fourth coordinate point is located at a certain position on the line l 1 extending from the positioning point and having an angle α with the second auxiliary line g 2. In the example of FIG. 5, in order to ensure the smoothness of the first Bezier curve, the intersection of the line l 1 and the side 1 can be used as the fourth coordinate point, that is, the coordinate point 4 shown in the figure. According to the knowledge of trigonometric functions, the distance between the coordinate point 4 and the positioning point is r/cosα. In other embodiments, the fourth coordinate point may also be located at other positions on the line l 1 , for example, at any point on the line l 1 within the range where the distance from the positioning point is not less than r and not greater than r/cosα.

进一步地,第二角度β对应于第五坐标点和定位点之间的连线(图5所示的线l 2)与第三坐标点和定位点之间的连线(图5所示的第一辅助线g 1)所构成的夹角。同样地,由于在实际操作中是在基于第二角度β来确定第五坐标点的位置,因此可以认为第五坐标点位于从定位点伸出且与第一辅助线g 1之间的夹角为β的线l 2上的某一位置处。在图5的例子中,为了保证第一贝塞尔曲线的平滑度,可以在坐标点3的位置做一条与第一辅助线g 1垂直的线作为第三辅助线g 3,并将线l 2与第三辅助线g 3的交点作为第五坐标点,即,图中示出的坐标点5。根据三角函数知识可知,坐标点5与坐标点3之间的距离为r×tanβ,坐标点5与定位点之间的距离为r/cosβ。在其他实施例中,第五坐标点也可以位于线l 2的其他位置处,例如,线l 1上与定位点的距离不小于r且不大于r/cosβ的范围内的任意点处。Further, the second angle β corresponds to the angle formed by the line connecting the fifth coordinate point and the positioning point (line l 2 shown in FIG. 5 ) and the line connecting the third coordinate point and the positioning point (first auxiliary line g 1 shown in FIG. 5 ). Similarly, since the position of the fifth coordinate point is determined based on the second angle β in actual operation, it can be considered that the fifth coordinate point is located at a certain position on the line l 2 extending from the positioning point and having an angle β with the first auxiliary line g 1. In the example of FIG. 5 , in order to ensure the smoothness of the first Bezier curve, a line perpendicular to the first auxiliary line g 1 can be made at the position of the coordinate point 3 as the third auxiliary line g 3 , and the intersection of the line l 2 and the third auxiliary line g 3 is taken as the fifth coordinate point, that is, the coordinate point 5 shown in the figure. According to the knowledge of trigonometric functions, the distance between the coordinate point 5 and the coordinate point 3 is r×tanβ, and the distance between the coordinate point 5 and the positioning point is r/cosβ. In other embodiments, the fifth coordinate point may also be located at other positions on line l2 , for example, at any point on line l1 within a range where the distance from the positioning point is not less than r and not greater than r/cosβ.

在确定了第四坐标点和第五坐标点的位置后,就可以以第一坐标点和第三坐标点为端点,第四坐标点和第五坐标点为柄点,基于如上公式绘制第一贝塞尔曲线。After the positions of the fourth coordinate point and the fifth coordinate point are determined, the first Bezier curve can be drawn based on the above formula with the first coordinate point and the third coordinate point as endpoints and the fourth coordinate point and the fifth coordinate point as handle points.

由于第一贝塞尔曲线用于替换半个普通圆角,即1/8段圆弧,并且利用两个柄点绘制得出,因此第一角度α和第二角度β的取值应该位于15°附近。在一个实施例中,第一角度α和第二角度β的取值都可以在15°±5°之间。在一个实施例中,第一角度α和第二角度β的取值都可以在15°±3°之间。在一个实施例中,第一角度α和第二角度β的取值都可以在15°±1°之间。例如,在一个实现中,第一角度α可以为15°,第二角度β可以为14°。Since the first Bezier curve is used to replace half of a normal fillet, that is, 1/8 of a circular arc, and is drawn using two handle points, the values of the first angle α and the second angle β should be around 15°. In one embodiment, the values of the first angle α and the second angle β can be between 15°±5°. In one embodiment, the values of the first angle α and the second angle β can be between 15°±3°. In one embodiment, the values of the first angle α and the second angle β can be between 15°±1°. For example, in one implementation, the first angle α can be 15° and the second angle β can be 14°.

如上结合图5以图示的方式给出了如何定位第一贝塞尔曲线的四个控制点的例子,由此方便对本公开原理的理解。在实际的操作中,终端可以使用如下公式来求取第一贝塞尔曲线的四个控制点的坐标(此时,认为O点为原点,两条直角边分别对应于第一和第二坐标轴,并设获取的圆角平滑度的值为 smoothness,圆角半径的值为radius,此时可以认为平滑余量margin= smoothness ×radius):As shown above, in conjunction with FIG. 5, an example of how to locate the four control points of the first Bezier curve is given in a graphical manner, thereby facilitating the understanding of the principles of the present disclosure. In actual operation, the terminal can use the following formula to obtain the coordinates of the four control points of the first Bezier curve (at this time, the point O is considered to be the origin, the two right-angled sides correspond to the first and second coordinate axes, and the obtained fillet smoothness value is smoothness, and the fillet radius value is radius. At this time, it can be considered that the smoothing margin margin = smoothness × radius):

坐标点1:(0, smoothness ×radius + radius)Coordinate point 1: (0, smoothness × radius + radius)

坐标点3:(-radius ×cos45°+ radius, -radius ×sin45°+ radius)Coordinate point 3: (-radius × cos45° + radius, -radius × sin45° + radius)

坐标点4:(0, -tanα×radius + radius)Coordinate point 4: (0, -tanα×radius + radius)

设中间变量:largeSide = cos45°×radius,且Let the intermediate variable be: largeSide = cos45°×radius, and

smallSide = cos45°×tanβ×radiussmallSide = cos45°×tanβ×radius

则:坐标点5:(-(smallSide + largeSide) + radius, -(largeSide -smallSide) + radius)Then: Coordinate point 5: (-(smallSide + largeSide) + radius, -(largeSide -smallSide) + radius)

为了方便理解,图5中给出了彼此垂直的两条点划线,其中的长线代表largeSide的长度,短线代表smallSide的长度。由于这两条点划线都与第三辅助线g 3呈45°夹角,因此显然坐标点5的第一坐标值为radius-smallSide – largeSide,第二坐标值为radius-smallSide + largeSide,即得到如上公式。For ease of understanding, two dotted lines perpendicular to each other are shown in Figure 5, where the long line represents the length of largeSide and the short line represents the length of smallSide. Since both dotted lines are at an angle of 45° to the third auxiliary line g 3 , it is obvious that the first coordinate value of coordinate point 5 is radius-smallSide – largeSide, and the second coordinate value is radius-smallSide + largeSide, which is the above formula.

类似地,由于第二贝塞尔曲线与第一贝塞尔曲线关于第一辅助线g 1对称,因此如图5所示的第二贝塞尔曲线的四个控制点的坐标为:Similarly, since the second Bezier curve is symmetric to the first Bezier curve about the first auxiliary line g1 , the coordinates of the four control points of the second Bezier curve as shown in FIG5 are:

坐标点2:(smoothness ×radius + radius, 0)Coordinate point 2: (smoothness × radius + radius, 0)

坐标点3:(-radius ×cos45°+ radius, -radius ×sin45°+ radius)Coordinate point 3: (-radius × cos45° + radius, -radius × sin45° + radius)

坐标点6:(-tanα ×radius + radius, 0)Coordinate point 6: (-tanα × radius + radius, 0)

坐标点7:(-(largeSide - smallSide) + radius, -(smallSide + largeSide)+ radius)Coordinate point 7: (-(largeSide - smallSide) + radius, -(smallSide + largeSide)+ radius)

在本公开的实施例中,可以如上所述通过翻转第一贝塞尔曲线得到第二贝塞尔曲线,并由此得到平滑圆角;也可以根据如上公式计算得到第二贝塞尔曲线,并由此得到平滑圆角。In the embodiments of the present disclosure, the second Bezier curve may be obtained by flipping the first Bezier curve as described above, thereby obtaining a smooth rounded corner; the second Bezier curve may also be calculated according to the above formula, thereby obtaining a smooth rounded corner.

由此,本公开的平滑圆角生成方案,相比于普通圆角曲线,能够解决(在圆角和边交界处的)斜率变化突兀的问题,视觉上更加平滑,并且基于贝塞尔曲线实现自适应的放大与缩小。相对于其他圆角方案,具有使用简单、所需算力量小等优点,并且能够高普适性地应用于各类操作系统,尤其是能够在不修改Android原有实现的情况下进行大批量的快速应用。Therefore, compared with ordinary rounded corner curves, the smooth rounded corner generation solution disclosed in the present invention can solve the problem of abrupt slope changes (at the intersection of the rounded corner and the edge), is visually smoother, and can achieve adaptive zooming in and out based on the Bezier curve. Compared with other rounded corner solutions, it has the advantages of being simple to use and requiring less computing power, and can be widely applied to various operating systems, especially to large-scale rapid applications without modifying the original Android implementation.

在一个实施例中,本公开的平滑圆角生成方法可以在终端上使用,例如用于在Android系统上生成平滑圆角。具体地,可以在操作系统的Path(路径)、Canvas(画布)、Drawable(可绘制)、bitmap(位图)、View(视图)和ViewGroup(视图组)等层级实现对应的接口。为此,本公开还可以实现为一种图像绘制方法。图6示出了根据本公开一个实施例的图像绘制方法的示意性流程图。In one embodiment, the smooth rounded corner generation method disclosed in the present invention can be used on a terminal, for example, to generate smooth rounded corners on an Android system. Specifically, the corresponding interfaces can be implemented at the Path, Canvas, Drawable, bitmap, View, and ViewGroup levels of the operating system. To this end, the present disclosure can also be implemented as an image drawing method. FIG6 shows a schematic flow chart of an image drawing method according to an embodiment of the present disclosure.

在步骤S610,以采用如上所述的平滑圆角生成方法来生成路径,所述路径包括所述平滑圆角。In step S610, a path is generated by using the smooth rounded corner generation method as described above, and the path includes the smooth rounded corner.

随后,在步骤S620,根据绘制界面的对象类型和所述路径生成图像。Then, in step S620, an image is generated according to the object type of the drawing interface and the path.

在具体操作中,以根据不同的对象类型来生成图像。In a specific operation, images are generated according to different object types.

响应于对象类型为路径,可以直接将所述路径作为所述图像。In response to the object type being a path, the path may be directly used as the image.

响应于对象类型为画布(通常,所述路径为闭合路径),选择如下之一的调用:将画布剪裁至所述路径的范围内,并在所述路径的范围内绘制画布内容;或者绘制画布内容,并在绘制结束后将所述路径的范围之外的内容擦除。In response to the object type being a canvas (usually, the path is a closed path), one of the following calls is selected: clipping the canvas to the range of the path and drawing the canvas content within the range of the path; or drawing the canvas content and erasing the content outside the range of the path after drawing is completed.

响应于对象类型为可绘制,使用画布对应的调用修改所述可绘制的绘制结果。In response to the object type being a drawable, a call corresponding to the canvas is used to modify a drawing result of the drawable.

响应于对象类型为位图,将位图设置为画布的绘制底图,绘制画布内容,并在绘制结束后将所述路径的范围之外的内容擦除。In response to the object type being a bitmap, the bitmap is set as a drawing base map of the canvas, the canvas content is drawn, and after the drawing is completed, the content outside the range of the path is erased.

响应于对象类型为视图,设置视图的边界轮廓为对应于所述路径的平滑圆角曲线并根据所述边界轮廓剪裁该视图。In response to the object type being a view, a boundary contour of the view is set to a smooth rounded curve corresponding to the path and the view is clipped according to the boundary contour.

响应于对象类型为视图组,使用设置的平滑圆角视图对象自动剪裁视图组内的视图以生成所述路径作为设定的平滑圆角边界。In response to the object type being a view group, the set smooth rounded corner view object is used to automatically clip the views in the view group to generate the path as the set smooth rounded corner boundary.

在Android系统的应用中,可以首先根据调用者传入的参数和所绘制区域的大小,生成平滑圆角的曲线(例如,基于如上结合图3所述的方法)。随后,调用者可以根据需要应用平滑圆角的对象类型、选择调用方式,并根据调用者的调用方式,生成对应方式下的平滑圆角。In an application of the Android system, a smooth rounded corner curve may be first generated according to the parameters passed in by the caller and the size of the drawn area (for example, based on the method described above in conjunction with FIG. 3 ). Subsequently, the caller may select the object type to which the smooth rounded corner is to be applied and the calling method as required, and a smooth rounded corner in a corresponding method may be generated according to the calling method of the caller.

具体地,生成平滑圆角的曲线,本质上需要绘制区域的左、上、右、下四个角的坐标,并且获知圆角平滑度smoothness、和四个角的圆角半径值radius。为此,可以根据如上信息,根据radius和smoothness得到7个核心控制点的原始坐标(例如,可以基于如上坐标点1~7的坐标计算公式并且可以参见图5的图示)。Specifically, to generate a smooth rounded curve, it is essentially necessary to draw the coordinates of the left, top, right, and bottom corners of the area, and to obtain the rounded smoothness and the rounded radius values of the four corners. To this end, the original coordinates of the seven core control points can be obtained according to the above information, radius, and smoothness (for example, the coordinate calculation formula of the above coordinate points 1 to 7 can be used and can be referred to in the diagram of FIG5 ).

根据上述参数(例如,求取的7个控制点的原始坐标),可以开始绘制平滑圆角曲线。According to the above parameters (for example, the original coordinates of the 7 control points), you can start drawing a smooth rounded curve.

在一个例子中,可以首先将7个坐标点整体平移至绘制区域的左上角。作第一贝塞尔曲线,起点为坐标点1,控制点分别为坐标点4、坐标点5,终点为坐标点7;作第二贝塞尔曲线,起点为坐标点3,控制点分别为坐标点6、坐标点7,终点为坐标点2,由此得到用于左上角的平滑圆角。In one example, the 7 coordinate points can be first translated as a whole to the upper left corner of the drawing area. The first Bezier curve is drawn, with the starting point being coordinate point 1, the control points being coordinate points 4 and 5, and the end point being coordinate point 7. The second Bezier curve is drawn, with the starting point being coordinate point 3, the control points being coordinate points 6 and 7, and the end point being coordinate point 2, thereby obtaining a smooth rounded corner for the upper left corner.

随后,可坐标点绕绘制区域中心进行左右翻转计算,得到新的7个点,将新的7个点反转前后顺序后,替换掉原坐标点1~7,此时曲线连接至坐标点1并重复如上生成第一和第二贝塞尔曲线的步骤,得到用于右上角的平滑圆角。Subsequently, the coordinate points can be flipped left and right around the center of the drawing area to obtain 7 new points. After reversing the order of the new 7 points, the original coordinate points 1 to 7 are replaced. At this time, the curve is connected to coordinate point 1 and the steps of generating the first and second Bezier curves are repeated to obtain a smooth rounded corner for the upper right corner.

随后,可将7个坐标点反转顺序,再绕绘制区域中心进行上下翻转计算,用得到的新坐标点替换原坐标点1~7,由此通过重复步骤得到右下角和左下角的平滑圆角。此时,可以闭合曲线,得到平滑圆角曲线。即,得到将四个直角替换成四个平滑圆角的平滑圆角矩形(即,平滑圆角曲线)。图7示出了根据本公开的平滑圆角生成方法得到的平滑圆角矩形。在图7的例子中,平滑余量m为0.5r(若使用圆角平滑度作为参数,则圆角平滑度s为50%)。相比于图2所示的圆角矩形,图7所示的平滑圆角矩形更为平滑。Subsequently, the order of the 7 coordinate points can be reversed, and then the calculation is performed upside down around the center of the drawing area, and the original coordinate points 1 to 7 are replaced with the obtained new coordinate points, thereby obtaining the smooth rounded corners of the lower right corner and the lower left corner by repeating the steps. At this time, the curve can be closed to obtain a smooth rounded corner curve. That is, a smooth rounded rectangle (i.e., a smooth rounded corner curve) is obtained by replacing four right angles with four smooth rounded corners. FIG. 7 shows a smooth rounded rectangle obtained by the smooth rounded corner generation method disclosed in the present invention. In the example of FIG. 7 , the smoothing margin m is 0.5r (if the rounded corner smoothness is used as a parameter, the rounded corner smoothness s is 50%). Compared with the rounded rectangle shown in FIG. 2 , the smooth rounded rectangle shown in FIG. 7 is smoother.

在本公开中,可以应用平滑圆角的对象类型包括:Path、Canvas、Drawable、bitmap、View、ViewGroup。对于不同类型的界面对象,分别可以有一种或多种不同的调用方式可供选择。In the present disclosure, the object types to which smooth rounded corners can be applied include: Path, Canvas, Drawable, bitmap, View, and ViewGroup. For different types of interface objects, one or more different calling methods can be selected.

在Android系统中,绘图的path是一个用于描述图形轮廓的对象,可以包含直线、曲线、圆弧等元素,用于在画布上绘制复杂的图形或形状。Android 提供了android.graphics.Path 类来操作和管理路径对象,通过该类可以创建、修改和绘制路径。对于Path,应用本公开的如上平滑圆角曲线生成的方法即能得到一条符合需求的Path。In the Android system, a drawing path is an object used to describe the outline of a graphic, which can contain elements such as straight lines, curves, and arcs, and is used to draw complex graphics or shapes on a canvas. Android provides the android.graphics.Path class to operate and manage path objects, through which paths can be created, modified, and drawn. For a Path, applying the above method for generating a smooth rounded curve disclosed in the present invention can obtain a Path that meets the requirements.

在Android开发中,Canvas是Android图形框架中的一个类(android.graphics.Canvas),为Bitmap或视图View提供了绘图表面,用于渲染图形。Canvas类允许使用诸如drawRect()、drawCircle()、drawText()、drawPath()等方法进行各种绘图操作,使得开发人员能够将形状、文本和其他图形元素渲染到画布上。对于Canvas,可以根据“边界内绘制法”或“边界外擦除法”来绘制平滑圆角内容。如果根据“边界内绘制法”,可以先将Canvas裁剪至上述提供的Path范围内,绘制结束后再取消裁剪,即可绘制出符合平滑圆角定义的内容。根据“边界外擦除法”,可以先进行绘制,绘制完毕后再在Path所述范围之外使用透明颜色覆盖,即可擦除不符合平滑圆角范围的绘制内容。In Android development, Canvas is a class in the Android graphics framework (android.graphics.Canvas), which provides a drawing surface for Bitmap or view View for rendering graphics. The Canvas class allows various drawing operations such as drawRect(), drawCircle(), drawText(), drawPath(), etc., allowing developers to render shapes, text, and other graphic elements onto the canvas. For Canvas, you can draw smooth rounded corners according to the "drawing within the boundary method" or the "erasing outside the boundary method". If you use the "drawing within the boundary method", you can first clip the Canvas to the range of the Path provided above, and then cancel the clipping after the drawing is completed, so that you can draw content that meets the definition of smooth rounded corners. According to the "erasing outside the boundary method", you can draw first, and then use a transparent color to cover the range outside the range described by the Path after the drawing is completed, so that you can erase the drawn content that does not meet the smooth rounded corner range.

Drawable 是Android系统中用于管理和显示可绘制图形资源的重要类,支持多种类型的图形表示,可以通过资源文件或代码动态加载和使用。开发中可以利用 Drawable实现丰富的界面效果和交互,为应用增添视觉吸引力和功能性。对于Drawable,在一个实施例中,可以提供了一个SmoothCornerDrawable对象,可以传入任意Drawable类型的对象。对于使用者来说,该对象绘制时将自动实现平滑圆角效果。对于系统内部的行为来说,其实是在绘制阶段使用上述Canvas的两种方法之一对Drawable的绘制结果进行了修改。Drawable is an important class in the Android system for managing and displaying drawable graphic resources. It supports multiple types of graphic representations and can be dynamically loaded and used through resource files or codes. Drawable can be used in development to achieve rich interface effects and interactions, adding visual appeal and functionality to the application. For Drawable, in one embodiment, a SmoothCornerDrawable object can be provided, and any object of Drawable type can be passed in. For the user, the object will automatically achieve a smooth rounded corner effect when drawing. For the behavior within the system, the drawing result of the Drawable is actually modified during the drawing phase using one of the two methods of the Canvas mentioned above.

位图在安卓开发中是常用的图像处理和显示工具,通过Bitmap类及相关工具类,开发人员可以灵活地加载、创建、修改和显示位图。对于位图,在获得位图后,可以将位图设置为Canvas的绘制底图,即可使用“边界外擦除法”将位图进行平滑圆角覆盖。Bitmap is a commonly used image processing and display tool in Android development. Through the Bitmap class and related tool classes, developers can flexibly load, create, modify and display bitmaps. For bitmaps, after obtaining the bitmap, you can set the bitmap as the drawing base map of Canvas, and use the "out-of-bounds erase method" to cover the bitmap with smooth rounded corners.

View 和 ViewGroup 是安卓应用中构建用户界面的核心类,开发人员可以通过这些类来创建、管理和定制各种界面元素。View 表示单个可视元素,而 ViewGroup 是用于组织和管理多个 View 的容器。通过合理地使用 View 和 ViewGroup,可以构建出灵活、交互丰富的用户界面。对于View,本公开可以提供了一个扩展函数,通过设置View的边界轮廓为平滑圆角曲线,并设置View裁剪到边界,从而实现平滑圆角。而对于ViewGroup,本实施例提供了一个SmoothCornerView对象,该对象将自动裁剪内部的子View到设定的平滑圆角边界。View and ViewGroup are the core classes for building user interfaces in Android applications. Developers can use these classes to create, manage, and customize various interface elements. View represents a single visual element, while ViewGroup is a container for organizing and managing multiple Views. By using View and ViewGroup properly, a flexible and interactive user interface can be built. For View, the present disclosure may provide an extension function that sets the boundary contour of View to a smooth rounded curve and sets View to be clipped to the boundary, thereby achieving smooth rounded corners. For ViewGroup, this embodiment provides a SmoothCornerView object that automatically clips the internal sub-View to the set smooth rounded boundary.

图8示出了本公开的图像绘制方法的一个例子。如图所述,无论哪种界面对象,首先都可以获取平滑圆角的关键参数。这些参数可由用户输入,也可以根据规则生成。随后,在基于本公开的如上方法根据参数生成具有平滑圆角的轨迹(例如,平滑圆角曲线构成的闭合Path)。其后,可以根据边界内绘制法,将所有内容在轨迹范围内绘制;或是根据边界外擦除法,擦除轨迹范围外的内容。由此,得到带有平滑圆角的目标对象。FIG8 shows an example of an image drawing method disclosed in the present invention. As shown in the figure, no matter what kind of interface object, the key parameters of smooth rounded corners can be obtained first. These parameters can be input by the user or generated according to rules. Subsequently, a trajectory with smooth rounded corners (for example, a closed path composed of smooth rounded corner curves) is generated according to the parameters based on the above method disclosed in the present invention. Thereafter, all contents can be drawn within the trajectory range according to the in-boundary drawing method; or the contents outside the trajectory range can be erased according to the out-boundary erasing method. Thus, a target object with smooth rounded corners is obtained.

本公开的平滑圆角生成和相应的图像绘制方法能够在不修改Android原有实现的情况下,实现一种比普通圆角的边缘过渡更加圆润、高精度、低性能损耗、可无损自适应放大的平滑圆角,并应用在几乎所有的应用开发场景中。The smooth rounded corner generation and corresponding image drawing method disclosed in the present invention can achieve a smooth rounded corner with smoother edge transition than ordinary rounded corners, high precision, low performance loss, and lossless adaptive enlargement without modifying the original Android implementation, and can be applied in almost all application development scenarios.

本公开还可以实现为一种计算设备。图9示出了根据本公开至少一个实施例的可用于实现上述方法的计算设备的结构示意图。如图所示,计算设备900包括存储器910和处理器920。The present disclosure may also be implemented as a computing device. FIG9 shows a schematic diagram of a computing device that can be used to implement the above method according to at least one embodiment of the present disclosure. As shown in the figure, the computing device 900 includes a memory 910 and a processor 920.

处理器920可以是一个多核的处理器,也可以包含多个处理器。在一些实施例中,处理器920可以包含一个通用的主处理器以及一个或多个特殊的协处理器,例如图形处理器(GPU)、数字信号处理器(DSP)等等。在一些实施例中,处理器920可以使用定制的电路实现,例如特定用途集成电路(ASIC,Application Specific Integrated Circuit)或者现场可编程逻辑门阵列(FPGA,Field Programmable Gate Arrays)。The processor 920 may be a multi-core processor or may include multiple processors. In some embodiments, the processor 920 may include a general-purpose main processor and one or more special coprocessors, such as a graphics processing unit (GPU), a digital signal processor (DSP), etc. In some embodiments, the processor 920 may be implemented using a customized circuit, such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA).

存储器910可以包括各种类型的存储单元,例如系统内存、只读存储器(ROM),和永久存储装置。其中,ROM可以存储处理器920或者计算机的其他模块需要的静态数据或者指令。永久存储装置可以是可读写的存储装置。永久存储装置可以是即使计算机断电后也不会失去存储的指令和数据的非易失性存储设备。在一些实施方式中,永久性存储装置采用大容量存储装置(例如磁或光盘、闪存)作为永久存储装置。另外一些实施方式中,永久性存储装置可以是可移除的存储设备(例如软盘、光驱)。系统内存可以是可读写存储设备或者易失性可读写存储设备,例如动态随机访问内存。系统内存可以存储一些或者所有处理器在运行时需要的指令和数据。此外,存储器610可以包括任意计算机可读存储媒介的组合,包括各种类型的半导体存储芯片(DRAM,SRAM,SDRAM,闪存,可编程只读存储器),磁盘和/或光盘也可以采用。在一些实施方式中,存储器910可以包括可读和/或写的可移除的存储设备,例如激光唱片(CD)、只读数字多功能光盘(例如DVD-ROM,双层DVD-ROM)、只读蓝光光盘、超密度光盘、闪存卡(例如SD卡、min SD卡、Micro-SD卡等等)、磁性软盘等等。计算机可读存储媒介不包含载波和通过无线或有线传输的瞬间电子信号。The memory 910 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 920 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at runtime. In addition, the memory 610 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and/or optical disks may also be used. In some embodiments, the memory 910 may include a readable and/or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.

存储器910上存储有可执行代码,当可执行代码被处理器920处理时,可以使处理器920执行上文述及的平滑圆角生成方法和图像绘制方法。The memory 910 stores executable codes. When the executable codes are processed by the processor 920 , the processor 920 can execute the smooth rounded corner generating method and the image drawing method mentioned above.

此外,根据本公开的方法还可以实现为一种计算机程序或计算机程序产品,该计算机程序或计算机程序产品包括用于执行本公开的上述方法中限定的上述各步骤的计算机程序代码指令。In addition, the method according to the present disclosure may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing the above steps defined in the above method of the present disclosure.

或者,本公开还可以实施为一种非暂时性机器可读存储介质(或计算机可读存储介质、或机器可读存储介质),其上存储有可执行代码(或计算机程序、或计算机指令代码),当所述可执行代码(或计算机程序、或计算机指令代码)被电子设备(或计算设备、服务器等)的处理器执行时,使所述处理器执行根据本公开的上述方法的各个步骤。Alternatively, the present disclosure may also be implemented as a non-transitory machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) on which executable code (or computer program, or computer instruction code) is stored. When the executable code (or computer program, or computer instruction code) is executed by a processor of an electronic device (or computing device, server, etc.), the processor executes the various steps of the above-mentioned method according to the present disclosure.

本领域技术人员还将明白的是,结合这里的公开所描述的各种示例性逻辑块、模块、电路和算法步骤可以被实现为电子硬件、计算机软件或两者的组合。Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or a combination of both.

附图中的流程图和框图显示了根据本公开的多个实施例的系统和方法的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标记的功能也可以以不同于附图中所标记的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the system and method according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and/or flow chart, and the combination of the boxes in the block diagram and/or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (9)

1.一种用于Android系统的图像绘制方法,包括:1. An image drawing method for an Android system, comprising: 生成包括平滑圆角的路径;以及generating paths including smooth rounded corners; and 根据绘制界面的对象类型和所述路径生成图像,Generate an image according to the object type of the drawing interface and the path, 其中,所述平滑圆角生成于相互垂直的第一边和第二边之间,并且生成所述平滑圆角的方法包括:The smooth rounded corner is generated between a first side and a second side that are perpendicular to each other, and a method for generating the smooth rounded corner includes: 获取平滑余量和圆角半径值;Get the smoothing allowance and fillet radius values; 根据所述平滑余量和所述圆角半径值之和确定位于所述第一边上的第一坐标点和位于所述第二边上的第二坐标点,所述第一坐标点和所述第二坐标点为平滑圆角的端点;Determine a first coordinate point located on the first side and a second coordinate point located on the second side according to the sum of the smoothing margin and the fillet radius value, wherein the first coordinate point and the second coordinate point are endpoints of the smooth fillet; 根据所述圆角半径值确定第三坐标点,所述第三坐标点为所述平滑圆角的中间点;Determine a third coordinate point according to the fillet radius value, wherein the third coordinate point is the middle point of the smooth fillet; 以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线,并以所述第三坐标点和所述第二坐标点为端点生成第二贝塞尔曲线;以及generating a first Bezier curve with the first coordinate point and the third coordinate point as endpoints, and generating a second Bezier curve with the third coordinate point and the second coordinate point as endpoints; and 基于所述第一贝塞尔曲线和所述第二贝塞尔曲线得到所述平滑圆角,The smooth rounded corner is obtained based on the first Bezier curve and the second Bezier curve, 其中,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线,包括:The step of generating a first Bezier curve with the first coordinate point and the third coordinate point as endpoints includes: 以所述第一坐标点和所述第三坐标点为端点,第四坐标点和第五坐标点为柄点,生成第一贝塞尔曲线,其中,所述第四坐标点和所述第五坐标点的坐标是基于所述圆角半径值确定的,以使所述第一贝塞尔曲线的斜率连续变化,A first Bezier curve is generated with the first coordinate point and the third coordinate point as endpoints and the fourth coordinate point and the fifth coordinate point as handle points, wherein the coordinates of the fourth coordinate point and the fifth coordinate point are determined based on the fillet radius value so that the slope of the first Bezier curve changes continuously, 其中,以所述第一坐标点和所述第三坐标点为端点生成第一贝塞尔曲线之前,还包括:Before generating a first Bezier curve with the first coordinate point and the third coordinate point as endpoints, the method further includes: 根据第一角度和所述圆角半径值确定所述第四坐标点的坐标;以及Determine the coordinates of the fourth coordinate point according to the first angle and the fillet radius value; and 根据第二角度和所述圆角半径值确定所述第五坐标点的坐标,Determine the coordinates of the fifth coordinate point according to the second angle and the fillet radius value, 其中,所述第一角度对应于所述第四坐标点与定位点之间的连线与第二边之间的夹角,所述定位点对应于具有所述圆角半径值的普通圆角的圆心,所述第二边为所述平滑圆角所处两边中第二坐标点所处的一边;The first angle corresponds to the angle between the line between the fourth coordinate point and the positioning point and the second side, the positioning point corresponds to the center of a common fillet with the fillet radius value, and the second side is one of the two sides where the smooth fillet is located, where the second coordinate point is located; 所述第二角度对应于所述第五坐标点和所述定位点之间的连线与所述第三坐标点和所述定位点之间的连线所构成的夹角。The second angle corresponds to an angle formed by a line connecting the fifth coordinate point and the positioning point and a line connecting the third coordinate point and the positioning point. 2.根据权利要求1所述的方法,其中,以所述第三坐标点和所述第二坐标点为端点生成第二贝塞尔曲线,包括:2. The method according to claim 1, wherein generating a second Bezier curve with the third coordinate point and the second coordinate point as endpoints comprises: 翻转生成的所述第一贝塞尔曲线,以获取所述第二贝塞尔曲线。The generated first Bezier curve is flipped to obtain the second Bezier curve. 3.根据权利要求1或2所述的方法,其中,坐标点的坐标以所述第一边和所述第二边之间的交点为原点,并且所述第三坐标点与半径为所述圆角半径值的普通圆角的中间点重合。3. The method according to claim 1 or 2, wherein the coordinates of the coordinate point are based on the intersection of the first side and the second side as the origin, and the third coordinate point coincides with the middle point of a common fillet with a radius equal to the fillet radius value. 4.如权利要求1所述的方法,其中,所述平滑余量为圆角平滑度和所述圆角半径值的乘积。The method of claim 1 , wherein the smoothing margin is a product of a fillet smoothness and a fillet radius value. 5.如权利要求1所述的方法,其中,所述平滑圆角绘制于矩形区域的一个直角位置,并且所述方法还包括:5. The method according to claim 1, wherein the smooth rounded corner is drawn at a right angle position of the rectangular area, and the method further comprises: 将所述平滑圆角旋转预定角度;以及Rotating the smooth rounded corner by a predetermined angle; and 将旋转的所述平滑圆角分别移至对应于所述矩形区域其余直角的位置。The rotated smooth rounded corners are respectively moved to positions corresponding to the remaining right angles of the rectangular area. 6.如权利要求1所述的方法,其中:6. The method of claim 1, wherein: 响应于对象类型为路径,将所述路径作为所述图像;In response to the object type being a path, taking the path as the image; 响应于对象类型为画布,选择如下之一的调用:将画布剪裁至所述路径的范围内,并在所述路径的范围内绘制画布内容,或者绘制画布内容,并在绘制结束后将所述路径的范围之外的内容擦除;In response to the object type being a canvas, selecting one of the following calls: clipping the canvas to the range of the path and drawing the canvas content within the range of the path, or drawing the canvas content and erasing the content outside the range of the path after drawing; 响应于对象类型为可绘制,使用画布对应的调用修改所述可绘制的绘制结果;In response to the object type being a drawable, modifying a drawing result of the drawable using a call corresponding to the canvas; 响应于对象类型为位图,将位图设置为画布的绘制底图,绘制画布内容,并在绘制结束后将所述路径的范围之外的内容擦除;In response to the object type being a bitmap, the bitmap is set as a drawing base map of the canvas, the canvas content is drawn, and after the drawing is completed, the content outside the range of the path is erased; 响应于对象类型为视图,设置视图的边界轮廓为对应于所述路径的平滑圆角曲线并根据所述边界轮廓剪裁该视图;以及In response to the object type being a view, setting a boundary contour of the view to a smooth rounded curve corresponding to the path and clipping the view according to the boundary contour; and 响应于对象类型为视图组,使用设置的平滑圆角视图对象自动剪裁视图组内的视图以生成所述路径作为设定的平滑圆角边界。In response to the object type being a view group, the set smooth rounded corner view object is used to automatically clip the views in the view group to generate the path as the set smooth rounded corner boundary. 7.一种计算设备,包括:7. A computing device comprising: 处理器;以及Processor; and 存储器,其上存储有可执行代码,当所述可执行代码被所述处理器执行时,使所述处理器执行基于如权利要求1至6中任一项所述的方法。A memory having executable codes stored therein, which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 6. 8.一种非暂时性机器可读存储介质,其上存储有可执行代码,当所述可执行代码被电子设备的处理器执行时,使所述处理器执行基于如权利要求1至6中任一项所述的方法。8. A non-transitory machine-readable storage medium having executable codes stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the method according to any one of claims 1 to 6. 9.一种计算机程序产品,包括计算机程序指令,其特征在于,该计算机程序指令被处理器执行时实现基于如权利要求1至6中任一项所述的方法。9. A computer program product, comprising computer program instructions, characterized in that when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
CN202410582636.5A 2024-05-11 2024-05-11 Smooth fillet generation method, image drawing method and related devices Active CN118154721B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410582636.5A CN118154721B (en) 2024-05-11 2024-05-11 Smooth fillet generation method, image drawing method and related devices

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410582636.5A CN118154721B (en) 2024-05-11 2024-05-11 Smooth fillet generation method, image drawing method and related devices

Publications (2)

Publication Number Publication Date
CN118154721A CN118154721A (en) 2024-06-07
CN118154721B true CN118154721B (en) 2024-11-05

Family

ID=91289055

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410582636.5A Active CN118154721B (en) 2024-05-11 2024-05-11 Smooth fillet generation method, image drawing method and related devices

Country Status (1)

Country Link
CN (1) CN118154721B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107239216A (en) * 2016-03-28 2017-10-10 北大方正集团有限公司 Drawing modification method and apparatus based on touch-screen
CN111462215A (en) * 2020-04-01 2020-07-28 北京小米移动软件有限公司 Graph processing method, device and storage medium
CN113312051A (en) * 2021-06-28 2021-08-27 深圳市亿图软件有限公司 Graph fillet processing method and device, computer equipment and storage medium
CN115311386A (en) * 2022-08-26 2022-11-08 Oppo广东移动通信有限公司 Fillet drawing method and device, electronic equipment and storage medium
CN116664716A (en) * 2023-05-31 2023-08-29 北京曼恒数字技术有限公司 Method, device, equipment and medium for determining visual connection line

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9396565B2 (en) * 2013-06-07 2016-07-19 Apple Inc. Rendering borders of elements of a graphical user interface
CN115906298A (en) * 2021-08-27 2023-04-04 中信戴卡股份有限公司 Curve fitting method, device and equipment based on drawing tool
CN114462204A (en) * 2021-12-30 2022-05-10 深圳美格尔生物医疗集团有限公司 Curve drawing method and device, terminal equipment and storage medium
CN117216905A (en) * 2023-09-14 2023-12-12 北京理工大学 Circular arc fitting precision adjustable cycle circle design method based on segmented Bezier curve

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107239216A (en) * 2016-03-28 2017-10-10 北大方正集团有限公司 Drawing modification method and apparatus based on touch-screen
CN111462215A (en) * 2020-04-01 2020-07-28 北京小米移动软件有限公司 Graph processing method, device and storage medium
CN113312051A (en) * 2021-06-28 2021-08-27 深圳市亿图软件有限公司 Graph fillet processing method and device, computer equipment and storage medium
CN115311386A (en) * 2022-08-26 2022-11-08 Oppo广东移动通信有限公司 Fillet drawing method and device, electronic equipment and storage medium
CN116664716A (en) * 2023-05-31 2023-08-29 北京曼恒数字技术有限公司 Method, device, equipment and medium for determining visual connection line

Also Published As

Publication number Publication date
CN118154721A (en) 2024-06-07

Similar Documents

Publication Publication Date Title
WO2020019913A1 (en) Face image processing method and device, and storage medium
US9842428B2 (en) Dynamically optimized deferred rendering pipeline
CN111147660B (en) Operation method and electronic device of a control
US20130033506A1 (en) Multi-context graphics processing
US9747007B2 (en) Resizing technique for display content
CN111464430B (en) Dynamic expression display method, dynamic expression creation method and device
WO2022022177A1 (en) Display method and electronic device
CN106575138A (en) Electronic device and method for providing user interface
WO2022100663A1 (en) Method, apparatus and device for selecting anti-aliasing algorithm and readable storage medium
CN114840280A (en) Display method and electronic equipment
TW201508695A (en) Image processing method and device
CN105550973B (en) Graphics processing unit, graphics processing system and anti-aliasing processing method
US20230186013A1 (en) Annotation method and electronic device
EP3374968A1 (en) Shape interpolation using a polar inset morphing grid
CN108369726B (en) Method and portable electronic device for changing graphics processing resolution according to scene
CN106527656A (en) Display method, device and terminal equipment
CN114511438A (en) A method, device and device for controlling load
CN118154721B (en) Smooth fillet generation method, image drawing method and related devices
CN114866641A (en) Icon processing method, terminal equipment and storage medium
CN118210413B (en) Interface display method, electronic device, storage medium and program product
CN114332998A (en) Method, device and equipment for determining key points of face contour and storage medium
CN112905132B (en) Screen projection method and equipment
CN114581477A (en) Map area merging method, device, electronic device and storage medium
CN115469955B (en) Real-time background blurring processing method, device and computer readable storage medium
CN116740254B (en) Image processing method and terminal

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant