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