Code Monkey home page Code Monkey logo

Comments (4)

gerane avatar gerane commented on May 25, 2024

I did this for my Themes here. I just used PowerShell to take cropped screenshots for the Theme screenshot and Theme icon. I also auto generated all of my package.json values. It would be great if you could do this programmatically just based on the input colors in some way.

My way still required a manual action per theme (switching to target theme), but I was also intentionally doing it manually because I was also looking for bugs caused by the conversion. After I changed theme, I just ran a command and it would take screenshots and update json etc. Then I just inspected everything looking for issues.

from vscode-theme-generator.

Tyriar avatar Tyriar commented on May 25, 2024

I was just thinking having color squares to indicate the colors but it would be really cool if a screenshot could be done too. I found out today that themes are finally being added/explored in Feb microsoft/vscode#20021 to settings, so there would no longer be a manual action necessary

from vscode-theme-generator.

gerane avatar gerane commented on May 25, 2024

Color Squares isn't a bad idea. Screenshots don't always display all colors, so having a combination of color squares and a screenshot might be a nice combo.

I quickly threw this together after I put my daughter to bed. In the themes I was working with, I didn't have an easy list of the color codes. I just wrote this in PowerShell, so I'd assume there has to be something similar in js. The better way to do it would likely be to take the colors as input instead, so $Green instead $CommentColor etc. The one issue with this, is I am just creating a bitmap and replacing the text colors, so it isn't a real screenshot of the theme in Code.

I am also not 100% sure how the colors translate to PowerShell, so the colors I used might not be totally correct, but I was just wanting to kind of make an example.

function New-ThemeImage
{
    [CmdletBinding()]
    param
    (
        $Filename,
        $BackgroundColor,
        $ForegroundColor,
        $StringColor,
        $CommentColor,
        $KeywordColor,
        $FunctionColor,
        $FunctionCallColor,
        $ClassColor
    )

    Add-Type -AssemblyName System.Drawing

    $Bitmap = new-object System.Drawing.Bitmap 300,230
    $font = new-object System.Drawing.Font Consolas,14

    $Gfx = [System.Drawing.Graphics]::FromImage($Bitmap)
    $Gfx.FillRectangle($BackgroundColor,0,0,$Bitmap.Width,$Bitmap.Height)

    $Gfx.DrawString('function',$font,$KeywordColor,10,10)
    $Gfx.DrawString(' Test-Function',$font,$ClassColor,90,10)
    $Gfx.DrawString('{',$font,$ForegroundColor,10,35)
    $Gfx.DrawString('# Test Comment',$font,$CommentColor,40,60)
    $Gfx.DrawString('$',$font,$KeywordColor,40,85)
    $Gfx.DrawString('var',$font,$FunctionColor,50,85)
    $Gfx.DrawString('= ',$font,$ForegroundColor,90,85)
    $Gfx.DrawString('"Hello World"',$font,$StringColor,110,85)
    $Gfx.DrawString('$',$font,$KeywordColor,40,110)
    $Gfx.DrawString('var',$font,$FunctionColor,50,110)
    $Gfx.DrawString('.Replace',$font,$FunctionCallColor,80,110)
    $Gfx.DrawString('(',$font,$KeywordColor,160,110)
    $Gfx.DrawString('"Hello "',$font,$StringColor,170,110)
    $Gfx.DrawString(',',$font,$KeywordColor,250,110)
    $Gfx.DrawString('""',$font,$StringColor,260,110)
    $Gfx.DrawString(')',$font,$KeywordColor,280,110)
    $Gfx.DrawString('Return ',$font,$KeywordColor,40,160)
    $Gfx.DrawString('$',$font,$KeywordColor,110,160)
    $Gfx.DrawString('var',$font,$FunctionColor,120,160)
    $Gfx.DrawString('}',$font,$ForegroundColor,10,185)

    $Gfx.Dispose()
    $Bitmap.Save($Filename)
}


function Convert-ColorCode
{
    param($Color)
    [System.Drawing.SolidBrush]::new([System.Drawing.ColorTranslator]::FromHtml($Color))
}

$Theme = @{
    BackgroundColor   = Convert-ColorCode '#151B24'
    ForegroundColor   = Convert-ColorCode '#efefef'
    StringColor       = Convert-ColorCode '#DA6771'
    CommentColor      = Convert-ColorCode '#4A5160'
    KeywordColor      = Convert-ColorCode '#399EF4'
    FunctionColor     = Convert-ColorCode '#21C5C7'
    FunctionCallColor = Convert-ColorCode '#fff099'
    ClassColor        = Convert-ColorCode '#21C5C7'
}

New-ThemeImage @Theme -Filename  "C:\Test.png"

When running that it produces a png that looks like this.

test

The idea would be that you could take the inputs from the generator and plug them into the functions to dynamically create a png with the proper colors.

from vscode-theme-generator.

Tyriar avatar Tyriar commented on May 25, 2024

While definitely cool, the problem with that is it doesn't look much like VS Code (and it's too much work to perfect it imo). I think you've hooked me on the screenshot of VS Code idea in https://github.com/gerane/VSCodeThemes/blob/master/CreateNewThemes/UpdateThemes.ps1

Combine that with some --user-data-dir magic and we can get things like line numbers, whitespace, guides, etc. displaying in an automated manner too.

from vscode-theme-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.