Skip to content

Commit

Permalink
frame title takes title_ args
Browse files Browse the repository at this point in the history
  • Loading branch information
iamlemec committed Sep 9, 2024
1 parent 1b21929 commit eb22769
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions js/gum.js
Original file line number Diff line number Diff line change
Expand Up @@ -1877,20 +1877,20 @@ class Node extends Frame {
}

class TitleFrame extends Frame {
constructor(child, title, attr) {
let {label_size, label_fill, border, margin, ...attr0} = attr ?? {};
let [label_attr0, frame_attr0] = prefix_split(['label'], attr0);
label_size = label_size ?? 0.075;
label_fill = label_fill ?? 'white';
constructor(child, text, attr) {
let {title_size, title_fill, border, margin, ...attr0} = attr ?? {};
let [title_attr0, frame_attr0] = prefix_split(['title'], attr0);
title_size = title_size ?? 0.075;
title_fill = title_fill ?? 'white';
border = border ?? 1;

// fill in default attributes
let label_attr = {fill: label_fill, ...label_attr0};
let title_attr = {fill: title_fill, ...title_attr0};
let frame_attr = {border, ...frame_attr0};

// place label at top
let label = new Node(title, label_attr);
let place = new Place(label, {pos: [0.5, 0.0], rad: [null, label_size], expand: true});
let title = new Node(text, title_attr);
let place = new Place(title, {pos: [0.5, 0.0], rad: [null, title_size], expand: true});
let frame = new Frame(child, frame_attr);
let group = new Group([frame, place], {clip: false, aspect: frame.aspect});

Expand Down
2 changes: 1 addition & 1 deletion js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ let plot = Plot([sine, peaks, ...quads], {
// Return the framed plot
return TitleFrame(plot, 'Quadratic Functions with Sine Wave Peaks', {
margin: 0.15, label_size: 0.06, label_border_radius: 0.03, border: 1
margin: 0.15, title_size: 0.065, title_border_radius: 0.03, border: 1
});`;

// init editors
Expand Down

0 comments on commit eb22769

Please sign in to comment.