aoqi@0: /* aoqi@0: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: /** aoqi@0: * Testing JavaFX canvas run by Nashorn. aoqi@0: * aoqi@0: * @test/nocompare aoqi@0: * @run aoqi@0: * @fork aoqi@0: */ aoqi@0: aoqi@0: TESTNAME = "kaleidoscope"; aoqi@0: aoqi@0: var WIDTH = 800; aoqi@0: var HEIGHT = 600; aoqi@0: var canvas = new Canvas(WIDTH, HEIGHT); aoqi@0: var context = canvas.graphicsContext2D; aoqi@0: aoqi@0: var x,y; aoqi@0: var p_x,p_y; aoqi@0: var a=0; aoqi@0: var b=0; aoqi@0: var angle=Math.PI/180*8; aoqi@0: var color=0; aoqi@0: var limit1=Math.PI*1.5; aoqi@0: var limit2=Math.PI*1.79; aoqi@0: var c=new Array(6); aoqi@0: var d=new Array(6); aoqi@0: var r,e; aoqi@0: var fade; aoqi@0: var prv_x,prv_y,prv_x2,prv_y2; aoqi@0: var isFrameRendered = false; aoqi@0: aoqi@0: function renderFrame() { attila@962: if (!isFrameRendered) { aoqi@0: a=0.2*angle; attila@962: b=0.7*angle; attila@962: r=0; attila@962: fade=32; attila@962: for(var i=0;i<6;i++) attila@962: { attila@962: c[i]=1.0/(i+1)/2; attila@962: d[i]=1.0/(i+1)/2; attila@962: } attila@962: radius=Math.round((WIDTH+HEIGHT)/8); attila@962: e=radius*0.2; attila@962: p_x=Math.round(WIDTH/2); attila@962: p_y=Math.round(HEIGHT/2); attila@962: x=(radius*c[0])*Math.cos(a*d[1])+(radius*c[2])*Math.sin(a*d[3])+(radius*c[4])*Math.sin(a*d[5]); attila@962: y=(radius*c[5])*Math.sin(a*d[4])+(radius*c[3])*Math.cos(a*d[2])+(radius*c[1])*Math.cos(a*d[0]); aoqi@0: isFrameRendered = true; aoqi@0: } aoqi@0: anim(); aoqi@0: } aoqi@0: aoqi@0: function anim() { attila@962: var a1=Math.cos(a*2); attila@962: var a2=Math.cos(a*4); attila@962: var a3=Math.cos(a); attila@962: var a4=Math.sin(a); attila@962: if(b>limit1&&b