Wikia

Planet JFX

Scribble

118pages on
this wiki
Talk0

Summary Edit

See this thread in the mailing lists.

Scribble is a simple path editor -- click on the canvas, and paths following mouse drags are converted into Polyline objects. Makes use of the SQL-like array insert functionality to create polylines and add points to them.

Scribble

Code Edit

ScribbleRect.fx


//works with javaFX 1.0
package scribble;

import java.lang.System;
import javafx.scene.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.*;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

class Scribble extends CustomNode {
    var polyline: Polyline;

    public override function create(): Node {
        var group: Group = Group{
            onMousePressed: function (e: MouseEvent) {
                polyline = Polyline{
                    points: [e.sceneX, e.sceneY]
                    stroke: Color.RED
                strokeWidth: 7};
            	insert polyline into group.content ;
            }// onMousePressed


            onMouseDragged: function (e: MouseEvent) {
                insert [e.sceneX, e.sceneY] into polyline.points;
            }// onMouseDragged

            content: Rectangle {
                width: 400
                height: 400
                fill: Color.BLUE //Color{opacity: 0}
            }// Rectangle
        }// Group


        return group;
    }// create()
}//Scribble


Stage {
    onClose: function(): Void {
        System.exit(0);
    }
    title: "Scribble with Rectangle"
    //fill: Color.WHITE;
    width: 600
    height: 400
    visible: true

    scene: Scene{
        content: [Scribble{}]
    }//Scene
}//Stage


[[Category:Code Example]]

Around Wikia's network

Random Wiki