<commit_before>﻿var c = Context.Editor.Container;
var sg = c.StyleGroups.Where(x => x.Name == "Logic").FirstOrDefault();
if (sg == null)
{
    sg = ShapeStyleGroup.Create("Logic");
    c.StyleGroups.Add(sg);
}
var styles = sg.Styles;
var ps = c.PointShape;

var styleTextBig = ShapeStyle.Create(
    "Logic-Big-Text", 
    255, 0, 0, 0, 
    255, 0, 0, 0, 
    2.0, 
    null, 
    "Consolas", 14.0, TextHAlignment.Center, TextVAlignment.Center);
styles.Add(styleTextBig);

var styleLineThick = ShapeStyle.Create(
    "Logic-Line-Thick", 
    255, 0, 0, 0, 
    255, 0, 0, 0, 
    2.0, null, 
    "Consolas", 12.0, TextHAlignment.Center, TextVAlignment.Center);
styles.Add(styleLineThick);

sg.CurrentStyle = sg.Styles.FirstOrDefault();

void SetShapeState(BaseShape shape, XGroup owner)
{
    shape.Owner = owner;
    shape.State &= ~ShapeState.Standalone;
}

void SetConnectorAsNone(XPoint point, XGroup owner)
{
    point.Owner = owner;
    point.State |= ShapeState.Connector | ShapeState.None;
    point.State &= ~ShapeState.Standalone;
}

void SetConnectorAsInput(XPoint point, XGroup owner)
{
    point.Owner = owner;
    point.State |= ShapeState.Connector | ShapeState.Input;
    point.State &= ~ShapeState.Standalone;
}

void SetConnectorAsOutput(XPoint point, XGroup owner)
{
    point.Owner = owner;
    point.State |= ShapeState.Connector | ShapeState.Output;
    point.State &= ~ShapeState.Standalone;
}

// INPUT signal
XGroup CreateInputSignal()
{
    var g = XGroup.Create("INPUT");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "IN", false, "");
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var co = XPoint.Create(30, 15, ps, "O");
    SetConnectorAsOutput(co, g);
    g.Connectors.Add(co);

    return g;
}

// OUTPUT signal
XGroup CreateOutputSignal()
{
    var g = XGroup.Create("OUTPUT");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "OUT", false, "");
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var ci = XPoint.Create(0, 15, ps, "I");
    SetConnectorAsInput(ci, g);
    g.Connectors.Add(ci);

    return g;
}

// AND gate
XGroup CreateAndGate()
{
    var g = XGroup.Create("AND");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "&", false, "");
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var cl = XPoint.Create(0, 15, ps, "L");
    SetConnectorAsNone(cl, g);
    g.Connectors.Add(cl);

    var cr = XPoint.Create(30, 15, ps, "R");
    SetConnectorAsNone(cr, g);
    g.Connectors.Add(cr);

    var ct = XPoint.Create(15, 0, ps, "T");
    SetConnectorAsNone(ct, g);
    g.Connectors.Add(ct);

    var cb = XPoint.Create(15, 30, ps, "B");
    SetConnectorAsNone(cb, g);
    g.Connectors.Add(cb);

    return g;
}

// OR gate
XGroup CreateOrGate()
{
    var g = XGroup.Create("OR");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "≥1", false, "");
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var cl = XPoint.Create(0, 15, ps, "L");
    SetConnectorAsNone(cl, g);
    g.Connectors.Add(cl);

    var cr = XPoint.Create(30, 15, ps, "R");
    SetConnectorAsNone(cr, g);
    g.Connectors.Add(cr);

    var ct = XPoint.Create(15, 0, ps, "T");
    SetConnectorAsNone(ct, g);
    g.Connectors.Add(ct);<commit_msg>Added properties to logic gates script<commit_after>﻿var c = Context.Editor.Container;
var sg = c.StyleGroups.Where(x => x.Name == "Logic").FirstOrDefault();
if (sg == null)
{
    sg = ShapeStyleGroup.Create("Logic");
    c.StyleGroups.Add(sg);
}
var styles = sg.Styles;
var ps = c.PointShape;

var styleTextBig = ShapeStyle.Create(
    "Logic-Big-Text", 
    255, 0, 0, 0, 
    255, 0, 0, 0, 
    2.0, 
    null, 
    "Consolas", 14.0, TextHAlignment.Center, TextVAlignment.Center);
styles.Add(styleTextBig);

