Engine prototype #13
@ -3,7 +3,7 @@ module Viewer
|
|||||||
using Blink
|
using Blink
|
||||||
using Colors
|
using Colors
|
||||||
|
|
||||||
export ConstructionViewer, display!
|
export ConstructionViewer, display!, opentools!, closetools!
|
||||||
|
|
||||||
# === Blink utilities ===
|
# === Blink utilities ===
|
||||||
|
|
||||||
@ -24,17 +24,23 @@ mutable struct ConstructionViewer
|
|||||||
|
|
||||||
function ConstructionViewer()
|
function ConstructionViewer()
|
||||||
# create window and open developer console
|
# create window and open developer console
|
||||||
win = Window()
|
win = Window(Blink.Dict(:width => 620, :height => 620))
|
||||||
opentools(win)
|
|
||||||
|
|
||||||
# set stylesheet
|
# set stylesheet
|
||||||
style!(win, """
|
style!(win, """
|
||||||
/* needed to keep Ganja canvas from blowing up */
|
body {
|
||||||
|
background-color: #c8c0d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* maximum dimensions are needed to keep Ganja canvas from blowing up */
|
||||||
canvas {
|
canvas {
|
||||||
min-width: 600px;
|
min-width: 600px;
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
min-height: 600px;
|
min-height: 600px;
|
||||||
max-height: 600px;
|
max-height: 600px;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
@ -50,8 +56,9 @@ mutable struct ConstructionViewer
|
|||||||
var elements = [];
|
var elements = [];
|
||||||
var palette = [];
|
var palette = [];
|
||||||
|
|
||||||
// declare visualization handle
|
// declare handles for the visualization and its options
|
||||||
var graph;
|
var graph;
|
||||||
|
var graphOpt;
|
||||||
|
|
||||||
// create scene function
|
// create scene function
|
||||||
function scene() {
|
function scene() {
|
||||||
@ -65,14 +72,13 @@ mutable struct ConstructionViewer
|
|||||||
|
|
||||||
# create view
|
# create view
|
||||||
@js win begin
|
@js win begin
|
||||||
graph = CGA3.graph(
|
graphOpt = Dict(
|
||||||
scene,
|
:conformal => true,
|
||||||
Dict(
|
:gl => true,
|
||||||
"conformal" => true,
|
:grid => true,
|
||||||
"gl" => true,
|
:devicePixelRatio => window.devicePixelRatio
|
||||||
"grid" => true
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
graph = CGA3.graph(scene, graphOpt)
|
||||||
document.body.replaceChildren(graph)
|
document.body.replaceChildren(graph)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -105,6 +111,16 @@ function display!(viewer::ConstructionViewer, elements::Matrix)
|
|||||||
@js viewer.win requestAnimationFrame(graph.update.bind(graph, scene));
|
@js viewer.win requestAnimationFrame(graph.update.bind(graph, scene));
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function opentools!(viewer::ConstructionViewer)
|
||||||
|
size(viewer.win, 1240, 620)
|
||||||
|
opentools(viewer.win)
|
||||||
|
end
|
||||||
|
|
||||||
|
function closetools!(viewer::ConstructionViewer)
|
||||||
|
closetools(viewer.win)
|
||||||
|
size(viewer.win, 620, 620)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# ~~~ sandbox setup ~~~
|
# ~~~ sandbox setup ~~~
|
||||||
|
Loading…
Reference in New Issue
Block a user