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.


Code Edit


//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()

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

    scene: Scene{
        content: [Scribble{}]

[[Category:Code Example]]

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.