var styleLineThick = ShapeStyle.Create(
    "Logic-Line-Thick", 
    255, 0, 0, 0, 
    255, 0, 0, 0, 
    2.0, null, 
    "Consolas", 12.0, TextHAlignment.Center, TextVAlignment.Center);
styles.Add(styleLineThick);

sg.CurrentStyle = sg.Styles.FirstOrDefault();

void SetShapeState(BaseShape shape, XGroup owner)
{
    shape.Owner = owner;
    shape.State &= ~ShapeState.Standalone;
}

void SetConnectorAsNone(XPoint point, XGroup owner)
{
    point.Owner = owner;
    point.State |= ShapeState.Connector | ShapeState.None;
    point.State &= ~ShapeState.Standalone;
}

void SetConnectorAsInput(XPoint point, XGroup owner)
{
    point.Owner = owner;
    point.State |= ShapeState.Connector | ShapeState.Input;
    point.State &= ~ShapeState.Standalone;
}

void SetConnectorAsOutput(XPoint point, XGroup owner)
{
    point.Owner = owner;
    point.State |= ShapeState.Connector | ShapeState.Output;
    point.State &= ~ShapeState.Standalone;
}

// INPUT signal
XGroup CreateInputSignal()
{
    var g = XGroup.Create("INPUT");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "{0}", false, "");
    var labelProperty = ShapeProperty.Create("IN");
    g.AddProperty("Label", labelProperty);
    label.Properties = new [] { labelProperty };

    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var co = XPoint.Create(30, 15, ps, "O");
    SetConnectorAsOutput(co, g);
    g.Connectors.Add(co);

    return g;
}

// OUTPUT signal
XGroup CreateOutputSignal()
{
    var g = XGroup.Create("OUTPUT");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "{0}", false, "");
    var labelProperty = ShapeProperty.Create("OUT");
    g.AddProperty("Label", labelProperty);
    label.Properties = new [] { labelProperty };
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var ci = XPoint.Create(0, 15, ps, "I");
    SetConnectorAsInput(ci, g);
    g.Connectors.Add(ci);

    return g;
}

// AND gate
XGroup CreateAndGate()
{
    var g = XGroup.Create("AND");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "&", false, "");
    var labelProperty = ShapeProperty.Create("&");
    g.AddProperty("Label", labelProperty);
    label.Properties = new [] { labelProperty };
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var cl = XPoint.Create(0, 15, ps, "L");
    SetConnectorAsNone(cl, g);
    g.Connectors.Add(cl);

    var cr = XPoint.Create(30, 15, ps, "R");
    SetConnectorAsNone(cr, g);
    g.Connectors.Add(cr);

    var ct = XPoint.Create(15, 0, ps, "T");
    SetConnectorAsNone(ct, g);
    g.Connectors.Add(ct);

    var cb = XPoint.Create(15, 30, ps, "B");
    SetConnectorAsNone(cb, g);
    g.Connectors.Add(cb);

    return g;
}

// OR gate
XGroup CreateOrGate()
{
    var g = XGroup.Create("OR");

    var label = XText.Create(0, 0, 30, 30, styleTextBig, ps, "{0}{1}", false, "");
    var prefixProperty = ShapeProperty.Create("≥");
    var counterProperty = ShapeProperty.Create("1");
    g.AddProperty("Prefix", prefixProperty);
    g.AddProperty("Counter", counterProperty);
    label.Properties = new [] { prefixProperty, counterProperty };
    SetShapeState(label, g);
    g.Shapes.Add(label);

    var frame = XRectangle.Create(0, 0, 30, 30, styleLineThick, ps, false, "");
    SetShapeState(frame, g);
    g.Shapes.Add(frame);

    var cl = XPoint.Create(0, 15, ps, "L");
    SetConnectorAsNone(cl, g);
    g.Connectors.Add(cl);

    var cr = XPoint.Create(30, 15, ps, "R");
    SetConnectorAsNone(cr, g);
    g.Connectors.Add(cr);

    var ct = XPoint.Create(15, 0, ps, "T");
    SetConnectorAsNone(ct, g);
    g.Connectors.Add(ct);
{'fraction_non_alphanumeric': 0.1625526791089705, 'fraction_numerical': 0.027934978928356412, 'mean_word_length': 3.399364406779661, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3366389', 'n_tokens_mistral': 3227, 'n_tokens_neox': 3018, 'n_words': 680}