nashorn/test/script/jfx/kaleidoscope.js
author rprotacio
Tue, 06 Sep 2016 22:52:35 +0200
changeset 40921 cc129ac8e609
parent 24778 2ff5d7041566
permissions -rw-r--r--
Merge
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
        
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    34
var WIDTH = 800;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    35
var HEIGHT = 600;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    36
var canvas = new Canvas(WIDTH, HEIGHT);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    37
var context = canvas.graphicsContext2D;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    38
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    39
var x,y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    40
var p_x,p_y;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    41
var a=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    42
var b=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    43
var angle=Math.PI/180*8;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    44
var color=0;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    45
var limit1=Math.PI*1.5;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    46
var limit2=Math.PI*1.79;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    47
var c=new Array(6);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    48
var d=new Array(6);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    49
var r,e;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    50
var fade;
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    51
var prv_x,prv_y,prv_x2,prv_y2;
21690
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
    52
var isFrameRendered = false;
21443
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    53
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    54
function renderFrame() {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    55
    if (!isFrameRendered) {
21690
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
    56
        a=0.2*angle;
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    57
        b=0.7*angle;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    58
        r=0;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    59
        fade=32;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    60
        for(var i=0;i<6;i++)
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    61
            {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    62
            c[i]=1.0/(i+1)/2;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    63
            d[i]=1.0/(i+1)/2;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    64
            }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    65
        radius=Math.round((WIDTH+HEIGHT)/8);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    66
        e=radius*0.2;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    67
        p_x=Math.round(WIDTH/2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    68
        p_y=Math.round(HEIGHT/2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    69
        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]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    70
        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]);
21690
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
    71
        isFrameRendered = true;
21443
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    72
    }
21690
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
    73
    anim();
21443
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    74
}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    75
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
    76
function anim() {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    77
    var a1=Math.cos(a*2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    78
    var a2=Math.cos(a*4);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    79
    var a3=Math.cos(a);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    80
    var a4=Math.sin(a);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    81
    if(b>limit1&&b<limit2) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    82
        r+=radius*0.02*a1;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    83
        prv_x=x;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    84
        prv_y=y;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    85
        x=prv_x2+r*a3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    86
        y=prv_y2+r*a4;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    87
    } else {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    88
        prv_x=x;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    89
        prv_y=y;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    90
        prv_x2=x;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    91
        prv_y2=y;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    92
        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]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    93
        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]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    94
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    95
    var c3=16*Math.cos(a*10);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    96
    var c1=Math.floor(56*Math.cos(a*angle*4)+c3);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    97
    var c2=Math.floor(56*Math.sin(a*angle*4)-c3);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    98
    context.lineCap=StrokeLineCap.ROUND;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
    99
    context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.01-0.005*-a1)+')'));
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   100
    context.lineWidth=e*1.4+e*0.8*a3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   101
    draw_line(p_x,p_y,prv_x,prv_y,x,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   102
    context.lineWidth=e+e*0.8*a3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   103
    draw_line(p_x,p_y,prv_x,prv_y,x,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   104
    context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.06-0.03*-a1)+')'));
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   105
    context.lineWidth=e*0.6+e*0.35*a3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   106
    draw_line(p_x,p_y,prv_x,prv_y,x,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   107
    context.setStroke(Paint.valueOf('rgba(0,0,0,0.06)'));
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   108
    context.lineWidth=e*0.4+e*0.225*a3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   109
    draw_line(p_x,p_y,prv_x,prv_y,x,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   110
    context.setStroke(Paint.valueOf('rgba('+(192+c1)+','+(192+c2)+','+(192-c1)+','+(0.1-0.075*-a1)+')'));
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   111
    context.lineWidth=e*0.2+e*0.1*a3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   112
    draw_line(p_x,p_y,prv_x,prv_y,x,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   113
    context.setStroke(Paint.valueOf('rgba(255,255,255,0.4)'));
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   114
    context.lineWidth=e*(0.1-0.05*-a2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   115
    draw_line(p_x,p_y,prv_x,prv_y,x,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   116
    a+=angle*Math.cos(b);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   117
    b+=angle*0.1;
21443
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   118
}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   119
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   120
function draw_line(x,y,x1,y1,x2,y2) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   121
    context.beginPath();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   122
    context.moveTo(x+x1,y+y1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   123
    context.lineTo(x+x2,y+y2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   124
    context.moveTo(x-x1,y+y1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   125
    context.lineTo(x-x2,y+y2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   126
    context.moveTo(x-x1,y-y1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   127
    context.lineTo(x-x2,y-y2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   128
    context.moveTo(x+x1,y-y1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   129
    context.lineTo(x+x2,y-y2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   130
    context.moveTo(x+y1,y+x1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   131
    context.lineTo(x+y2,y+x2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   132
    context.moveTo(x-y1,y+x1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   133
    context.lineTo(x-y2,y+x2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   134
    context.moveTo(x-y1,y-x1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   135
    context.lineTo(x-y2,y-x2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   136
    context.moveTo(x+y1,y-x1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   137
    context.lineTo(x+y2,y-x2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   138
    context.moveTo(x,y+x2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   139
    context.lineTo(x,y+x1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   140
    context.moveTo(x,y-x2);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   141
    context.lineTo(x,y-x1);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   142
    context.moveTo(x+x2,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   143
    context.lineTo(x+x1,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   144
    context.moveTo(x-x2,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   145
    context.lineTo(x-x1,y);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   146
    context.stroke();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 21690
diff changeset
   147
    context.closePath();
21443
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   148
}
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   149
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   150
var stack = new StackPane();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   151
var pane = new BorderPane();
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   152
pane.setCenter(canvas);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   153
stack.getChildren().add(pane);
85671274e5fb 8026871: NASHORN TEST: Enable possibility to test Nashorn use of JavaFX canvas.
kshefov
parents:
diff changeset
   154
$STAGE.scene = new Scene(stack);
21690
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   155
var frame = 0;
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   156
var timer = new AnimationTimerExtend() {
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   157
    handle: function handle(now) {
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   158
        if (frame < 800) {
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   159
            renderFrame();
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   160
            frame++;
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   161
        } else {
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   162
            checkImageAndExit();
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   163
            timer.stop();
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   164
        }
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   165
    }
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   166
};
ffbb4611d1f4 8027708: NASHORN TEST: Create Nashorn test that draws image step-by-step using JavaFX canvas.
kshefov
parents: 21443
diff changeset
   167
timer.start();