Skip to content

Commit

Permalink
purged Random for gen_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
emmaccode authored May 10, 2024
1 parent 16c600d commit 943dff0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Contexts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ mutable struct Context <: AbstractContext
dim::Pair{Int64, Int64}
margin::Pair{Int64, Int64}
Context(wind::Component{:svg}, margin::Pair{Int64, Int64}) = begin
new(wind, randstring(), wind[:width] => wind[:height],
new(wind, gen_ref(5), wind[:width] => wind[:height],
margin)::Context
end
Context(width::Int64 = 1280, height::Int64 = 720,
Expand Down Expand Up @@ -316,7 +316,7 @@ are used to create scaling with `group` and create layers with `group!`.
------------------
##### constructors
```julia
Group(name::String = randstring(), width::Int64 = 1280, height::Int64 = 720,
Group(name::String = gen_ref(5), width::Int64 = 1280, height::Int64 = 720,
margin::Pair{Int64, Int64} = 0 => 0)
```
"""
Expand All @@ -325,7 +325,7 @@ mutable struct Group <: AbstractContext
uuid::String
dim::Pair{Int64, Int64}
margin::Pair{Int64, Int64}
Group(name::String = randstring(), width::Int64 = 1280, height::Int64 = 720,
Group(name::String = gen_ref(5), width::Int64 = 1280, height::Int64 = 720,
margin::Pair{Int64, Int64} = 0 => 0) = begin
window::Component{:g} = ToolipsSVG.g("$name", width = width, height = height)
new(window, name, width => height, margin)
Expand Down
3 changes: 1 addition & 2 deletions src/Gattino.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ module Gattino
using ToolipsSVG
import Base: getindex, setindex!, show, display, vcat, push!, hcat, size, reshape, string
import ToolipsSVG: position, set_position!, set_size!, style!, set_shape, SVGShape
import ToolipsSVG.ToolipsServables: Servable, Component, AbstractComponent, br
using Random: randstring
import ToolipsSVG.ToolipsServables: Servable, Component, AbstractComponent, br, gen_ref

include("context_plotting.jl")

Expand Down
10 changes: 5 additions & 5 deletions src/context_plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function text!(con::AbstractContext, x::Number, y::Number, text::String, styles:
if length(styles) == 0
styles = ("fill" => "black", "font-size" => 13pt)
end
t = ToolipsSVG.text(randstring(), x = x, y = y, text = text)
t = ToolipsSVG.text(gen_ref(5), x = x, y = y, text = text)
style!(t, styles ...)
draw!(con, [t])
nothing::Nothing
Expand Down Expand Up @@ -50,7 +50,7 @@ function line!(con::AbstractContext, first::Pair{<:Number, <:Number},
if length(styles) == 0
styles = ("fill" => "none", "stroke" => "black", "stroke-width" => "4")
end
ln = ToolipsSVG.line(randstring(), x1 = first[1], y1 = first[2],
ln = ToolipsSVG.line(gen_ref(5), x1 = first[1], y1 = first[2],
x2 = second[1], y2 = second[2])
style!(ln, styles ...)
draw!(con, [ln])
Expand Down Expand Up @@ -312,7 +312,7 @@ function points!(con::AbstractContext, x::Vector{<:Number}, y::Vector{<:Number},
draw!(con, Vector{Servable}([begin
cx = Int64(round(percvec_x[i] * (con.dim[1] - 1) + con.margin[1]))
cy = Int64(round(con.dim[2] - percvec_y[i] * (con.dim[2] - 1) + con.margin[2]))
c = circle(randstring(), cx = cx, cy = cy, r = r)
c = circle(gen_ref(5), cx = cx, cy = cy, r = r)
style!(c, styles...)
c
end for i in 1:length(x)]))
Expand Down Expand Up @@ -398,7 +398,7 @@ function bars!(con::AbstractContext, x::Vector{<:Any}, y::Vector{<:Number}, styl
block_width = Int64(round(con.dim[1] / n_features))
rects = Vector{Servable}([begin
scaled_y::Number = Int64(round(con.dim[2] * percvec_y[e]))
rct = ToolipsSVG.rect(randstring(), x = Int64(round(n)) + con.margin[1], y = con.dim[2] - scaled_y + con.margin[2],
rct = ToolipsSVG.rect(gen_ref(5), x = Int64(round(n)) + con.margin[1], y = con.dim[2] - scaled_y + con.margin[2],
width = block_width, height = con.dim[2] - (con.dim[2] - scaled_y))
style!(rct, styles ...)
n += block_width
Expand Down Expand Up @@ -471,7 +471,7 @@ function v_bars!(con::AbstractContext, x::Vector{<:AbstractString}, y::Vector{<:
block_width = Int64(round(con.dim[2] / n_features))
rects = Vector{Servable}([begin
scaled_y::Number = Int64(round(con.dim[2] * percvec_y[e]))
rct = ToolipsSVG.rect(randstring(), x = 0, y = n,
rct = ToolipsSVG.rect(gen_ref(5), x = 0, y = n,
width = con.dim[1] - (con.dim[1] - scaled_y), height = block_width)
style!(rct, styles ...)
n += block_width
Expand Down

0 comments on commit 943dff0

Please sign in to comment.