Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么在颜色数组中需要额外的元素来绘制顶点?_Java_Android_Canvas_Draw_Vertices - Fatal编程技术网

Java 为什么在颜色数组中需要额外的元素来绘制顶点?

Java 为什么在颜色数组中需要额外的元素来绘制顶点?,java,android,canvas,draw,vertices,Java,Android,Canvas,Draw,Vertices,当我绘制顶点时,我需要放置6个颜色数组,而不是3个,即使我只有3个坐标 setLayerType(View.LAYER_TYPE_SOFTWARE, null) val verticesColors = intArrayOf( Color.RED, Color.GREEN, Color.BLUE, -0x1000000, -0x1000000, -0x1000000) val verts = fl

当我绘制顶点时,我需要放置6个颜色数组,而不是3个,即使我只有3个坐标

        setLayerType(View.LAYER_TYPE_SOFTWARE, null)

        val verticesColors = intArrayOf(
            Color.RED, Color.GREEN, Color.BLUE,
            -0x1000000, -0x1000000, -0x1000000)

        val verts = floatArrayOf(0f, 0f, width.toFloat(), 0f, width/2f, height.toFloat())

        canvas.drawVertices(
            Canvas.VertexMode.TRIANGLES,
            verts.size, verts, 0,
            null, 0,
            verticesColors, 0,
            null, 0, 0,
            paint
        )
图片如下

但是我不明白为什么我需要下面的
-0x1000000

    val verticesColors = intArrayOf(
        Color.RED, Color.GREEN, Color.BLUE,
        -0x1000000, -0x1000000, -0x1000000)
如果我删除
-0x1000000
,它将在内部崩溃

    --------- beginning of crash
2019-04-05 00:27:34.793 15461-15461/? A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 15461 (anvasexperiment), pid 15461 (anvasexperiment)
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:9/PSR1.180720.075/5124027:user/release-keys'
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: Revision: '0'
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: ABI: 'x86'
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: pid: 15461, tid: 15461, name: anvasexperiment  >>> com.elyeproj.canvasexperiment <<<
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG: Abort message: 'bad length'
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:     eax 00000000  ebx 00003c65  ecx 00003c65  edx 00000006
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:     edi 00003c65  esi ffc8f7ec
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:     ebp ffc8f7b8  esp ffc8f748  eip e9ff8b39
2019-04-05 00:27:34.967 15496-15496/? A/DEBUG: backtrace:
2019-04-05 00:27:34.968 15496-15496/? A/DEBUG:     #00 pc 00000b39  [vdso:e9ff8000] (__kernel_vsyscall+9)
2019-04-05 00:27:34.968 15496-15496/? A/DEBUG:     #01 pc 0001fdf8  /system/lib/libc.so (syscall+40)
2019-04-05 00:27:34.968 15496-15496/? A/DEBUG:     #02 pc 00022ed3  /system/lib/libc.so (abort+115)
2019-04-05 00:27:34.968 15496-15496/? A/DEBUG:     #03 pc 00006c84  /system/lib/liblog.so (__android_log_assert+292)
-----------崩溃开始
2019-04-05 00:27:34.793 15461-15461/? A/libc:tid 15461中的致命信号6(SIGABRT)、代码-6(SIU TKILL)(ANVASSERATION)、pid 15461(ANVASSERATION)
2019-04-05 00:27:34.824 15496-15496/? A/调试:***************************************************
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:Build fingerprint:'google/sdk\u gphone\u x86/generic\u x86:9/PSR1.180720.075/5124027:user/release key'
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:修订版:“0”
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:ABI:'x86'
2019-04-05 00:27:34.824 15496-15496/? A/DEBUG:pid:15461,tid:15461,名称:AnvasExperience>>>com.elyeproj.canvasExperience