nashorn/test/script/jfx/kaleidoscope.js
author kshefov
Mon, 21 Oct 2013 13:31:03 +0400
changeset 21443 85671274e5fb
child 21690 ffbb4611d1f4
permissions -rw-r--r--
8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas. Reviewed-by: jlaskey, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21443
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     1
/*
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     4
 * 
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     8
 * 
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    13
 * accompanied this code).
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    14
 * 
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    18
 * 
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    21
 * questions.
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    22
 */
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    23
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    24
/**
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    25
 * Testing JavaFX canvas run by Nashorn.
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    26
 *
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    27
 * @test/nocompare
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    28
 * @run
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    29
 * @fork
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    30
 */
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    31
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    32
TESTNAME = "kaleidoscope";
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    33
WAIT = 4000;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    34
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    35
var Paint                = Java.type("javafx.scene.paint.Paint");
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    36
var Canvas               = Java.type("javafx.scene.canvas.Canvas");
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    37
var BorderPane           = Java.type("javafx.scene.layout.BorderPane");
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    38
var StackPane            = Java.type("javafx.scene.layout.StackPane");
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    39
var StrokeLineCap        = Java.type("javafx.scene.shape.StrokeLineCap");
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    40
        
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    41
var WIDTH = 800;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    42
var HEIGHT = 600;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    43
var canvas = new Canvas(WIDTH, HEIGHT);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    44
var context = canvas.graphicsContext2D;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    45
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    46
var x,y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    47
var p_x,p_y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    48
var a=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    49
var b=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    50
var angle=Math.PI/180*8;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    51
var color=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    52
var limit1=Math.PI*1.5;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    53
var limit2=Math.PI*1.79;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    54
var c=new Array(6);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    55
var d=new Array(6);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    56
var r,e;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    57
var fade;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    58
var prv_x,prv_y,prv_x2,prv_y2;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    59
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    60
function renderFrame() {
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    61
	a=0.2*angle;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    62
	b=0.7*angle;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    63
	r=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    64
	fade=32;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    65
	for(var i=0;i<6;i++)
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    66
		{
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    67
		c[i]=1.0/(i+1)/2;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    68
		d[i]=1.0/(i+1)/2;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    69
		}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    70
	radius=Math.round((WIDTH+HEIGHT)/8);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    71
	e=radius*0.2;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    72
	p_x=Math.round(WIDTH/2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    73
	p_y=Math.round(HEIGHT/2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    74
	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]);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    75
	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]);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    76
    for (i = 0; i < 800; i++) {
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    77
        anim();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    78
    }
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    79
}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    80
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    81
function anim() {
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    82
	var a1=Math.cos(a*2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    83
	var a2=Math.cos(a*4);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    84
	var a3=Math.cos(a);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    85
	var a4=Math.sin(a);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    86
	if(b>limit1&&b<limit2) {
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    87
		r+=radius*0.02*a1;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    88
		prv_x=x;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    89
		prv_y=y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    90
		x=prv_x2+r*a3;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    91
		y=prv_y2+r*a4;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    92
	} else {
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    93
		prv_x=x;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    94
		prv_y=y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    95
		prv_x2=x;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    96
		prv_y2=y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    97
		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]);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    98
		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]);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    99
	}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   100
	var c3=16*Math.cos(a*10);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   101
	var c1=Math.floor(56*Math.cos(a*angle*4)+c3);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   102
	var c2=Math.floor(56*Math.sin(a*angle*4)-c3);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   103
	context.lineCap=StrokeLineCap.ROUND;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   104
	context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.01-0.005*-a1)+')'));
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   105
	context.lineWidth=e*1.4+e*0.8*a3;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   106
	draw_line(p_x,p_y,prv_x,prv_y,x,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   107
	context.lineWidth=e+e*0.8*a3;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   108
	draw_line(p_x,p_y,prv_x,prv_y,x,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   109
	context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.06-0.03*-a1)+')'));
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   110
	context.lineWidth=e*0.6+e*0.35*a3;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   111
	draw_line(p_x,p_y,prv_x,prv_y,x,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   112
	context.setStroke(Paint.valueOf('rgba(0,0,0,0.06)'));
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   113
	context.lineWidth=e*0.4+e*0.225*a3;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   114
	draw_line(p_x,p_y,prv_x,prv_y,x,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   115
	context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.1-0.075*-a1)+')'));
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   116
	context.lineWidth=e*0.2+e*0.1*a3;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   117
	draw_line(p_x,p_y,prv_x,prv_y,x,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   118
	context.setStroke(Paint.valueOf('rgba(255,255,255,0.4)'));
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   119
	context.lineWidth=e*(0.1-0.05*-a2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   120
	draw_line(p_x,p_y,prv_x,prv_y,x,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   121
	a+=angle*Math.cos(b);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   122
	b+=angle*0.1;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   123
}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   124
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   125
function draw_line(x,y,x1,y1,x2,y2) {
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   126
	context.beginPath();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   127
	context.moveTo(x+x1,y+y1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   128
	context.lineTo(x+x2,y+y2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   129
	context.moveTo(x-x1,y+y1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   130
	context.lineTo(x-x2,y+y2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   131
	context.moveTo(x-x1,y-y1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   132
	context.lineTo(x-x2,y-y2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   133
	context.moveTo(x+x1,y-y1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   134
	context.lineTo(x+x2,y-y2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   135
	context.moveTo(x+y1,y+x1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   136
	context.lineTo(x+y2,y+x2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   137
	context.moveTo(x-y1,y+x1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   138
	context.lineTo(x-y2,y+x2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   139
	context.moveTo(x-y1,y-x1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   140
	context.lineTo(x-y2,y-x2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   141
	context.moveTo(x+y1,y-x1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   142
	context.lineTo(x+y2,y-x2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   143
	context.moveTo(x,y+x2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   144
	context.lineTo(x,y+x1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   145
	context.moveTo(x,y-x2);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   146
	context.lineTo(x,y-x1);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   147
	context.moveTo(x+x2,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   148
	context.lineTo(x+x1,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   149
	context.moveTo(x-x2,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   150
	context.lineTo(x-x1,y);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   151
	context.stroke();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   152
	context.closePath();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   153
}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   154
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   155
var stack = new StackPane();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   156
var pane = new BorderPane();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   157
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   158
pane.setCenter(canvas);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   159
stack.getChildren().add(pane);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   160
$STAGE.scene = new Scene(stack);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   161
renderFrame();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   162
checkImageAndExit();