CN105045476A - Method and device for acquiring spotlight graph - Google Patents
Method and device for acquiring spotlight graph Download PDFInfo
- Publication number
- CN105045476A CN105045476A CN201510325511.5A CN201510325511A CN105045476A CN 105045476 A CN105045476 A CN 105045476A CN 201510325511 A CN201510325511 A CN 201510325511A CN 105045476 A CN105045476 A CN 105045476A
- Authority
- CN
- China
- Prior art keywords
- spotlight
- circle
- color value
- points
- color
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 20
- 238000009877 rendering Methods 0.000 claims description 8
- 230000000694 effects Effects 0.000 abstract description 11
- 230000003247 decreasing effect Effects 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 10
- 230000007423 decrease Effects 0.000 description 3
Landscapes
- Image Generation (AREA)
Abstract
Description
技术领域technical field
本发明实施例涉及移动终端的技术领域,尤其涉及一种获取聚光灯图形的方法及装置。Embodiments of the present invention relate to the technical field of mobile terminals, and in particular to a method and device for acquiring spotlight graphics.
背景技术Background technique
目前,在图形处理中,很多聚光灯的效果都是一个完全的透明圆形遮挡在显示图层的最上层,用于透视下层的物体,仅是一个透视区域,并无所谓的聚光灯效果。At present, in graphics processing, the effect of many spotlights is a completely transparent circular block on the top layer of the display layer, which is used to see through the objects in the lower layer. It is only a perspective area, and there is no such thing as a spotlight effect.
发明内容Contents of the invention
本发明实施例的目的在于提出一种获取聚光灯图形的方法及装置,旨在解决如何提高聚光灯的显示效果的问题。The purpose of the embodiments of the present invention is to provide a method and device for acquiring spotlight graphics, aiming at solving the problem of how to improve the display effect of the spotlight.
为达此目的,本发明实施例采用以下技术方案:To achieve this purpose, the embodiments of the present invention adopt the following technical solutions:
一种获取聚光灯图形的方法,所述方法包括:A method for obtaining spotlight graphics, the method comprising:
获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;Obtain the circle of the spotlight, and the center point of the circle is the position of the spotlight on the screen;
获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;Obtain a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the center point of the circle and at least two points on the circumference of the circle;
将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;Setting the color value of the center of the circle as a first color value, and setting the color values of other points on the graph except the center point of the circle as a second color value;
根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化。The graph after the color change is acquired according to a preset color change algorithm, the change being a change of a color value from the first color value to the second color value.
优选地,所述获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点,包括:Preferably, the acquisition of a preset number of graphics, the graphics are triangles or polygons, the vertices of the graphics include the center point of the circle and at least two points on the circumference of the circle, including:
将所述圆均匀的划分为N个等份;Divide the circle evenly into N equal parts;
获取划分后的N+1个点的坐标,所述N+1个点的坐标为N个等份的圆与所述聚光灯的圆周相交的N+1个点的坐标;Obtaining the coordinates of the divided N+1 points, where the coordinates of the N+1 points are the coordinates of the N+1 points where N equal circles intersect the circumference of the spotlight;
根据所述N+1个点的坐标获取N个三角形,所述三角形的顶点分别为所述圆的中心和所述N+1个点中相邻两个点。Acquire N triangles according to the coordinates of the N+1 points, and the vertices of the triangles are respectively the center of the circle and two adjacent points among the N+1 points.
优选地,所述根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化,包括:Preferably, the said graph after the color change is acquired according to the preset color change algorithm, the change is the change of the color value from the first color value to the second color value, including:
根据预先设置的渲染算法获取所述N个三角形的颜色从白色到黑色的渐变颜色,所述第一颜色值为白色,所述第二颜色值为黑色。A gradient color of the N triangles from white to black is acquired according to a preset rendering algorithm, the first color value is white, and the second color value is black.
优选地,所述根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化之后,还包括:Preferably, the acquisition of the graph after color change according to a preset color change algorithm, where the change is after a color value changes from the first color value to the second color value, further includes:
接收用户在所述屏幕上的触发点的位置坐标;receiving position coordinates of a trigger point of the user on the screen;
判断所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内;judging whether the position coordinates of the trigger point are within the coordinate range of the spotlight circle;
若所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内,则获取所述触发点在所述屏幕上滑动的指令;If the position coordinates of the trigger point are within the coordinate range of the spotlight circle, then acquire an instruction that the trigger point slides on the screen;
根据所述指令移动所述聚光灯的中心点的位置。The position of the center point of the spotlight is moved according to the instruction.
优选地,所述根据所述指令移动所述聚光灯的中心点的位置,包括:Preferably, the moving the position of the center point of the spotlight according to the instruction includes:
若所述指令为向左移动,则向左移动所述聚光灯的中心点的位置;If the instruction is to move to the left, move the position of the center point of the spotlight to the left;
若所述指令为向右移动,则向右移动所述聚光灯的中心点的位置;If the instruction is to move to the right, then move the position of the center point of the spotlight to the right;
若所述指令为向上移动,则向上移动所述聚光灯的中心点的位置;If the instruction is to move upward, move the position of the center point of the spotlight upward;
若所述指令为向下移动,则向下移动所述聚光灯的中心点的位置。If the instruction is to move downward, move the position of the center point of the spotlight downward.
一种获取聚光灯图形的装置,所述装置包括:A device for obtaining spotlight graphics, the device comprising:
第一获取模块,用于获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;The first obtaining module is used to obtain the circle of the spotlight, and the center point of the circle is the position of the spotlight on the screen;
第二获取模块,用于获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;The second acquisition module is used to acquire a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the center point of the circle and at least two points on the circumference of the circle;
设置模块,用于将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;A setting module, configured to set the color value of the center of the circle as the first color value, and set the color values of points other than the center point of the circle on the graph as the second color value;
第三获取模块,用于根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化。The third acquisition module is configured to acquire the color-changed graphic according to a preset color change algorithm, the change being a change of a color value from the first color value to the second color value.
优选地,所述第二获取模块包括:Preferably, the second acquisition module includes:
划分单元,用于将所述圆均匀的划分为N个等份;A division unit, configured to evenly divide the circle into N equal parts;
第一获取单元,用于获取划分后的N+1个点的坐标,所述N+1个点的坐标为N个等份的圆与所述聚光灯的圆周相交的N+1个点的坐标;The first acquisition unit is configured to acquire the coordinates of the divided N+1 points, where the coordinates of the N+1 points are the coordinates of the N+1 points where N equal circles intersect the circumference of the spotlight ;
第二获取单元,用于根据所述N+1个点的坐标获取N个三角形,所述三角形的顶点分别为所述圆的中心和所述N+1个点中相邻两个点。The second acquisition unit is configured to acquire N triangles according to the coordinates of the N+1 points, and vertices of the triangles are respectively the center of the circle and two adjacent points among the N+1 points.
优选地,所述第三获取模块包括:Preferably, the third acquisition module includes:
第三获取单元,用于根据预先设置的渲染算法获取所述N个三角形的颜色从白色到黑色的渐变颜色,所述第一颜色值为白色,所述第二颜色值为黑色。The third acquisition unit is configured to acquire a gradient color of the N triangles from white to black according to a preset rendering algorithm, the first color value is white, and the second color value is black.
优选地,所述装置还包括:Preferably, the device also includes:
接收模块,用于接收用户在所述屏幕上的触发点的位置坐标;A receiving module, configured to receive the position coordinates of the user's trigger point on the screen;
判断模块,用于判断所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内;A judging module, configured to judge whether the position coordinates of the trigger point are within the coordinate range of the spotlight circle;
获取模块,用于若所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内,则获取所述触发点在所述屏幕上滑动的指令;An acquisition module, configured to acquire an instruction that the trigger point slides on the screen if the position coordinates of the trigger point are within the coordinate range of the spotlight circle;
移动模块根据所述指令移动所述聚光灯的中心点的位置。The moving module moves the position of the center point of the spotlight according to the instruction.
优选地,所述移动模块包括:Preferably, the mobile module includes:
第一移动单元,用于若所述指令为向左移动,则向左移动所述聚光灯的中心点的位置;a first moving unit, configured to move the position of the center point of the spotlight to the left if the instruction is to move to the left;
第二移动单元,用于若所述指令为向右移动,则向右移动所述聚光灯的中心点的位置;a second moving unit, configured to move the position of the center point of the spotlight to the right if the instruction is to move to the right;
第三移动单元,用于若所述指令为向上移动,则向上移动所述聚光灯的中心点的位置;A third moving unit, configured to move upward the position of the center point of the spotlight if the instruction is to move upward;
第四移动单元,用于若所述指令为向下移动,则向下移动所述聚光灯的中心点的位置。The fourth moving unit is configured to move the position of the center point of the spotlight downward if the instruction is to move downward.
本发明实现通过获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化,从而实现聚光灯在灯中心是最亮,亮度再慢慢向四周递减,最后在给定的范围内达到模糊效果,给人的视线造成聚光灯的发散效果。The present invention realizes by obtaining the circle of the spotlight, and the center point of the circle is the position of the spotlight on the screen; obtaining a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the The center point of the circle and at least two points on the circumference of the circle; the color value of the center of the circle is set as the first color value, and the other points on the graph except the center point of the circle are set The color value of the point is set as a second color value; the graph after the color change is obtained according to a preset color change algorithm, the change is a change of a color value from the first color value to the second color value, In this way, the spotlight is the brightest in the center of the lamp, and the brightness gradually decreases to the surroundings, and finally achieves a blur effect within a given range, causing the divergence effect of the spotlight to give people's sight.
附图说明Description of drawings
图1是本发明实施例获取聚光灯图形的方法第一实施例的流程示意图;FIG. 1 is a schematic flow chart of the first embodiment of the method for acquiring spotlight graphics according to the embodiment of the present invention;
图2是本发明实施例获取聚光灯的方法第二实施例的流程示意图;Fig. 2 is a schematic flow chart of the second embodiment of the method for acquiring a spotlight according to the embodiment of the present invention;
图3是本发明实施例获取聚光灯图形的装置的功能模块示意图;FIG. 3 is a schematic diagram of functional modules of a device for acquiring spotlight graphics according to an embodiment of the present invention;
图4是本发明实施例第二获取模块302的功能模块示意图;FIG. 4 is a schematic diagram of functional modules of a second acquisition module 302 according to an embodiment of the present invention;
图5是本发明实施例第三获取模块304的功能模块示意图;FIG. 5 is a schematic diagram of functional modules of a third acquisition module 304 according to an embodiment of the present invention;
图6是本发明实施例获取聚光灯图形的装置的功能模块示意图;FIG. 6 is a schematic diagram of functional modules of a device for acquiring spotlight graphics according to an embodiment of the present invention;
图7是本发明实施例移动模块308的功能模块示意图。Fig. 7 is a schematic diagram of functional modules of the mobile module 308 according to the embodiment of the present invention.
具体实施方式Detailed ways
下面结合附图和实施例对本发明实施例作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本发明实施例,而非对本发明实施例的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明实施例相关的部分而非全部结构。The embodiments of the present invention will be further described in detail below in conjunction with the drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the embodiments of the present invention, rather than to limit the embodiments of the present invention. In addition, it should be noted that, for the convenience of description, the drawings only show some but not all structures related to the embodiments of the present invention.
实施例一Embodiment one
参考图1,图1是本发明实施例获取聚光灯图形的方法第一实施例的流程示意图。Referring to FIG. 1 , FIG. 1 is a schematic flowchart of a first embodiment of a method for acquiring spotlight graphics according to an embodiment of the present invention.
在实施例一中,所述获取聚光灯图形的方法包括:In Embodiment 1, the method for acquiring spotlight graphics includes:
步骤101,获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;Step 101, obtaining the circle of the spotlight, and the center point of the circle is the position of the spotlight on the screen;
具体的,在屏幕上新建一个图层,将该图层的颜色设置为黑色。给定聚光灯在屏幕上的位置坐标P(x,y),和聚光灯的半径R,并将该图层中P点的颜色设置为黑色透明。Specifically, create a new layer on the screen, and set the color of the layer to black. The position coordinates P(x, y) of the spotlight on the screen and the radius R of the spotlight are given, and the color of point P in this layer is set to black and transparent.
步骤102,获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;Step 102, obtaining a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the center point of the circle and at least two points on the circumference of the circle;
优选地,所述获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点,包括:Preferably, the acquisition of a preset number of graphics, the graphics are triangles or polygons, the vertices of the graphics include the center point of the circle and at least two points on the circumference of the circle, including:
将所述圆均匀的划分为N个等份;Divide the circle evenly into N equal parts;
获取划分后的N+1个点的坐标,所述N+1个点的坐标为N个等份的圆与所述聚光灯的圆周相交的N+1个点的坐标;Obtaining the coordinates of the divided N+1 points, where the coordinates of the N+1 points are the coordinates of the N+1 points where N equal circles intersect the circumference of the spotlight;
根据所述N+1个点的坐标获取N个三角形,所述三角形的顶点分别为所述圆的中心和所述N+1个点中相邻两个点。Acquire N triangles according to the coordinates of the N+1 points, and the vertices of the triangles are respectively the center of the circle and two adjacent points among the N+1 points.
具体的,将聚光灯的圆分成N份,则每一份的角度为a=2*π/N,通过半径和聚光灯的坐标计算出这个划分N去区域的N个定点的坐标如下:Specifically, the circle of the spotlight is divided into N parts, and the angle of each part is a=2*π/N. The coordinates of the N fixed points that divide the N area are calculated through the radius and the coordinates of the spotlight as follows:
第i个点的坐标为:x=R*cos(i*a);y=R*sin(i*a);i从0到N,并设置第个点的颜色值为黑色不透明。The coordinates of the i-th point are: x=R*cos(i*a); y=R*sin(i*a); i is from 0 to N, and the color value of the i-th point is set to black and opaque.
步骤103,将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;Step 103, setting the color value of the center of the circle as the first color value, and setting the color values of other points on the graphic except the center point of the circle as the second color value;
步骤104,根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化。Step 104: Obtain the graphic after color change according to a preset color change algorithm, where the change is a change of a color value from the first color value to the second color value.
优选地,所述根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化,包括:Preferably, the said graph after the color change is acquired according to the preset color change algorithm, the change is the change of the color value from the first color value to the second color value, including:
根据预先设置的渲染算法获取所述N个三角形的颜色从白色到黑色的渐变颜色,所述第一颜色值为白色,所述第二颜色值为黑色。A gradient color of the N triangles from white to black is acquired according to a preset rendering algorithm, the first color value is white, and the second color value is black.
具体的,按顺序从N个定点中取出相邻的两个定点如(0,1)(1,2),…(N-1,N+1),分别与聚光灯的坐标点p组成一个三角形,并用OpenGL的三角形渲染方式将这些三角行进行渲染,每个顶点的颜色值上面已知,OpenGL会根据颜色值变化趋势去渲染三角形,例如a点红色,b点白色,a到b就会由红变白趋势。Specifically, take out two adjacent fixed points such as (0,1)(1,2),...(N-1, N+1) from N fixed points in order, and form a triangle with the coordinate point p of the spotlight respectively , and use OpenGL's triangle rendering method to render these triangle rows. The color value of each vertex is known above. OpenGL will render the triangle according to the color value change trend. For example, point a is red, point b is white, and a to b will be changed Red to white trend.
本发明实现通过获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化,从而实现聚光灯在灯中心是最亮,亮度再慢慢向四周递减,最后在给定的范围内达到模糊效果,给人的视线造成聚光灯的发散效果。The present invention realizes by obtaining the circle of the spotlight, and the center point of the circle is the position of the spotlight on the screen; obtaining a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the The center point of the circle and at least two points on the circumference of the circle; the color value of the center of the circle is set as the first color value, and the other points on the graph except the center point of the circle are set The color value of the point is set as a second color value; the graph after the color change is obtained according to a preset color change algorithm, the change is a change of a color value from the first color value to the second color value, In this way, the spotlight is the brightest in the center of the lamp, and the brightness gradually decreases to the surroundings, and finally achieves a blur effect within a given range, causing the divergence effect of the spotlight to give people's sight.
实施例二Embodiment two
参考图2,图2是本发明实施例获取聚光灯的方法第二实施例的流程示意图。Referring to FIG. 2 , FIG. 2 is a schematic flowchart of a second embodiment of a method for acquiring a spotlight according to an embodiment of the present invention.
在实施例二中,所述根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化之后,还包括:In the second embodiment, the graph obtained after the color change is obtained according to the preset color change algorithm, the change is after the color value changes from the first color value to the second color value, and further includes :
步骤105,接收用户在所述屏幕上的触发点的位置坐标;Step 105, receiving the position coordinates of the user's trigger point on the screen;
步骤106,判断所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内;Step 106, judging whether the position coordinates of the trigger point are within the coordinate range of the circle of the spotlight;
步骤107,若所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内,则获取所述触发点在所述屏幕上滑动的指令;Step 107, if the position coordinates of the trigger point are within the coordinate range of the spotlight circle, obtain an instruction for the trigger point to slide on the screen;
步骤108,根据所述指令移动所述聚光灯的中心点的位置。Step 108, move the position of the center point of the spotlight according to the instruction.
优选地,所述根据所述指令移动所述聚光灯的中心点的位置,包括:Preferably, the moving the position of the center point of the spotlight according to the instruction includes:
若所述指令为向左移动,则向左移动所述聚光灯的中心点的位置;If the instruction is to move to the left, move the position of the center point of the spotlight to the left;
若所述指令为向右移动,则向右移动所述聚光灯的中心点的位置;If the instruction is to move to the right, then move the position of the center point of the spotlight to the right;
若所述指令为向上移动,则向上移动所述聚光灯的中心点的位置;If the instruction is to move upward, move the position of the center point of the spotlight upward;
若所述指令为向下移动,则向下移动所述聚光灯的中心点的位置。If the instruction is to move downward, move the position of the center point of the spotlight downward.
具体的,可以通过检测用户在屏幕聚光灯范围内的触屏位置,若该触屏位置在所述聚光灯的圆内,进一步检测用户在触摸屏上滑动的方向,根据该方向来移动所述聚光灯。Specifically, by detecting the user's touch screen position within the spotlight range of the screen, if the touch screen position is within the circle of the spotlight, further detecting the direction in which the user slides on the touch screen, and moving the spotlight according to the direction.
实施例三Embodiment three
参考图3,图3是本发明实施例获取聚光灯图形的装置的功能模块示意图。Referring to FIG. 3 , FIG. 3 is a schematic diagram of functional modules of an apparatus for acquiring a spotlight image according to an embodiment of the present invention.
在实施例三中,所述获取聚光灯图形的装置包括:In the third embodiment, the device for acquiring spotlight graphics includes:
第一获取模块301,用于获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;The first acquiring module 301 is configured to acquire a circle of a spotlight, and the center point of the circle is the position of the spotlight on the screen;
具体的,在屏幕上新建一个图层,将该图层的颜色设置为黑色。给定聚光灯在屏幕上的位置坐标P(x,y),和聚光灯的半径R,并将该图层中P点的颜色设置为黑色透明。Specifically, create a new layer on the screen, and set the color of the layer to black. The position coordinates P(x, y) of the spotlight on the screen and the radius R of the spotlight are given, and the color of point P in this layer is set to black and transparent.
第二获取模块302,用于获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;The second acquisition module 302 is used to acquire a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the center point of the circle and at least two points on the circumference of the circle ;
优选地,参考图4,图4是本发明实施例第二获取模块302的功能模块示意图。Preferably, refer to FIG. 4 , which is a schematic diagram of functional modules of the second acquisition module 302 according to an embodiment of the present invention.
所述第二获取模块302包括:The second acquisition module 302 includes:
划分单元401,用于将所述圆均匀的划分为N个等份;A dividing unit 401, configured to evenly divide the circle into N equal parts;
第一获取单元402,用于获取划分后的N+1个点的坐标,所述N+1个点的坐标为N个等份的圆与所述聚光灯的圆周相交的N+1个点的坐标;The first acquisition unit 402 is configured to acquire the coordinates of the divided N+1 points, where the coordinates of the N+1 points are the N+1 points where N equal circles intersect the circumference of the spotlight coordinate;
第二获取单元403,用于根据所述N+1个点的坐标获取N个三角形,所述三角形的顶点分别为所述圆的中心和所述N+1个点中相邻两个点。The second obtaining unit 403 is configured to obtain N triangles according to the coordinates of the N+1 points, and vertices of the triangles are respectively the center of the circle and two adjacent points among the N+1 points.
具体的,将聚光灯的圆分成N份,则每一份的角度为a=2*π/N,通过半径和聚光灯的坐标计算出这个划分N去区域的N个定点的坐标如下:Specifically, the circle of the spotlight is divided into N parts, and the angle of each part is a=2*π/N. The coordinates of the N fixed points that divide the N area are calculated through the radius and the coordinates of the spotlight as follows:
第i个点的坐标为:x=R*cos(i*a);y=R*sin(i*a);i从0到N,并设置第个点的颜色值为黑色不透明。The coordinates of the i-th point are: x=R*cos(i*a); y=R*sin(i*a); i is from 0 to N, and the color value of the i-th point is set to black and opaque.
设置模块303,用于将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;A setting module 303, configured to set the color value of the center of the circle as a first color value, and set the color values of points other than the center point of the circle on the graph as a second color value;
第三获取模块304,用于根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化。The third obtaining module 304 is configured to obtain the graph after color change according to a preset color change algorithm, the change being a change of a color value from the first color value to the second color value.
优选地,图5是本发明实施例第三获取模块304的功能模块示意图。Preferably, FIG. 5 is a schematic diagram of functional modules of the third acquisition module 304 according to the embodiment of the present invention.
所述第三获取模块304包括:The third acquisition module 304 includes:
第三获取单元500,用于根据预先设置的渲染算法获取所述N个三角形的颜色从白色到黑色的渐变颜色,所述第一颜色值为白色,所述第二颜色值为黑色。The third obtaining unit 500 is configured to obtain a gradient color of the N triangles from white to black according to a preset rendering algorithm, the first color value is white, and the second color value is black.
具体的,按顺序从N个定点中取出相邻的两个定点如(0,1)(1,2),…(N-1,N+1),分别与聚光灯的坐标点p组成一个三角形,并用OpenGL的三角形渲染方式将这些三角行进行渲染,每个顶点的颜色值上面已知,OpenGL会根据颜色值变化趋势去渲染三角形,例如a点红色,b点白色,a到b就会由红变白趋势。Specifically, take out two adjacent fixed points such as (0,1)(1,2),...(N-1, N+1) from N fixed points in order, and form a triangle with the coordinate point p of the spotlight respectively , and use OpenGL's triangle rendering method to render these triangle rows. The color value of each vertex is known above, and OpenGL will render the triangle according to the color value change trend. For example, point a is red, point b is white, and a to b will be changed Red to white trend.
本发明实现通过获取聚光灯的圆,所述圆的中心点为所述聚光灯在屏幕上的位置;获取预先设置的个数的图形,所述图形为三角形或者多边形,所述图形的顶点包括所述圆的中心点以及至少两个在所述圆的圆周上的点;将所述圆的中心的颜色值设置为第一颜色值,将在所述图形上除所述圆的中心点以外的其他点的颜色值设置为第二颜色值;根据预先设置的颜色变化算法获取颜色变化后的所述图形,所述变化为颜色值从所述第一颜色值到所述第二颜色值的变化,从而实现聚光灯在灯中心是最亮,亮度再慢慢向四周递减,最后在给定的范围内达到模糊效果,给人的视线造成聚光灯的发散效果。The present invention realizes by obtaining the circle of the spotlight, and the center point of the circle is the position of the spotlight on the screen; obtaining a preset number of graphics, the graphics are triangles or polygons, and the vertices of the graphics include the The center point of the circle and at least two points on the circumference of the circle; the color value of the center of the circle is set as the first color value, and the other points on the graph except the center point of the circle are set The color value of the point is set as a second color value; the graph after the color change is obtained according to a preset color change algorithm, the change is a change of a color value from the first color value to the second color value, In this way, the spotlight is the brightest in the center of the lamp, and the brightness gradually decreases to the surroundings, and finally achieves a blur effect within a given range, causing the divergence effect of the spotlight to give people's sight.
实施例四Embodiment four
参考图6,图6是本发明实施例获取聚光灯图形的装置的功能模块示意图。Referring to FIG. 6 , FIG. 6 is a schematic diagram of functional modules of an apparatus for acquiring a spotlight image according to an embodiment of the present invention.
在实施例三的基础上,所述装置还包括:On the basis of embodiment three, the device also includes:
接收模块305,用于接收用户在所述屏幕上的触发点的位置坐标;A receiving module 305, configured to receive the position coordinates of the user's trigger point on the screen;
判断模块306,用于判断所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内;A judging module 306, configured to judge whether the position coordinates of the trigger point are within the coordinate range of the spotlight circle;
第三获取模块307,用于若所述触发点的位置坐标是否在所述聚光灯的圆的坐标范围内,则获取所述触发点在所述屏幕上滑动的指令;The third acquiring module 307 is configured to acquire an instruction for the trigger point to slide on the screen if the position coordinates of the trigger point are within the coordinate range of the spotlight circle;
移动模块308,用于根据所述指令移动所述聚光灯的中心点的位置。A moving module 308, configured to move the position of the center point of the spotlight according to the instruction.
优选地,参考图7,图7是本发明实施例移动模块308的功能模块示意图。所述移动模块308包括:Preferably, refer to FIG. 7 , which is a schematic diagram of functional modules of the mobile module 308 according to an embodiment of the present invention. The mobile module 308 includes:
第一移动单元701,用于若所述指令为向左移动,则向左移动所述聚光灯的中心点的位置;The first moving unit 701 is configured to move the position of the center point of the spotlight to the left if the instruction is to move to the left;
第二移动单元702,用于若所述指令为向右移动,则向右移动所述聚光灯的中心点的位置;The second moving unit 702 is configured to move the position of the center point of the spotlight to the right if the instruction is to move to the right;
第三移动单元703,用于若所述指令为向上移动,则向上移动所述聚光灯的中心点的位置;The third moving unit 703 is configured to move the position of the center point of the spotlight upward if the instruction is to move upward;
第四移动单元704,用于若所述指令为向下移动,则向下移动所述聚光灯的中心点的位置。The fourth moving unit 704 is configured to move the position of the center point of the spotlight downward if the instruction is to move downward.
具体的,可以通过检测用户在屏幕聚光灯范围内的触屏位置,若该触屏位置在所述聚光灯的圆内,进一步检测用户在触摸屏上滑动的方向,根据该方向来移动所述聚光灯。Specifically, by detecting the position of the user's touch screen within the range of the spotlight on the screen, if the touch screen position is within the circle of the spotlight, further detecting the direction in which the user slides on the touch screen, and moving the spotlight according to this direction.
以上结合具体实施例描述了本发明实施例的技术原理。这些描述只是为了解释本发明实施例的原理,而不能以任何方式解释为对本发明实施例保护范围的限制。基于此处的解释,本领域的技术人员不需要付出创造性的劳动即可联想到本发明实施例的其它具体实施方式,这些方式都将落入本发明实施例的保护范围之内。The above describes the technical principles of the embodiments of the present invention in conjunction with specific embodiments. These descriptions are only for explaining the principles of the embodiments of the present invention, and cannot be construed as limiting the protection scope of the embodiments of the present invention in any way. Based on the explanations herein, those skilled in the art can think of other specific implementation manners of the embodiments of the present invention without creative efforts, and these manners will fall within the protection scope of the embodiments of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510325511.5A CN105045476A (en) | 2015-06-12 | 2015-06-12 | Method and device for acquiring spotlight graph |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510325511.5A CN105045476A (en) | 2015-06-12 | 2015-06-12 | Method and device for acquiring spotlight graph |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105045476A true CN105045476A (en) | 2015-11-11 |
Family
ID=54452052
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510325511.5A Pending CN105045476A (en) | 2015-06-12 | 2015-06-12 | Method and device for acquiring spotlight graph |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105045476A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106126024A (en) * | 2016-06-23 | 2016-11-16 | 福建天泉教育科技有限公司 | A kind of method and system of display highlighting content |
CN107798662A (en) * | 2017-10-18 | 2018-03-13 | 维沃移动通信有限公司 | A kind of image processing method and mobile terminal |
WO2022042130A1 (en) * | 2020-08-28 | 2022-03-03 | 稿定(厦门)科技有限公司 | Spotlight effect implementation method and apparatus based on particles |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1950864A (en) * | 2004-06-15 | 2007-04-18 | 欧姆龙株式会社 | Display device |
US20070115275A1 (en) * | 2005-11-18 | 2007-05-24 | Cook Joanna | Grip manipulatable shadows in 3D models |
CN101098415A (en) * | 2006-06-30 | 2008-01-02 | 松下电器产业株式会社 | Solid-state imaging element and solid-state imaging device |
CN101739897A (en) * | 2010-01-22 | 2010-06-16 | 苏州领航自动化科技有限公司 | PLT file-based three-dimensional display method for advertising character |
CN103399311A (en) * | 2013-08-19 | 2013-11-20 | 中国电子科技集团公司第三十八研究所 | Rendering method used for real-time echo of scene surveillance radar |
-
2015
- 2015-06-12 CN CN201510325511.5A patent/CN105045476A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1950864A (en) * | 2004-06-15 | 2007-04-18 | 欧姆龙株式会社 | Display device |
US20070115275A1 (en) * | 2005-11-18 | 2007-05-24 | Cook Joanna | Grip manipulatable shadows in 3D models |
CN101098415A (en) * | 2006-06-30 | 2008-01-02 | 松下电器产业株式会社 | Solid-state imaging element and solid-state imaging device |
CN101739897A (en) * | 2010-01-22 | 2010-06-16 | 苏州领航自动化科技有限公司 | PLT file-based three-dimensional display method for advertising character |
CN103399311A (en) * | 2013-08-19 | 2013-11-20 | 中国电子科技集团公司第三十八研究所 | Rendering method used for real-time echo of scene surveillance radar |
Non-Patent Citations (2)
Title |
---|
JIAOYANGZHIDAO: "PPT 动画 制作聚光灯效果", 《HTTPS://WENKU.BAIDU.COM/VIEW/4724CBDC50E2524DE5187E45.HTML?FROM=SEARCH》 * |
张鹏: "一种基于OpenGL的雷达回波显示方法", 《舰船电子对抗》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106126024A (en) * | 2016-06-23 | 2016-11-16 | 福建天泉教育科技有限公司 | A kind of method and system of display highlighting content |
CN107798662A (en) * | 2017-10-18 | 2018-03-13 | 维沃移动通信有限公司 | A kind of image processing method and mobile terminal |
CN107798662B (en) * | 2017-10-18 | 2020-04-07 | 维沃移动通信有限公司 | Image processing method and mobile terminal |
WO2022042130A1 (en) * | 2020-08-28 | 2022-03-03 | 稿定(厦门)科技有限公司 | Spotlight effect implementation method and apparatus based on particles |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11200746B2 (en) | Device and method to display object with visual effect | |
JP6903183B2 (en) | Changes in effective resolution based on screen position in graphics processing by approximating the projection of vertices on a curved viewport | |
JP6612266B2 (en) | 3D model rendering method and apparatus, and terminal device | |
US20170032565A1 (en) | Three-dimensional facial reconstruction method and system | |
ES2932404T3 (en) | Shading CG renderings of materials | |
ES3014189T3 (en) | Display system and method for delivering multi-view content | |
US20170169613A1 (en) | Displaying an object with modified render parameters | |
ES2984277T3 (en) | Changing the overlay emphasis on augmented reality displays | |
US20180184071A1 (en) | Photographing device and method for obtaining depth information | |
CN104200512A (en) | Multiple-light source rendering method based on virtual spherical light sources | |
CN105045476A (en) | Method and device for acquiring spotlight graph | |
CN105227882A (en) | A kind of display packing and corresponding intrument | |
US20160081168A1 (en) | Optical projection apparatus and illumination apparatus using same | |
Iwai et al. | Shadow removal of projected imagery by occluder shape measurement in a multiple overlapping projection system | |
CN104657097A (en) | Method and device for displaying wave-shaped dynamic image | |
US9501862B2 (en) | Visibility silhouettes for masked spherical integration | |
CN117422844B (en) | Virtual-real light alignment method and device, electronic equipment and medium | |
CN103824310A (en) | Method for generating characters with special light effect | |
US10334697B2 (en) | Method and device for displaying illumination | |
US20170178394A1 (en) | Rendering an infinite plane | |
CN105956996B (en) | Fisheye image correcting method, device and system based on birefringence projection model | |
US10121253B2 (en) | Method and apparatus for modeling target object to represent smooth silhouette | |
CN112819929A (en) | Water surface rendering method and device, electronic equipment and storage medium | |
CN108174115B (en) | Light supplementing method and device for flying saucer camera | |
CN106873875B (en) | Graphical display method and device of data and computing equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20151111 |
|
RJ01 | Rejection of invention patent application after publication |